public interface StreamingDataOutput<S extends StreamingDataOutput<S>> extends StreamingCommon<S>
The various write methods in this interface support writing bytes, arrays of bytes, and sequences
of bytes from other sources like ByteBuffer
and RandomDataInput
. It also provides
methods for writing primitive data types and their boxed counterparts. Additionally, it supports
writing complex data structures such as BigDecimal
, BigInteger
, Histogram
and objects in unsafe way.
Not all the methods are expected to be implemented by classes. Default methods are provided for common use cases. Classes that extend this interface can override these methods to provide more efficient or custom implementations.
Implementations of this interface are expected to handle cases where the buffer may not have
enough capacity to handle the write operation. In such cases, methods should throw a BufferOverflowException
.
Instances of classes implementing StreamingDataOutput are not guaranteed to be thread safe. If multiple threads interact with the same instance, external synchronization should be used.
RandomDataOutput
,
ByteBuffer
,
BufferOverflowException
,
BigDecimal
,
BigInteger
,
Histogram
Modifier and Type | Field and Description |
---|---|
static int |
JAVA9_STRING_CODER_LATIN |
static int |
JAVA9_STRING_CODER_UTF16 |
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 S |
appendUtf8(byte[] bytes,
int offset,
int length)
Appends a UTF-8 encoded byte array to this output stream, taking into account the provided offset and length.
|
default S |
appendUtf8(byte[] bytes,
int offset,
int length,
byte coder)
Appends a UTF-8 encoded byte array to this output stream, taking into account the provided offset, length, and coder.
|
default S |
appendUtf8(char[] chars,
int offset,
int length)
Appends a UTF-8 encoded CharSequence to this output stream from a specific offset and length.
|
default S |
appendUtf8(@NotNull CharSequence cs)
Appends a UTF-8 encoded CharSequence to this output stream.
|
default S |
appendUtf8(@NotNull CharSequence cs,
int offset,
int length)
Appends a UTF-8 encoded CharSequence to this output stream from a specific offset and length.
|
default S |
appendUtf8(int codepoint)
Appends a UTF-8 encoded character to this output stream.
|
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 boolean |
canWriteDirect(long count)
Determines if the buffer can write the specified count of bytes directly.
|
default long |
capacity() |
default void |
copyFrom(@NotNull InputStream input)
Copies data from the provided InputStream into this Bytes object.
|
void |
ensureCapacity(long desiredCapacity)
Ensures that the buffer has the desired capacity.
|
byte[] |
internalNumberBuffer()
Deprecated.
|
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.
|
default @NotNull OutputStream |
outputStream()
Provides a view of this Bytes object as an OutputStream.
|
default S |
rawWriteByte(byte i8)
Writes a byte to the data stream without any additional checks or transformations.
|
default S |
rawWriteInt(int i)
Writes an integer to the data stream without any additional checks or transformations.
|
default S |
rawWriteLong(long i)
Writes a long integer to the data stream without performing a bounds check.
|
default long |
readLimit()
If the resource is closed, the returned value is unspecified.
|
default long |
readPosition()
Returns the read position.
|
default long |
readRemaining()
Calculates the number of bytes remaining that can be read from the current read position.
|
long |
realCapacity()
Returns the actual capacity of the buffer without resize.
|
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() |
default S |
unsafeWrite(long address,
int length)
Writes raw native memory to this output stream.
|
default S |
unsafeWriteObject(Object o,
int length)
Writes the memory content of an object to this output stream.
|
default S |
unsafeWriteObject(Object o,
int offset,
int length)
Writes the memory content of an object to this output stream from a specific offset.
|
default S |
write(byte[] byteArray)
Writes all the bytes from the given
byteArray into the output stream. |
S |
write(byte[] byteArray,
int offset,
int length)
Writes the specified number of bytes from the given
byteArray into the output stream, starting from the
given offset. |
default S |
write(@NotNull BytesStore<?,?> bytes)
Writes all available data from the specified
BytesStore into the output stream. |
default S |
write(@NotNull BytesStore<?,?> bytes,
long readOffset,
long length)
Writes the specified number of bytes from the provided
BytesStore into the output stream,
starting from the given read offset. |
default S |
write(@NotNull CharSequence text)
Writes the provided
text to this StreamingDataOutput at the current writePosition(). |
default S |
write(@NotNull CharSequence text,
int startText,
int length)
Writes the provided
text to this StreamingDataOutput at the current writePosition() |
default S |
write(@NotNull RandomDataInput bytes)
Writes all available data from the specified
RandomDataInput into the output stream. |
default S |
write(@NotNull RandomDataInput bytes,
long readOffset,
long length)
Writes the specified number of bytes from the provided
RandomDataInput object into the output stream,
starting from the given read offset. |
default S |
write8bit(@Nullable CharSequence text)
Writes a CharSequence as an 8-bit string to the data stream.
|
default S |
write8bit(@NotNull CharSequence text,
int start,
int length)
Writes a subsequence of a CharSequence as an 8-bit string to the data stream.
|
default S |
write8bit(@Nullable String s)
Writes a String as an 8-bit string to the data stream.
|
S |
write8bit(@NotNull String text,
int start,
int length)
Writes a subsequence of a String as an 8-bit string to the data stream.
|
default void |
writeBigDecimal(@NotNull BigDecimal bd)
Writes the given BigDecimal into this Bytes object.
|
default void |
writeBigInteger(@NotNull BigInteger bi)
Writes the given BigInteger into this Bytes object.
|
default S |
writeBoolean(boolean flag)
Writes a boolean value to this output stream.
|
S |
writeByte(byte i8)
Writes a byte to the data stream.
|
default S |
writeChar(char ch)
Writes a char to the data stream as a stop bit encoded value.
|
S |
writeDouble(double d)
Writes a double-precision floating-point number to the data stream.
|
S |
writeDoubleAndInt(double d,
int i)
Writes a double-precision floating-point number followed by an integer to the data stream.
|
default <E extends Enum<E>> |
writeEnum(E e)
Writes an enum value to this output stream by writing the enum's name.
|
S |
writeFloat(float f)
Writes a floating-point number to the data stream.
|
default void |
writeHistogram(@NotNull net.openhft.chronicle.core.util.Histogram histogram)
Writes the given Histogram object into this Bytes object.
|
S |
writeInt(int i)
Writes an integer to the data stream.
|
default S |
writeInt24(int i)
Writes a 24-bit integer to the data stream.
|
S |
writeIntAdv(int i,
int advance)
Writes an integer to the data stream, then advances the write position by the specified amount.
|
default long |
writeLimit()
Retrieves the maximum writable position within the buffer.
|
S |
writeLimit(long limit)
Sets the limit for writing to the data stream.
|
S |
writeLong(long i64)
Writes a long integer to the data stream.
|
S |
writeLongAdv(long i64,
int advance)
Writes a long integer to the data stream, then advances the write position by the specified amount.
|
S |
writeOrderedInt(int i)
Writes an integer value to this output stream using an ordered-writing mechanism.
|
S |
writeOrderedLong(long i)
Writes a long value to this output stream using an ordered-writing mechanism.
|
default long |
writePosition()
Returns the write position.
|
S |
writePosition(long position)
Sets the current write position in the data stream.
|
default long |
writePositionForHeader(boolean skipPadding)
Returns the current write position while optionally skipping any padding needed for a header.
|
default void |
writePositionRemaining(long position,
long length)
Sets the write position and the remaining length of writable bytes in this Bytes object.
|
default long |
writeRemaining()
Calculates the number of bytes remaining that can be written from the current write position.
|
S |
writeShort(short i16)
Writes a short integer to the data stream.
|
S |
writeSkip(long bytesToSkip)
Skips a specified number of bytes from the current write position in the data stream.
|
S |
writeSome(@NotNull ByteBuffer buffer)
Writes the available data from the provided
ByteBuffer into this Bytes object. |
default S |
writeSome(@NotNull Bytes<?> bytes)
Deprecated.
use write(bytes) instead and alter the bytes as you intended
|
default S |
writeStopBit(char x)
Writes a stop bit encoded char to the data stream.
|
default S |
writeStopBit(double d)
Writes a stop bit encoded double value to the data stream.
|
default S |
writeStopBit(long x)
Writes a stop bit encoded long to the data stream.
|
default S |
writeStopBitDecimal(double d)
Writes a double value to the data stream with a stop bit encoded decimal.
|
default S |
writeUnsignedByte(int i)
Writes an unsigned byte to the data stream.
|
default S |
writeUnsignedInt(long i)
Writes an unsigned integer to the data stream.
|
default S |
writeUnsignedInt24(int i)
Writes an unsigned 24-bit integer to the data stream.
|
default S |
writeUnsignedShort(int u16)
Writes an unsigned short integer to the data stream.
|
default S |
writeUtf8(@Nullable CharSequence text)
Writes a UTF-8 encoded string to the data stream, similar to writeUTF, but with a few differences.
|
default S |
writeUtf8(@Nullable String text)
Writes a UTF-8 encoded String to the data stream.
|
default void |
writeWithLength(@NotNull RandomDataInput bytes)
Writes data from the provided RandomDataInput into this Bytes object with prefixed length.
|
clear
static final int JAVA9_STRING_CODER_LATIN
static final int JAVA9_STRING_CODER_UTF16
@NotNull S writePosition(long position) throws BufferOverflowException
position
- The new write position. It must be a non-negative number.BufferOverflowException
- if the specified position exceeds the limit of the data buffer.@NotNull S writeLimit(long limit) throws BufferOverflowException
limit
- The new write limit. It must be a non-negative number.BufferOverflowException
- if the specified limit is less than the current write position.@NotNull S writeSkip(long bytesToSkip) throws BufferOverflowException, IllegalStateException
bytesToSkip
- The number of bytes to skip. This can be a negative number to move the
position backward.BufferOverflowException
- if the new position calculated by the skip operation falls
outside the limits of the data buffer.IllegalStateException
- if releaseddefault long writePositionForHeader(boolean skipPadding)
skipPadding
- If true, aligns the write position to the next 4-byte boundary.@NotNull default @NotNull OutputStream outputStream()
@NotNull default S writeStopBit(long x) throws BufferOverflowException, IllegalStateException
x
- The long value to be written to the data stream.BufferOverflowException
- if there is insufficient space in the buffer.IllegalStateException
- if released@NotNull default S writeStopBit(char x) throws BufferOverflowException, IllegalStateException
x
- The char value to be written to the data stream.BufferOverflowException
- if there is insufficient space in the buffer.IllegalStateException
- if released@NotNull default S writeStopBit(double d) throws BufferOverflowException, IllegalStateException
d
- The double value to be written to the data stream.BufferOverflowException
- if there is insufficient space in the buffer.IllegalStateException
- if released@NotNull default S writeStopBitDecimal(double d) throws BufferOverflowException, IllegalStateException
d
- The double value to be written to the data stream.BufferOverflowException
- if there is insufficient space in the buffer.IllegalStateException
- if released@NotNull default S writeUtf8(@Nullable @Nullable CharSequence text) throws BufferOverflowException, IllegalStateException, IllegalArgumentException, BufferUnderflowException
text
- The string to be written. Can be null.BufferOverflowException
- if there is insufficient space in the buffer.IllegalStateException
- if releasedIllegalArgumentException
BufferUnderflowException
@NotNull default S writeUtf8(@Nullable @Nullable String text) throws BufferOverflowException, IllegalStateException, BufferUnderflowException, IllegalArgumentException
text
- The string to be written. Can be null.BufferOverflowException
- if there is insufficient space in the buffer.IllegalStateException
- if releasedBufferUnderflowException
IllegalArgumentException
@NotNull default S write8bit(@Nullable @Nullable CharSequence text) throws BufferOverflowException, ArithmeticException, IllegalStateException, BufferUnderflowException
text
- The CharSequence to be written. Can be null.BufferOverflowException
- if there is insufficient space in the buffer.IllegalStateException
- if releasedArithmeticException
BufferUnderflowException
@NotNull default S write8bit(@NotNull @NotNull CharSequence text, int start, int length) throws BufferOverflowException, IndexOutOfBoundsException, ArithmeticException, IllegalStateException, BufferUnderflowException
text
- The CharSequence to be written.start
- The index of the first char in the CharSequence to write.length
- The number of chars from the CharSequence to write.BufferOverflowException
- if there is insufficient space in the buffer.IllegalStateException
- if releasedIndexOutOfBoundsException
ArithmeticException
BufferUnderflowException
@NotNull S write8bit(@NotNull @NotNull String text, int start, int length)
text
- The String to be written.start
- The index of the first char in the String to write.length
- The number of chars from the String to write.@NotNull default S write(@NotNull @NotNull CharSequence text) throws BufferOverflowException, IndexOutOfBoundsException, IllegalStateException
text
to this StreamingDataOutput at the current writePosition().text
- to writeBufferOverflowException
- if the provided text
cannot be accommodated.IllegalStateException
- if this StreamingDataOutput has been previously released.IllegalArgumentException
- if the provided text
is null
.IndexOutOfBoundsException
@NotNull default S write(@NotNull @NotNull CharSequence text, int startText, int length) throws BufferOverflowException, IndexOutOfBoundsException, IllegalStateException
text
to this StreamingDataOutput at the current writePosition()text
- to writestartText
- offset from where text should be copied fromlength
- number of characters to write.BufferOverflowException
- if the provided text
cannot be accommodated.IllegalStateException
- if this StreamingDataOutput has been previously released.NullPointerException
- if the provided text
is null
.IllegalArgumentException
- if the provided startText
or the provided length
is negative.IndexOutOfBoundsException
@NotNull default S write8bit(@Nullable @Nullable String s) throws BufferOverflowException, ArithmeticException, IllegalStateException
s
- The String to be written. Can be null.BufferOverflowException
- if there is insufficient space in the buffer.IllegalStateException
- if releasedArithmeticException
@NotNull S writeByte(byte i8) throws BufferOverflowException, IllegalStateException
i8
- The byte to be written.BufferOverflowException
- if there is insufficient space in the buffer.IllegalStateException
- if releaseddefault S rawWriteByte(byte i8) throws BufferOverflowException, IllegalStateException
i8
- The byte to be written.BufferOverflowException
- if there is insufficient space in the buffer.IllegalStateException
- if released@NotNull default S writeUnsignedByte(int i) throws BufferOverflowException, ArithmeticException, IllegalStateException
i
- The integer to be written as an unsigned byte.BufferOverflowException
- if there is insufficient space in the buffer.IllegalStateException
- if releasedArithmeticException
@NotNull default S writeChar(char ch) throws BufferOverflowException, IllegalStateException
ch
- The char to be written.BufferOverflowException
- if there is insufficient space in the buffer.IllegalStateException
- if released@NotNull S writeShort(short i16) throws BufferOverflowException, IllegalStateException
i16
- The short integer to be written.BufferOverflowException
- if there is insufficient space in the buffer.IllegalStateException
- if released@NotNull default S writeUnsignedShort(int u16) throws BufferOverflowException, ArithmeticException, IllegalStateException
u16
- The integer to be written as an unsigned short.BufferOverflowException
- if there is insufficient space in the buffer.IllegalStateException
- if releasedArithmeticException
@NotNull default S writeInt24(int i) throws BufferOverflowException, ArithmeticException, IllegalStateException
i
- The integer to be written.BufferOverflowException
- if there is insufficient space in the buffer.IllegalStateException
- if releasedArithmeticException
@NotNull default S writeUnsignedInt24(int i) throws BufferOverflowException, ArithmeticException, IllegalStateException
i
- The integer to be written.BufferOverflowException
- if there is insufficient space in the buffer.IllegalStateException
- if releasedArithmeticException
@NotNull S writeInt(int i) throws BufferOverflowException, IllegalStateException
i
- The integer to be written.BufferOverflowException
- if there is insufficient space in the buffer.IllegalStateException
- if releaseddefault S rawWriteInt(int i) throws BufferOverflowException, IllegalStateException
i
- The integer to be written.BufferOverflowException
- if there is insufficient space in the buffer.IllegalStateException
- if released@NotNull S writeIntAdv(int i, int advance) throws BufferOverflowException, IllegalStateException
i
- The integer to be written.advance
- The number of bytes to advance the write position after the integer has been written.BufferOverflowException
- if there is insufficient space in the buffer.IllegalStateException
- if released@NotNull default S writeUnsignedInt(long i) throws BufferOverflowException, ArithmeticException, IllegalStateException
i
- The long to be written as an unsigned integer.BufferOverflowException
- if there is insufficient space in the buffer.IllegalStateException
- if releasedArithmeticException
@NotNull S writeLong(long i64) throws BufferOverflowException, IllegalStateException
i64
- The long integer to be written.BufferOverflowException
- if there is insufficient space in the buffer.IllegalStateException
- if releaseddefault S rawWriteLong(long i) throws BufferOverflowException, IllegalStateException
i
- The long integer to be written.BufferOverflowException
- if there is insufficient space in the buffer.IllegalStateException
- if released@NotNull S writeLongAdv(long i64, int advance) throws BufferOverflowException, IllegalStateException
i64
- The long integer to be written.advance
- The number of bytes to advance the write position after the long integer has been written.BufferOverflowException
- if there is insufficient space in the buffer.IllegalStateException
- if released@NotNull S writeFloat(float f) throws BufferOverflowException, IllegalStateException
f
- The floating-point number to be written.BufferOverflowException
- if there is insufficient space in the buffer.IllegalStateException
- if released@NotNull S writeDouble(double d) throws BufferOverflowException, IllegalStateException
d
- The double-precision floating-point number to be written.BufferOverflowException
- if there is insufficient space in the buffer.IllegalStateException
- if released@NotNull S writeDoubleAndInt(double d, int i) throws BufferOverflowException, IllegalStateException
d
- The double-precision floating-point number to be written.i
- The integer to be written.BufferOverflowException
- if there is insufficient space in the buffer.IllegalStateException
- if released@NotNull default S write(@NotNull @NotNull RandomDataInput bytes) throws BufferOverflowException, IllegalStateException
RandomDataInput
into the output stream.
The position of this output stream is updated accordingly, but the read position of the input data is not changed.
The operation will fail if there is not enough space left in the output stream.bytes
- the RandomDataInput
from which data is read.IllegalArgumentException
- if the provided bytes
is null
.BufferOverflowException
- if there is not enough space left in the output stream.IllegalStateException
- if releaseddefault S write(@NotNull @NotNull BytesStore<?,?> bytes) throws BufferOverflowException, IllegalStateException
BytesStore
into the output stream.
The position of this output stream is updated accordingly, but the read position of the input data is not changed.
The operation will fail if there is not enough space left in the output stream.bytes
- the BytesStore
from which data is read.BufferOverflowException
- if there is not enough space left in the output stream.IllegalStateException
- if releasedStreamingDataInput.read(Bytes)
void ensureCapacity(long desiredCapacity) throws DecoratedBufferOverflowException, IllegalStateException
DecoratedBufferOverflowException
will be thrown.desiredCapacity
- the required capacity.IllegalStateException
- if releasedDecoratedBufferOverflowException
- if the buffer is not elastic and lacks sufficient space, or
if the provided desiredCapacity
is negative.long realCapacity()
default boolean canWriteDirect(long count)
count
- the number of bytes to write.@Deprecated @NotNull default S writeSome(@NotNull @NotNull Bytes<?> bytes) throws IllegalStateException
Bytes
object into the output stream. The amount of data written is
the minimum of the remaining data in the Bytes
object and the remaining space in the output stream.
The position of this output stream is updated accordingly, but the read position of the input data is not changed.bytes
- the Bytes
object from which data is read.IllegalStateException
- if released@NotNull default S write(@NotNull @NotNull RandomDataInput bytes, long readOffset, long length) throws BufferOverflowException, BufferUnderflowException, IllegalStateException, IllegalArgumentException
RandomDataInput
object into the output stream,
starting from the given read offset.
The position of this output stream is updated accordingly, but the read position of the input data is not changed.bytes
- the RandomDataInput
from which data is read.readOffset
- the offset at which reading from the RandomDataInput
starts.length
- the number of bytes to write.BufferOverflowException
- if there is not enough space left in the output stream.BufferUnderflowException
- if there is not enough data available in the input.IllegalStateException
- if releasedIllegalArgumentException
- if the readOffset
or length
are invalid.@NotNull default S write(@NotNull @NotNull BytesStore<?,?> bytes, long readOffset, long length) throws BufferOverflowException, BufferUnderflowException, IllegalStateException, IllegalArgumentException
BytesStore
into the output stream,
starting from the given read offset. It ensures that the output stream has enough capacity
to accommodate the incoming bytes. The position of this output stream is updated accordingly,
but the read position of the input data is not changed.bytes
- the BytesStore
from which data is read.readOffset
- the offset at which reading from the BytesStore
starts.length
- the number of bytes to write.BufferOverflowException
- if there is not enough space left in the output stream.BufferUnderflowException
- if there is not enough data available in the input.IllegalStateException
- if releasedIllegalArgumentException
- if the readOffset
or length
are invalid.NullPointerException
- if the provided bytes
object is null
.@NotNull default S write(byte[] byteArray) throws BufferOverflowException, IllegalStateException
byteArray
into the output stream. The position of the output stream
is updated according to the number of bytes written.byteArray
- the array of bytes to be written.BufferOverflowException
- if there is not enough space left in the output stream.IllegalStateException
- if releasedNullPointerException
- if the provided byteArray
is null
.@NotNull S write(byte[] byteArray, int offset, int length) throws BufferOverflowException, IllegalStateException, IllegalArgumentException, ArrayIndexOutOfBoundsException
byteArray
into the output stream, starting from the
given offset. The position of the output stream is updated according to the number of bytes written.byteArray
- the array of bytes to be written.offset
- the start index in the array from where to start writing bytes.length
- the number of bytes to write.BufferOverflowException
- if there is not enough space left in the output stream.IllegalStateException
- if releasedIllegalArgumentException
- if the provided offset
or length
is negativeNullPointerException
- if the provided byteArray
is null
ArrayIndexOutOfBoundsException
- if the provided offset
and length
combination is invalid.default S unsafeWriteObject(Object o, int length) throws BufferOverflowException, IllegalStateException
o
- The object whose memory content is to be written.length
- The length (in bytes) of the object's content to write.BufferOverflowException
- if there is not enough space left in the output stream.IllegalStateException
- if the buffer is in an invalid state.default S unsafeWriteObject(Object o, int offset, int length) throws BufferOverflowException, IllegalStateException
o
- The object whose memory content is to be written.offset
- The offset in bytes from the start of the object's content to begin writing from.length
- The length (in bytes) of the object's content to write.BufferOverflowException
- if there is not enough space left in the output stream.IllegalStateException
- if the buffer is in an invalid state.default S unsafeWrite(long address, int length)
address
- The address of the raw memory to write.length
- The length (in bytes) of the raw memory to write.BufferOverflowException
- if there is not enough space left in the output stream.IllegalStateException
- if the buffer is in an invalid state.@NotNull S writeSome(@NotNull @NotNull ByteBuffer buffer) throws BufferOverflowException, IllegalStateException, BufferUnderflowException
ByteBuffer
into this Bytes object.
The number of bytes written is constrained by the space available in this Bytes object.
The position of this Bytes object is updated according to the number of bytes written.buffer
- the ByteBuffer from which data is read.BufferOverflowException
- if there is not enough space left in the output stream.IllegalStateException
- if the buffer is in an invalid state.BufferUnderflowException
- if there is not enough data available in the input ByteBuffer.NullPointerException
- if the provided buffer
is null
.@NotNull default S writeBoolean(boolean flag) throws BufferOverflowException, IllegalStateException
flag
- The boolean value to be written.BufferOverflowException
- if there is not enough space left in the output stream.IllegalStateException
- if the buffer is in an invalid state.@NotNull S writeOrderedInt(int i) throws BufferOverflowException, IllegalStateException
i
- The integer value to be written.BufferOverflowException
- if there is not enough space left in the output stream.IllegalStateException
- if the buffer is in an invalid state.@NotNull S writeOrderedLong(long i) throws BufferOverflowException, IllegalStateException
i
- The long value to be written.BufferOverflowException
- if there is not enough space left in the output stream.IllegalStateException
- if the buffer is in an invalid state.default <E extends Enum<E>> S writeEnum(@NotNull E e) throws BufferOverflowException, ArithmeticException, IllegalStateException
e
- The enum value to be written.BufferOverflowException
- if there is not enough space left in the output stream.ArithmeticException
- if a numeric error occurs.IllegalStateException
- if the buffer is in an invalid state.@NotNull default S appendUtf8(@NotNull @NotNull CharSequence cs) throws BufferOverflowException, IllegalStateException, BufferUnderflowException
cs
- The CharSequence to be appended.BufferOverflowException
- if there is not enough space left in the output stream.IllegalStateException
- if the buffer is in an invalid state.BufferUnderflowException
- if there is not enough data available in the input CharSequence.@NotNull default S appendUtf8(int codepoint) throws BufferOverflowException, IllegalStateException
codepoint
- The Unicode code point of the character to be appended.BufferOverflowException
- if there is not enough space left in the output stream.IllegalStateException
- if the buffer is in an invalid state.@NotNull default S appendUtf8(char[] chars, int offset, int length) throws BufferOverflowException, IllegalStateException, BufferUnderflowException, IllegalArgumentException
chars
- The CharSequence to be appended.offset
- The offset from which to start writing the CharSequence.length
- The number of characters from the CharSequence to write.BufferOverflowException
- if there is not enough space left in the output stream.IndexOutOfBoundsException
- if the offset or length is out of bounds for the given CharSequence.IllegalStateException
- if the buffer is in an invalid state.BufferUnderflowException
- if there is not enough data available in the input CharSequence.IllegalArgumentException
@NotNull default S appendUtf8(@NotNull @NotNull CharSequence cs, int offset, int length) throws BufferOverflowException, IndexOutOfBoundsException, IllegalStateException, BufferUnderflowException
cs
- The CharSequence to be appended.offset
- The offset from which to start writing the CharSequence.length
- The number of characters from the CharSequence to write.BufferOverflowException
- if there is not enough space left in the output stream.IndexOutOfBoundsException
- if the offset or length is out of bounds for the given CharSequence.IllegalStateException
- if the buffer is in an invalid state.BufferUnderflowException
- if there is not enough data available in the input CharSequence.@NotNull default S appendUtf8(byte[] bytes, int offset, int length, byte coder) throws BufferOverflowException, IllegalStateException
bytes
- The byte array to be appended.offset
- The offset from which to start writing the byte array.length
- The number of characters (not bytes) from the byte array to write.coder
- The coder indicating the encoding of the byte array.BufferOverflowException
- if there is not enough space left in the output stream.IllegalStateException
- if the buffer is in an invalid state.@NotNull default S appendUtf8(byte[] bytes, int offset, int length) throws BufferOverflowException, IllegalStateException
bytes
- The byte array to be appended.offset
- The offset from which to start writing the byte array.length
- The length of the byte array to write.BufferOverflowException
- if there is not enough space left in the output stream.IllegalStateException
- if the buffer is in an invalid state.default void copyFrom(@NotNull @NotNull InputStream input) throws IOException, BufferOverflowException, IllegalStateException
input
- The InputStream from which data should be copied.IOException
- if an I/O error occurs when reading from the InputStream.BufferOverflowException
- if there is not enough space in this Bytes object to store the incoming data.IllegalStateException
- if this Bytes object is in an invalid state.default void writePositionRemaining(long position, long length) throws BufferOverflowException
position
- The new write position.length
- The new length of writable bytes remaining.BufferOverflowException
- if the provided position and length exceeds the size of the buffer.default void writeHistogram(@NotNull @NotNull net.openhft.chronicle.core.util.Histogram histogram) throws BufferOverflowException, IllegalStateException
histogram
- The Histogram object to be written.BufferOverflowException
- if there is not enough space in this Bytes object to store the Histogram.IllegalStateException
- if this Bytes object is in an invalid state.default void writeBigDecimal(@NotNull @NotNull BigDecimal bd) throws BufferOverflowException, IllegalStateException, IllegalArgumentException
bd
- The BigDecimal object to be written.BufferOverflowException
- if there is not enough space in this Bytes object to store the BigDecimal.IllegalStateException
- if this Bytes object is in an invalid state.IllegalArgumentException
- if the BigDecimal cannot be written.default void writeBigInteger(@NotNull @NotNull BigInteger bi) throws BufferOverflowException, IllegalStateException, IllegalArgumentException
bi
- The BigInteger object to be written.BufferOverflowException
- if there is not enough space in this Bytes object to store the BigInteger.IllegalStateException
- if this Bytes object is in an invalid state.IllegalArgumentException
- if the BigInteger cannot be written.default void writeWithLength(@NotNull @NotNull RandomDataInput bytes) throws BufferOverflowException, IllegalStateException
bytes
- The RandomDataInput source of data to be written.BufferOverflowException
- if there is not enough space in this Bytes object to store the incoming data.IllegalStateException
- if this Bytes object is in an invalid state.@Deprecated byte[] internalNumberBuffer()
default long start()
default long capacity()
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, IllegalStateException
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()IllegalStateException
- if the buffer has been closed.default long addressForRead(long offset, int buffer) throws UnsupportedOperationException, BufferUnderflowException, IllegalStateException
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.IllegalStateException
- if the buffer has been closed.long addressForWrite(long offset) throws UnsupportedOperationException, BufferOverflowException, IllegalStateException
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()IllegalStateException
long addressForWritePosition() throws UnsupportedOperationException, BufferOverflowException, IllegalStateException
UnsupportedOperationException
- if the underlying buffer is on the heap.BufferOverflowException
- if the current write position is before the start or after the capacity.IllegalStateException
- if the buffer state doesn't allow the operation.default ByteOrder byteOrder()
@NotNull @NotNull Bytes<?> bytesForRead() throws IllegalStateException
IllegalStateException
- if the buffer state doesn't allow the operation.@NotNull @NotNull Bytes<?> bytesForWrite() throws IllegalStateException
IllegalStateException
- if the buffer state doesn't allow the operation.boolean sharedMemory()
boolean isDirectMemory()
Copyright © 2023. All rights reserved.