S
- the type of StreamingDataInputpublic interface StreamingDataInput<S extends StreamingDataInput<S>> extends StreamingCommon<S>
Reading methods in this interface are usually expected to advance the read position by the number of bytes read. This allows consecutive calls to the read methods to sequentially read chunks of data from the stream.
Additionally, StreamingDataInput provides support for leniency and conversion of data into BigInteger or BigDecimal objects. When lenient mode is enabled, methods will return default values when there's no more data to read, instead of throwing exceptions.
The interface includes methods for handling exceptions and managing the state of the stream, such as checking the remaining bytes or throwing an exception if the stream has been previously released.
Defines a data input interface that supports setting and getting positions and limits. Implementing classes can be used to read data from a data source, typically a byte stream or byte buffer.
Note: Implementations of this interface may choose to handle the actual reading of data in various ways, such as through direct memory access or other optimized mechanisms.
Modifier and Type | Method and Description |
---|---|
long |
addressForRead(long offset)
Retrieves the underlying memory address for reading.
|
default long |
addressForRead(long offset,
int buffer)
Retrieves the underlying memory address for reading.
|
long |
addressForWrite(long offset)
Retrieves the underlying memory address for writing.
|
long |
addressForWritePosition()
Retrieves the underlying memory address for writing at the current write position.
|
default ByteOrder |
byteOrder()
Retrieves the byte order used by the buffer.
|
@NotNull Bytes<?> |
bytesForRead()
Retrieves a Bytes object for reading.
|
@NotNull Bytes<?> |
bytesForWrite()
Retrieves a Bytes object for writing.
|
default long |
capacity() |
long |
copyTo(@NotNull BytesStore to)
Copies the data from the input stream to the provided BytesStore.
|
void |
copyTo(@NotNull OutputStream out)
Copies the data from the input stream to the provided OutputStream.
|
default @NotNull InputStream |
inputStream()
Provides an InputStream for the data represented by this StreamingDataInput.
|
boolean |
isDirectMemory()
Checks if the buffer uses direct memory.
|
default long |
lengthWritten(long startPosition)
Calculates the length of data written from the given start position.
|
boolean |
lenient() |
void |
lenient(boolean lenient)
When there is no more data to read, return zero,
false and empty string. |
default long |
parseHexLong()
Parses a hexadecimal long value from the input stream.
|
default void |
parseUtf8(@NotNull Appendable sb,
boolean utf,
int length)
Parses a UTF-8 string from the input stream into the provided Appendable.
|
default void |
parseUtf8(@NotNull Appendable sb,
int encodedLength)
Parses a UTF-8 string from the input stream into the provided Appendable.
|
int |
peekUnsignedByte()
Peeks (reads without moving the read pointer) the next unsigned byte from the input stream.
|
default byte |
rawReadByte()
Reads a raw byte value from the input stream.
|
default int |
rawReadInt()
Reads a 32-bit integer value from the input stream without performing boundary checks.
|
default long |
rawReadLong()
Reads a 64-bit long value from the input stream without performing boundary checks.
|
default int |
read(byte[] bytes)
Reads the input stream into the provided byte array.
|
default int |
read(byte[] bytes,
int off,
int len)
Reads the input stream into the provided byte array, starting from the given offset and reading up to the specified length.
|
default void |
read(@NotNull ByteBuffer buffer)
Reads the input stream into the provided ByteBuffer.
|
default void |
read(@NotNull Bytes<?> bytes)
Transfers as many bytes as possible from the input stream into the provided Bytes object.
|
default void |
read(@NotNull Bytes<?> bytes,
int length)
Transfers the specified number of bytes from the input stream into the provided Bytes object.
|
default int |
read(char[] bytes,
int off,
int len)
Reads the input stream into the provided char array, starting from the given offset and reading up to the specified length.
|
default @Nullable String |
read8bit()
Reads an 8-bit encoded string from the input stream.
|
default boolean |
read8bit(@NotNull Bytes<?> b)
Reads an 8-bit encoded string from the input stream and appends it to the provided Bytes.
|
default boolean |
read8bit(@NotNull StringBuilder sb)
Reads an 8-bit encoded string from the input stream and appends it to the provided StringBuilder.
|
default @NotNull BigDecimal |
readBigDecimal()
Creates and returns a new BigDecimal representing the contents of this Bytes object.
|
default @NotNull BigInteger |
readBigInteger()
Creates and returns a new BigInteger representing the contents of this Bytes object or
BigInteger.ZERO
if this Bytes object is empty. |
default boolean |
readBoolean()
Reads a boolean value from the input stream.
|
byte |
readByte()
Reads a byte value from the input stream.
|
default char |
readChar()
Reads a character value from the input stream.
|
double |
readDouble()
Reads a 64-bit floating-point number from the input stream.
|
default <E extends Enum<E>> |
readEnum(@NotNull Class<E> eClass)
Reads an Enum value from the input stream.
|
float |
readFloat()
Reads a 32-bit floating-point number from the input stream.
|
default void |
readHistogram(@NotNull net.openhft.chronicle.core.util.Histogram histogram)
Reads data from the input stream into the provided Histogram.
|
default long |
readIncompleteLong() |
int |
readInt()
Reads a 32-bit integer value from the input stream.
|
default int |
readInt24()
Reads a 24-bit signed integer value from the input stream.
|
default long |
readLimit()
If the resource is closed, the returned value is unspecified.
|
S |
readLimit(long limit)
Sets the read limit of this StreamingDataInput.
|
default S |
readLimitToCapacity()
Sets the read limit of this StreamingDataInput to its capacity.
|
long |
readLong()
Reads a 64-bit long value from the input stream.
|
default long |
readPosition()
Returns the read position.
|
S |
readPosition(long position)
Sets the read position of this StreamingDataInput.
|
default long |
readPositionForHeader(boolean skipPadding)
Obtains the current read position, optionally skipping padding bytes if specified.
|
default S |
readPositionRemaining(long position,
long remaining)
Sets the read position and limit of this StreamingDataInput based on the specified position and remaining values.
|
default S |
readPositionUnlimited(long position)
Sets the read position of this StreamingDataInput without limiting it to the current read limit.
|
default long |
readRemaining()
Calculates the number of bytes remaining that can be read from the current read position.
|
short |
readShort()
Reads a 16-bit short value from the input stream.
|
S |
readSkip(long bytesToSkip)
Skips the specified number of bytes by advancing the read position.
|
default long |
readStopBit()
Reads a variable-length integer encoded using the stop bit encoding.
|
default char |
readStopBitChar()
Reads a variable-length character encoded using the stop bit encoding.
|
default double |
readStopBitDecimal()
Reads a decimal number represented as a variable-length double and scale encoded using the stop bit encoding.
|
default double |
readStopBitDouble()
Reads a variable-length double encoded using the stop bit encoding.
|
int |
readUnsignedByte()
Reads the next unsigned 8-bit value from the input stream.
|
default long |
readUnsignedInt()
Reads a 32-bit value from the input stream and converts it to an unsigned integer by masking the sign bit.
|
default int |
readUnsignedInt24()
Reads a 24-bit unsigned integer value from the input stream.
|
default int |
readUnsignedShort()
Reads a 16-bit value from the input stream and converts it to an unsigned short by masking the sign bit.
|
default @Nullable String |
readUtf8()
Reads a UTF-8 encoded string from the input stream.
|
default boolean |
readUtf8(@NotNull Bytes<?> sb)
Reads a UTF-8 encoded string from the input stream and appends it to the provided Bytes.
|
default <C extends Appendable & CharSequence> |
readUtf8(C sb)
Reads a UTF-8 encoded string from the input stream and appends it to the provided appendable.
|
default boolean |
readUtf8(@NotNull StringBuilder sb)
Reads a UTF-8 encoded string from the input stream and appends it to the provided StringBuilder.
|
int |
readVolatileInt()
Reads a volatile (concurrently mutable) integer value from the input stream.
|
long |
readVolatileLong()
Reads a volatile (concurrently mutable) long value from the input stream.
|
default void |
readWithLength(@NotNull Bytes<?> bytes)
Reads data from the input stream with specified length into the provided Bytes.
|
default void |
readWithLength(long length,
@NotNull net.openhft.chronicle.core.util.ThrowingConsumer<S,net.openhft.chronicle.core.io.IORuntimeException> bytesConsumer)
Perform a set of actions within a temporary bounds mode.
|
default void |
readWithLength0(long length,
@NotNull net.openhft.chronicle.core.util.ThrowingConsumerNonCapturing<S,net.openhft.chronicle.core.io.IORuntimeException,BytesOut> bytesConsumer,
StringBuilder sb,
BytesOut<?> toBytes)
Perform a set of actions within a temporary bounds mode.
|
default long |
realCapacity() |
default long |
realReadRemaining()
Calculates the number of bytes that can be safely read directly.
|
default long |
realWriteRemaining()
Calculates the number of bytes remaining that can be written from the current write position with resizing.
|
boolean |
sharedMemory()
Checks if the Bytes use shared memory.
|
default long |
start() |
void |
uncheckedReadSkipBackOne()
Unchecked version of readSkip(-1).
|
void |
uncheckedReadSkipOne()
Unchecked version of readSkip(1).
|
int |
uncheckedReadUnsignedByte()
Reads the next unsigned 8-bit value from the input stream without performing boundary checks.
|
default S |
unsafeRead(long address,
int length)
Reads data from the input stream into the memory at the provided address.
|
default void |
unsafeReadObject(@NotNull Object o,
int length)
Deprecated.
|
default void |
unsafeReadObject(@NotNull Object o,
int offset,
int length)
Reads data from the input stream into the provided object, starting from the given offset.
|
default long |
writeLimit()
Retrieves the maximum writable position within the buffer.
|
default long |
writePosition()
Returns the write position.
|
default long |
writeRemaining()
Calculates the number of bytes remaining that can be written from the current write position.
|
clear
@NotNull S readPosition(long position) throws BufferUnderflowException, IllegalStateException, net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
position
- the new read position, must be non-negativeBufferUnderflowException
- If the new position is greater than the limitnet.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe wayIllegalStateException
@NotNull default S readPositionUnlimited(long position) throws BufferUnderflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
position
- the new read position, must be non-negativeBufferUnderflowException
- If the new position is greater than the capacitynet.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe way@NotNull default S readPositionRemaining(long position, long remaining) throws BufferUnderflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
position
- the new read position, must be non-negativeremaining
- the remaining size, which is used to set the read limitBufferUnderflowException
- If the new position is greater than the read limitnet.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe way@NotNull S readLimit(long limit) throws BufferUnderflowException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
limit
- the new read limit, must be non-negativeBufferUnderflowException
- If the new limit is less than the read positionnet.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe waydefault S readLimitToCapacity() throws BufferUnderflowException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
BufferUnderflowException
- If the capacity is less than the read positionnet.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe way@NotNull S readSkip(long bytesToSkip) throws BufferUnderflowException, IllegalStateException, net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
bytesToSkip
- the number of bytes to skipBufferUnderflowException
- If the new read position is outside the limits of the data sourcenet.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe wayIllegalStateException
default long readPositionForHeader(boolean skipPadding) throws net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
skipPadding
- if true, aligns the read position to a 4-byte boundary by skipping padding bytesnet.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe wayvoid uncheckedReadSkipOne()
void uncheckedReadSkipBackOne()
default void readWithLength0(long length, @NotNull @NotNull net.openhft.chronicle.core.util.ThrowingConsumerNonCapturing<S,net.openhft.chronicle.core.io.IORuntimeException,BytesOut> bytesConsumer, StringBuilder sb, BytesOut<?> toBytes) throws BufferUnderflowException, net.openhft.chronicle.core.io.IORuntimeException, net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
length
- the length to set the temporary bounds tobytesConsumer
- the consumer to execute within the temporary boundssb
- the StringBuilder to usetoBytes
- the BytesOut to useBufferUnderflowException
- If the specified length is greater than the number of bytes remaining to readnet.openhft.chronicle.core.io.IORuntimeException
- If the bytesConsumer encounters an IO errornet.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe waydefault void readWithLength(long length, @NotNull @NotNull net.openhft.chronicle.core.util.ThrowingConsumer<S,net.openhft.chronicle.core.io.IORuntimeException> bytesConsumer) throws BufferUnderflowException, net.openhft.chronicle.core.io.IORuntimeException, net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
length
- the length to set the temporary bounds tobytesConsumer
- the consumer to execute within the temporary boundsBufferUnderflowException
- If the specified length is greater than the number of bytes remaining to readnet.openhft.chronicle.core.io.IORuntimeException
- If the bytesConsumer encounters an IO errornet.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe way@NotNull default @NotNull InputStream inputStream()
default long readStopBit() throws net.openhft.chronicle.core.io.IORuntimeException, net.openhft.chronicle.core.io.ClosedIllegalStateException, BufferUnderflowException
BytesInternal.readStopBit(this)
.net.openhft.chronicle.core.io.IORuntimeException
- If an I/O error occursBufferUnderflowException
- If there's not enough data to readnet.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe waydefault char readStopBitChar() throws net.openhft.chronicle.core.io.IORuntimeException, net.openhft.chronicle.core.io.ClosedIllegalStateException, BufferUnderflowException
BytesInternal.readStopBitChar(this)
.net.openhft.chronicle.core.io.IORuntimeException
- If an I/O error occursBufferUnderflowException
- If there's not enough data to readnet.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe waydefault double readStopBitDouble() throws net.openhft.chronicle.core.io.ClosedIllegalStateException
BytesInternal.readStopBitDouble(this)
.net.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe waydefault double readStopBitDecimal() throws net.openhft.chronicle.core.io.ClosedIllegalStateException, BufferUnderflowException
BufferUnderflowException
- If there's not enough data to readnet.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe waydefault boolean readBoolean() throws net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
BytesUtil.byteToBoolean(b)
.net.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe waybyte readByte() throws net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
net.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe waydefault byte rawReadByte() throws net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
readByte()
is that the latter might perform additional processing or checks.net.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe waydefault char readChar() throws net.openhft.chronicle.core.io.ClosedIllegalStateException, BufferUnderflowException
net.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.BufferUnderflowException
- If there's not enough data to readint readUnsignedByte() throws net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
net.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe wayint uncheckedReadUnsignedByte()
short readShort() throws BufferUnderflowException, IllegalStateException, net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
BufferUnderflowException
- If there's not enough data to readnet.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe wayIllegalStateException
default int readUnsignedShort() throws BufferUnderflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
BufferUnderflowException
- If there's not enough data to readnet.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe waydefault int readInt24() throws BufferUnderflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
BufferUnderflowException
- If there's not enough data to readnet.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe waydefault int readUnsignedInt24() throws BufferUnderflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
BufferUnderflowException
- If there's not enough data to readnet.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe wayint readInt() throws BufferUnderflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
BufferUnderflowException
- If there's not enough data to readnet.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe waydefault int rawReadInt() throws BufferUnderflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
BufferUnderflowException
- If there's not enough data to readnet.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe waydefault long readUnsignedInt() throws BufferUnderflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
BufferUnderflowException
- If there's not enough data to readnet.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe waylong readLong() throws BufferUnderflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
BufferUnderflowException
- If there's not enough data to readnet.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe waydefault long rawReadLong() throws BufferUnderflowException, IllegalStateException, net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
BufferUnderflowException
- If there's not enough data to readnet.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe wayIllegalStateException
default long readIncompleteLong() throws net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
net.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe wayfloat readFloat() throws BufferUnderflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
BufferUnderflowException
- If there's not enough data to readnet.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe waydouble readDouble() throws BufferUnderflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
BufferUnderflowException
- If there's not enough data to readnet.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe way@Nullable default @Nullable String readUtf8() throws BufferUnderflowException, net.openhft.chronicle.core.io.IORuntimeException, net.openhft.chronicle.core.io.ClosedIllegalStateException, ArithmeticException
null
values and
utilizes stop bit encoding for length, saving one byte for strings shorter than 128 characters.null
if writeUtf8(null)
was calledBufferUnderflowException
- If there's not enough data to readnet.openhft.chronicle.core.io.IORuntimeException
- If an IO error occursnet.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.ArithmeticException
- If numeric overflow or underflow occurs@Nullable default @Nullable String read8bit() throws net.openhft.chronicle.core.io.IORuntimeException, BufferUnderflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException, ArithmeticException
null
if write8bit(null)
was calledBufferUnderflowException
- If there's not enough data to readnet.openhft.chronicle.core.io.IORuntimeException
- If an IO error occursnet.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.ArithmeticException
- If numeric overflow or underflow occursdefault <C extends Appendable & CharSequence> boolean readUtf8(@NotNull C sb) throws net.openhft.chronicle.core.io.IORuntimeException, BufferUnderflowException, ArithmeticException, net.openhft.chronicle.core.io.ClosedIllegalStateException, IllegalArgumentException
readUtf8()
, except it populates a provided appendable instead of creating a new string.sb
- the appendable to which the read string will be appendedtrue
if there was a String, or false
if it was null
net.openhft.chronicle.core.io.IORuntimeException
- If an IO error occursBufferUnderflowException
- If there's not enough data to readArithmeticException
- If numeric overflow or underflow occursnet.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.IllegalArgumentException
- If the appendable does not allow setting lengthdefault boolean readUtf8(@NotNull @NotNull Bytes<?> sb) throws net.openhft.chronicle.core.io.IORuntimeException, BufferUnderflowException, ArithmeticException, net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
readUtf8()
, except it populates a provided Bytes instance instead of creating a new string.sb
- the Bytes instance to which the read string will be appendedtrue
if there was a String, or false
if it was null
net.openhft.chronicle.core.io.IORuntimeException
- If an IO error occursBufferUnderflowException
- If there's not enough data to readArithmeticException
- If numeric overflow or underflow occursnet.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe waydefault boolean readUtf8(@NotNull @NotNull StringBuilder sb) throws net.openhft.chronicle.core.io.IORuntimeException, BufferUnderflowException, ArithmeticException, net.openhft.chronicle.core.io.ClosedIllegalStateException
readUtf8()
, except it populates a provided StringBuilder instead of creating a new string.sb
- the StringBuilder to which the read string will be appendedtrue
if there was a String, or false
if it was null
net.openhft.chronicle.core.io.IORuntimeException
- If an IO error occursBufferUnderflowException
- If there's not enough data to readArithmeticException
- If numeric overflow or underflow occursnet.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe waydefault boolean read8bit(@NotNull @NotNull Bytes<?> b) throws BufferUnderflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException, ArithmeticException, BufferOverflowException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
b
- the Bytes instance to which the read string will be appendedtrue
if there was a String, or false
if it was null
BufferUnderflowException
- If there's not enough data to readArithmeticException
- If numeric overflow or underflow occursBufferOverflowException
- If the buffer is fullnet.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe waydefault boolean read8bit(@NotNull @NotNull StringBuilder sb) throws net.openhft.chronicle.core.io.IORuntimeException, BufferUnderflowException, ArithmeticException, net.openhft.chronicle.core.io.ClosedIllegalStateException
sb
- the StringBuilder to which the read string will be appendedtrue
if there was a String, or false
if it was null
net.openhft.chronicle.core.io.IORuntimeException
- If an IO error occursBufferUnderflowException
- If there's not enough data to readArithmeticException
- If numeric overflow or underflow occursnet.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe waydefault int read(byte[] bytes) throws BufferUnderflowException, IllegalStateException, net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
bytes
- the byte array to fill with the read dataBufferUnderflowException
- If there's not enough data to readnet.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe wayIllegalStateException
default int read(byte[] bytes, int off, int len) throws BufferUnderflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
bytes
- the byte array to fill with the read dataoff
- the start offset in the byte arraylen
- the maximum number of bytes to readBufferUnderflowException
- If there's not enough data to readnet.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe waydefault int read(char[] bytes, int off, int len) throws net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
bytes
- the char array to fill with the read dataoff
- the start offset in the char arraylen
- the maximum number of chars to readnet.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe waydefault void read(@NotNull @NotNull ByteBuffer buffer) throws net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
buffer
- the ByteBuffer to fill with the read datanet.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe waydefault void read(@NotNull @NotNull Bytes<?> bytes) throws net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
bytes
- the Bytes object to fill with the read datanet.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe wayStreamingDataOutput.write(BytesStore)
default void read(@NotNull @NotNull Bytes<?> bytes, int length) throws BufferUnderflowException, BufferOverflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
bytes
- the Bytes object to fill with the read datalength
- the number of bytes to readBufferUnderflowException
- If there's not enough data to readBufferOverflowException
- If there's not enough space in the provided Bytes objectnet.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe way@Deprecated default void unsafeReadObject(@NotNull @NotNull Object o, int length) throws BufferUnderflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
o
- the object to fill with the read datalength
- the number of bytes to readBufferUnderflowException
- If there's not enough data to readnet.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe waydefault void unsafeReadObject(@NotNull @NotNull Object o, int offset, int length) throws BufferUnderflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
o
- the object to fill with the read dataoffset
- the start offset in the objectlength
- the number of bytes to readBufferUnderflowException
- If there's not enough data to readnet.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe waydefault S unsafeRead(long address, int length) throws net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
address
- the address of the memory to fill with the read datalength
- the number of bytes to readnet.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe wayint readVolatileInt() throws BufferUnderflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
BufferUnderflowException
- If there's not enough data to readnet.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe waylong readVolatileLong() throws BufferUnderflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
BufferUnderflowException
- If there's not enough data to readnet.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe wayint peekUnsignedByte() throws net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
net.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe way@NotNull default <E extends Enum<E>> E readEnum(@NotNull @NotNull Class<E> eClass) throws net.openhft.chronicle.core.io.IORuntimeException, BufferUnderflowException, ArithmeticException, net.openhft.chronicle.core.io.ClosedIllegalStateException, BufferOverflowException
eClass
- the class of the Enumnet.openhft.chronicle.core.io.IORuntimeException
- If an I/O error occursBufferUnderflowException
- If there's not enough data to readArithmeticException
- If the number format is invalidnet.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.BufferOverflowException
- If there's not enough space in the bufferdefault void parseUtf8(@NotNull @NotNull Appendable sb, int encodedLength) throws IllegalArgumentException, BufferUnderflowException, UTFDataFormatRuntimeException, net.openhft.chronicle.core.io.ClosedIllegalStateException
sb
- the Appendable to fill with the parsed stringencodedLength
- the length of the UTF-8 encoded data in bytesIllegalArgumentException
- If an illegal argument is providedBufferUnderflowException
- If there's not enough data to readUTFDataFormatRuntimeException
- If the string is not valid UTF-8net.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe waydefault void parseUtf8(@NotNull @NotNull Appendable sb, boolean utf, int length) throws IllegalArgumentException, BufferUnderflowException, UTFDataFormatRuntimeException, net.openhft.chronicle.core.io.ClosedIllegalStateException
sb
- the Appendable to fill with the parsed stringutf
- true if the length is the UTF-8 encoded length, false if the length is the length of charslength
- the maximum number of bytes to readIllegalArgumentException
- If an illegal argument is providedBufferUnderflowException
- If there's not enough data to readUTFDataFormatRuntimeException
- If the string is not valid UTF-8net.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe waydefault long parseHexLong() throws BufferUnderflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException
BufferUnderflowException
- If there's not enough data to readnet.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe wayvoid copyTo(@NotNull @NotNull OutputStream out) throws IOException, net.openhft.chronicle.core.io.ClosedIllegalStateException
out
- the OutputStream to copy the data toIOException
- If an I/O error occursnet.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe waylong copyTo(@NotNull @NotNull BytesStore to) throws net.openhft.chronicle.core.io.ClosedIllegalStateException
to
- the BytesStore to copy the data tonet.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe waydefault void readHistogram(@NotNull @NotNull net.openhft.chronicle.core.util.Histogram histogram) throws BufferUnderflowException, IllegalStateException, ArithmeticException, net.openhft.chronicle.core.io.ClosedIllegalStateException
histogram
- the Histogram to fill with dataBufferUnderflowException
- If there's not enough data to readnet.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.ArithmeticException
- If the number format is invalidIllegalStateException
default void readWithLength(@NotNull @NotNull Bytes<?> bytes) throws ArithmeticException, BufferUnderflowException, BufferOverflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
bytes
- the Bytes to fill with dataArithmeticException
- If the number format is invalidBufferUnderflowException
- If there's not enough data to readBufferOverflowException
- If there's not enough space in the buffernet.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe wayvoid lenient(boolean lenient)
false
and empty string.lenient
- if true, return nothing rather than error.boolean lenient()
@NotNull default @NotNull BigDecimal readBigDecimal() throws ArithmeticException, BufferUnderflowException, IllegalStateException, net.openhft.chronicle.core.io.ClosedIllegalStateException
If this Byte object is empty, an object equal to BigDecimal.ZERO
is returned.
ArithmeticException
- If the content of this Bytes object could not be successfully convertedBufferUnderflowException
- If the content of this Bytes object is insufficient to be successfully convertednet.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe wayIllegalStateException
@NotNull default @NotNull BigInteger readBigInteger() throws ArithmeticException, BufferUnderflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException
BigInteger.ZERO
if this Bytes object is empty.ArithmeticException
- If the content of this Bytes object could not be successfully convertedBufferUnderflowException
- If the content of this Bytes object is insufficient to be successfully convertednet.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe waydefault long start()
default long capacity()
default long realCapacity()
default long readPosition()
The read position is start() <= readPosition() && readPosition() <= readLimit() && readPosition < safeLimit()
If the resource is closed, the returned value is unspecified.
default long writePosition()
The write position is readPosition() <= writePosition() && writePosition() <= writeLimit()
If the resource is closed, the returned value is unspecified.
default long lengthWritten(long startPosition)
Typically this calculates the difference however for HexDumpBytes it's not as simple.
If the resource is closed, the returned value is unspecified.
startPosition
- The position to calculate the length from.default long readRemaining()
If the resource is closed, the returned value is unspecified.
default long realReadRemaining()
If the resource is closed, the returned value is unspecified.
default long writeRemaining()
If the resource is closed, the returned value is unspecified.
default long realWriteRemaining()
If the resource is closed, the returned value is unspecified.
default long readLimit()
If the resource is closed, the returned value is unspecified.
default long writeLimit()
If the resource is closed, the returned value is unspecified.
long addressForRead(long offset) throws UnsupportedOperationException, BufferUnderflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
offset
- within this buffer. addressForRead(start()) is the actual addressForRead of the first byte.UnsupportedOperationException
- If the underlying buffer is on the heapBufferUnderflowException
- If the offset is before the start() or the after the capacity()net.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe waydefault long addressForRead(long offset, int buffer) throws UnsupportedOperationException, BufferUnderflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
offset
- The offset within this buffer.buffer
- The buffer index.UnsupportedOperationException
- If the underlying buffer is on the heap.BufferUnderflowException
- If the offset is before the start or after the capacity.net.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe waylong addressForWrite(long offset) throws UnsupportedOperationException, BufferOverflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
offset
- within this buffer. addressForRead(start()) is the actual addressForRead of the first byte.UnsupportedOperationException
- If the underlying buffer is on the heapBufferOverflowException
- If the offset is before the start() or the after the capacity()net.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe waylong addressForWritePosition() throws UnsupportedOperationException, BufferOverflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException
UnsupportedOperationException
- If the underlying buffer is on the heap.BufferOverflowException
- If the current write position is before the start or after the capacity.net.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe waydefault ByteOrder byteOrder()
@NotNull @NotNull Bytes<?> bytesForRead() throws net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
net.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe way@NotNull @NotNull Bytes<?> bytesForWrite() throws net.openhft.chronicle.core.io.ClosedIllegalStateException
net.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe wayboolean sharedMemory()
boolean isDirectMemory()
Copyright © 2023. All rights reserved.