U
- Underlying typepublic abstract class AbstractBytes<U> extends net.openhft.chronicle.core.io.AbstractReferenceCounted implements Bytes<U>, HasUncheckedRandomDataInput, DecimalAppender
Modifier and Type | Field and Description |
---|---|
protected @NotNull BytesStore<Bytes<U>,U> |
bytesStore |
protected static boolean |
DISABLE_THREAD_SAFETY
Deprecated.
|
protected boolean |
isPresent |
protected long |
readPosition |
protected long |
writeLimit |
referenceCounted, WARN_COUNT, WARN_NS
DEFAULT_BYTE_BUFFER_CAPACITY, MAX_CAPACITY, MAX_HEAP_CAPACITY
charToString
JAVA9_STRING_CODER_LATIN, JAVA9_STRING_CODER_UTF16
Modifier and Type | Method and Description |
---|---|
@NotNull UncheckedRandomDataInput |
acquireUncheckedInput()
Returns a view of a memory segment providing memory read operations with potentially unchecked
memory boundaries.
|
long |
addressForRead(long offset)
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.
|
void |
append(boolean negative,
long mantissa,
int exponent)
Appends a numeric value in decimal form with the specified mantissa and exponent,
handling negative values and decimal point placement.
|
@NotNull AbstractBytes<U> |
append(double d)
Appends the string representation of the given double value to the bytes.
|
@NotNull Bytes<U> |
append(double d,
int decimalPlaces)
Appends a double in decimal notation to a specific number of decimal places.
|
@NotNull Bytes<U> |
append(float f)
Appends the string representation of the given float value to the bytes.
|
@NotNull Bytes<U> |
append(int value)
Appends an int in decimal to this.
|
@NotNull Bytes<U> |
append(long value)
Appends a long value in decimal.
|
long |
appendAndReturnLength(long writePosition,
boolean negative,
long mantissa,
int exponent,
boolean append0) |
int |
byteCheckSum()
Returns the bytes sum of the readable bytes in this BytesStore.
|
int |
byteCheckSum(int start,
int end)
Returns the bytes sum between the specified indexes; start (inclusive) and end (exclusive).
|
int |
byteCheckSum(long start,
long end)
Returns the bytes sum between the specified indexes; start (inclusive) and end (exclusive).
|
@NotNull BytesStore |
bytesStore()
Returns the backing BytesStore that this Bytes object wraps.
|
protected void |
bytesStore(BytesStore<Bytes<U>,U> bytesStore) |
boolean |
canReadDirect(long length)
Checks if the specified length of bytes can be read directly from native memory.
|
boolean |
canWriteDirect(long count)
Determines if the buffer can write the specified count of bytes directly.
|
long |
capacity()
Provides the maximum limit that can be set for the ByteStore.
|
@NotNull Bytes<U> |
clear()
Clears the content of this Bytes object and resets its state.
|
@NotNull Bytes<U> |
clearAndPad(long length)
Clears the buffer and pads it with a specified length to allow prepending later.
|
@NotNull Bytes<U> |
compact()
Compacts this Bytes object by moving the read position to the start.
|
boolean |
compareAndSwapInt(long offset,
int expected,
int value)
Perform a 32-bit CAS at a given offset.
|
boolean |
compareAndSwapLong(long offset,
long expected,
long value)
Perform a 64-bit CAS at a given offset.
|
BytesStore<Bytes<U>,U> |
copy()
Creates and returns a deep copy of this Bytes object, including the data between
RandomCommon.readPosition() and RandomCommon.readLimit() . |
int |
copyTo(byte[] bytes)
Copies data from this byte source into a byte array.
|
Decimaliser |
decimaliser()
Gets the Decimaliser currently associated with this ByteStringAppender.
|
Bytes<U> |
decimaliser(Decimaliser decimaliser)
Associates a Decimaliser with this ByteStringAppender.
|
boolean |
equals(Object obj) |
boolean |
fpAppend0() |
Bytes<U> |
fpAppend0(boolean append0) |
int |
hashCode() |
byte[] |
internalNumberBuffer()
Deprecated.
|
boolean |
isDirectMemory()
Checks if this BytesStore uses direct memory.
|
boolean |
isElastic()
Checks if this Bytes object is elastic, meaning it can dynamically resize when more data is written
than its current
Bytes.realCapacity() . |
boolean |
isImmutableEmptyByteStore()
Returns if this ByteStore is an immutable empty ByteStore or if it is backed
by an immutable empty ByteStore.
|
int |
lastDecimalPlaces()
Returns the number of decimal places in the last parsed floating-point number
(from the
ByteStringParser.parseDouble() or ByteStringParser.parseLongDecimal() methods). |
void |
lastDecimalPlaces(int lastDecimalPlaces)
Sets the number of decimal places in the last parsed number.
|
boolean |
lastNumberHadDigits()
Returns whether the last parsed number had any digits.
|
void |
lastNumberHadDigits(boolean lastNumberHadDigits)
Sets whether the last parsed number had any digits.
|
int |
length()
This method is inherited from CharSequence so result should be the length of the contained
chars sequence although it actually returns the number of underlying bytes.
|
boolean |
lenient() |
void |
lenient(boolean lenient)
When there is no more data to read, return zero,
false and empty string. |
void |
move(long from,
long to,
long length)
Moves a sequence of bytes within this BytesStore from the source to destination index.
|
void |
nativeRead(long position,
long address,
long size)
Expert-level method for transferring data from this byte source to native memory.
|
void |
nativeWrite(long address,
long position,
long size)
Expert-level method that copies data directly from native memory into this BytesStore.
|
int |
peekUnsignedByte()
Peeks (reads without moving the read pointer) the next unsigned byte from the input stream.
|
int |
peekUnsignedByte(long offset)
Reads an unsigned byte value from a specific offset.
|
protected void |
performRelease() |
@NotNull Bytes<U> |
prewrite(byte[] bytes)
Writes a byte array backward in binary format.
|
@NotNull Bytes<U> |
prewrite(@NotNull BytesStore bytes)
Writes a BytesStore instance backward in binary format.
|
@NotNull Bytes<U> |
prewriteByte(byte i8)
Writes a byte backward in binary format.
|
@NotNull Bytes<U> |
prewriteInt(int i)
Writes an int (4-byte int) backward in binary format.
|
@NotNull Bytes<U> |
prewriteLong(long l)
Writes a long (8-byte int) backward in binary format.
|
protected long |
prewriteOffsetPositionMoved(long subtracting) |
@NotNull Bytes<U> |
prewriteShort(short i)
Writes a short (2-byte int) backward in binary format.
|
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.
|
long |
read(long offsetInRDI,
byte[] bytes,
int offset,
int length)
Reads a sequence of bytes from the specified offset into a byte array.
|
byte |
readByte()
Reads a byte value from the input stream.
|
byte |
readByte(long offset)
Reads a byte value from a specific offset.
|
protected void |
readCheckOffset(long offset,
long adding,
boolean given) |
double |
readDouble()
Reads a 64-bit floating-point number from the input stream.
|
double |
readDouble(long offset)
Reads a 64-bit floating point value from a specified offset.
|
float |
readFloat()
Reads a 32-bit floating-point number from the input stream.
|
float |
readFloat(long offset)
Reads a 32-bit floating point value from a specified offset.
|
int |
readInt()
Reads a 32-bit integer value from the input stream.
|
int |
readInt(long offset)
Reads a 32-bit integer value from a specific offset.
|
long |
readLimit()
If the resource is closed, the returned value is unspecified.
|
@NotNull Bytes<U> |
readLimit(long limit)
Sets the read limit of this StreamingDataInput.
|
long |
readLong()
Reads a 64-bit long value from the input stream.
|
long |
readLong(long offset)
Reads a 64-bit long value from a specific offset.
|
protected long |
readOffsetPositionMoved(long adding) |
long |
readPosition()
Returns the read position.
|
@NotNull Bytes<U> |
readPosition(long position)
Sets the read position of this StreamingDataInput.
|
long |
readPositionForHeader(boolean skipPadding)
Obtains the current read position, optionally skipping padding bytes if specified.
|
short |
readShort()
Reads a 16-bit short value from the input stream.
|
short |
readShort(long offset)
Reads a short value from a specific offset.
|
@NotNull Bytes<U> |
readSkip(long bytesToSkip)
Skips the specified number of bytes by advancing the read position.
|
int |
readUnsignedByte()
Reads the next unsigned 8-bit value from the input stream.
|
int |
readUnsignedByte(long offset)
Reads an unsigned byte value from a specific offset.
|
byte |
readVolatileByte(long offset)
Reads a volatile 8-bit byte value from a specified offset.
|
int |
readVolatileInt()
Reads a volatile (concurrently mutable) integer value from the input stream.
|
int |
readVolatileInt(long offset)
Reads a volatile 32-bit integer value from a specified offset.
|
long |
readVolatileLong()
Reads a volatile (concurrently mutable) long value from the input stream.
|
long |
readVolatileLong(long offset)
Reads a volatile 64-bit long value from a specified offset.
|
short |
readVolatileShort(long offset)
Reads a volatile 16-bit short value from a specified offset.
|
long |
realCapacity()
Returns the actual capacity of the ByteStore before any resizing occurs.
|
protected int |
safeCopySize() |
long |
start() |
boolean |
startsWith(@Nullable BytesStore bytesStore)
Returns if the content of this BytesStore starts with bytes equal to the content of a specified BytesStore.
|
void |
testAndSetInt(long offset,
int expected,
int value)
Tests if the current value at the specified offset equals the expected value and, if so, sets it to the provided value.
|
@NotNull String |
toString() |
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.
|
protected void |
uncheckedWritePosition(long writePosition) |
U |
underlyingObject() |
@NotNull Bytes<U> |
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. |
Bytes<U> |
write(@NotNull BytesStore<?,?> bytes)
Writes all available data from the specified
BytesStore into the output stream. |
@NotNull Bytes<U> |
write(long offsetInRDO,
byte[] byteArray,
int offset,
int length)
Copies the provided
byteArray to this Bytes object starting at writeOffset taking
content starting at readOffset but copying at most length bytes. |
void |
write(long offsetInRDO,
@NotNull ByteBuffer bytes,
int offset,
int length)
Copies a segment from the provided ByteBuffer into this data output.
|
@NotNull Bytes<U> |
write(long writeOffset,
@NotNull RandomDataInput bytes,
long readOffset,
long length)
Copies a segment from the provided RandomDataInput into this data output.
|
@NotNull Bytes<U> |
write(@NotNull RandomDataInput bytes)
Writes all available data from the specified
RandomDataInput into the output stream. |
@NotNull Bytes<U> |
write8bit(@Nullable BytesStore bs) |
long |
write8bit(long position,
@NotNull BytesStore bs)
Writes a BytesStore instance to this RandomDataOutput at the given position.
|
long |
write8bit(long position,
@NotNull String s,
int start,
int length)
Writes a portion of a string to this RandomDataOutput at the given position.
|
@NotNull Bytes<U> |
write8bit(@NotNull String text,
int start,
int length)
Writes a subsequence of a String as an 8-bit string to the data stream.
|
@NotNull Bytes<U> |
writeBoolean(boolean flag)
Writes a boolean value to this output stream.
|
@NotNull Bytes<U> |
writeByte(byte i8)
Writes a byte to the data stream.
|
@NotNull Bytes<U> |
writeByte(long offset,
byte i)
Writes a byte at the specified non-negative offset.
|
protected void |
writeCheckOffset(long offset,
long adding) |
@NotNull Bytes<U> |
writeDouble(double d)
Writes a double-precision floating-point number to the data stream.
|
@NotNull Bytes<U> |
writeDouble(long offset,
double d)
Writes a double-precision floating-point value at the specified non-negative offset.
|
@NotNull Bytes<U> |
writeDoubleAndInt(double d,
int i)
Writes a double-precision floating-point number followed by an integer to the data stream.
|
@NotNull Bytes<U> |
writeFloat(float f)
Writes a floating-point number to the data stream.
|
@NotNull Bytes<U> |
writeFloat(long offset,
float d)
Writes a single-precision floating-point value at the specified non-negative offset.
|
@NotNull Bytes<U> |
writeInt(int i)
Writes an integer to the data stream.
|
@NotNull Bytes<U> |
writeInt(long offset,
int i)
Writes an integer value at the specified non-negative offset.
|
@NotNull Bytes<U> |
writeIntAdv(int i,
int advance)
Writes an integer to the data stream, then advances the write position by the specified amount.
|
long |
writeLimit()
Retrieves the maximum writable position within the buffer.
|
@NotNull Bytes<U> |
writeLimit(long limit)
Sets the limit for writing to the data stream.
|
@NotNull Bytes<U> |
writeLong(long i64)
Writes a long integer to the data stream.
|
@NotNull Bytes<U> |
writeLong(long offset,
long i)
Writes a long integer value at the specified non-negative offset.
|
@NotNull Bytes<U> |
writeLongAdv(long i64,
int advance)
Writes a long integer to the data stream, then advances the write position by the specified amount.
|
protected long |
writeOffsetPositionMoved(long adding) |
protected long |
writeOffsetPositionMoved(long adding,
long advance) |
@NotNull Bytes<U> |
writeOrderedInt(int i)
Writes an integer value to this output stream using an ordered-writing mechanism.
|
@NotNull Bytes<U> |
writeOrderedInt(long offset,
int i)
Performs a non-blocking write operation with a memory barrier to ensure order of stores.
|
@NotNull Bytes<U> |
writeOrderedLong(long i)
Writes a long value to this output stream using an ordered-writing mechanism.
|
@NotNull Bytes<U> |
writeOrderedLong(long offset,
long i)
Performs a non-blocking write operation with a memory barrier to ensure order of stores.
|
long |
writePosition()
Returns the write position.
|
@NotNull Bytes<U> |
writePosition(long position)
Sets the current write position in the data stream.
|
@NotNull Bytes<U> |
writeShort(long offset,
short i)
Writes a short integer at the specified non-negative offset.
|
@NotNull Bytes<U> |
writeShort(short i16)
Writes a short integer to the data stream.
|
@NotNull Bytes<U> |
writeSkip(long bytesToSkip)
Skips a specified number of bytes from the current write position in the data stream.
|
@NotNull Bytes<U> |
writeSome(@NotNull ByteBuffer buffer)
Writes the available data from the provided
ByteBuffer into this Bytes object. |
@NotNull Bytes<U> |
writeVolatileByte(long offset,
byte i8)
Writes a volatile byte at the specified non-negative offset.
|
@NotNull Bytes<U> |
writeVolatileInt(long offset,
int i32)
Writes a volatile integer at the specified non-negative offset.
|
@NotNull Bytes<U> |
writeVolatileLong(long offset,
long i64)
Writes a volatile long integer at the specified non-negative offset.
|
@NotNull Bytes<U> |
writeVolatileShort(long offset,
short i16)
Writes a volatile short at the specified non-negative offset.
|
addReferenceChangeListener, assertReferencesReleased, backgroundPerformRelease, canReleaseInBackground, clearUsedByThread, createdHere, disableReferenceTracing, enableReferenceTracing, refCount, referenceCountedUnmonitored, referenceId, release, releaseLast, removeReferenceChangeListener, reserve, reservedBy, reserveTransfer, singleThreadedCheckDisabled, singleThreadedCheckReset, threadSafetyCheck, throwExceptionIfNotReleased, throwExceptionIfReleased, tryReserve, unmonitor, warnAndReleaseIfNotReleased
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
allocateDirect, allocateDirect, allocateElasticDirect, allocateElasticDirect, allocateElasticOnHeap, allocateElasticOnHeap, bytesForRead, bytesForWrite, copyTo, copyTo, directFrom, elasticByteBuffer, elasticByteBuffer, elasticByteBuffer, elasticHeapByteBuffer, elasticHeapByteBuffer, empty, ensureCapacity, forFieldGroup, from, from, fromDirect, fromHexString, indexOf, indexOf, isClear, isEqual, readMarshallableLength16, readWithLength, readWrite, safeLimit, sharedMemory, toHexString, toHexString, toHexString, toString, toString, toString, unchecked, unchecked, unwrite, valueOf, wrapForRead, wrapForRead, wrapForWrite, wrapForWrite, write, writeMarshallableLength16
addAndGetDouble, addAndGetDoubleNotAtomic, addAndGetFloat, addAndGetFloatNotAtomic, addAndGetInt, addAndGetIntNotAtomic, addAndGetLong, addAndGetShortNotAtomic, addAndGetUnsignedByteNotAtomic, charAt, cipher, cipher, compareAndSwapDouble, compareAndSwapFloat, contentEquals, elasticByteBuffer, endsWith, equalBytes, follow, forFields, from, hash, inside, inside, isEmpty, isEqual, lazyNativeBytesStoreWithFixedCapacity, nativePointer, nativeStore, nativeStoreFrom, nativeStoreWithFixedCapacity, startsWith, subSequence, to8bitString, toDebugString, toDebugString, wrap, wrap, wrap, writeMaxInt, writeMaxLong, zeroOut
append, append, write, write, writeBoolean, writeByte, writeInt24, writeOrderedDouble, writeOrderedFloat, writeUnsignedByte, writeUnsignedInt, writeUnsignedShort, writeUtf8, writeUtf8Limited, writeVolatileDouble, writeVolatileFloat
chars, codePoints
bytesMethodReader, bytesMethodReaderBuilder, readObject
canReadDirect, compareUtf8, copyTo, createCharToString, fastHash, findByte, parseLong, peekVolatileInt, printable, readBoolean, readIncompleteLong, readUnsignedInt, readUnsignedInt24, readUnsignedShort, readUtf8, readUtf8Limited, readUtf8Limited, readVolatileDouble, readVolatileFloat, subBytes, toByteArray, toTemporaryDirectByteBuffer
parse8bit, parse8bit, parse8bit, parse8bit, parse8bit, parseBigDecimal, parseBoolean, parseBoolean, parseDouble, parseFlexibleLong, parseFloat, parseInt, parseLong, parseLongDecimal, parseUtf8, parseUtf8, parseUtf8, reader, skipTo
inputStream, parseHexLong, parseUtf8, parseUtf8, rawReadByte, rawReadInt, rawReadLong, read, read, read, read, read, read8bit, read8bit, read8bit, readBigDecimal, readBigInteger, readBoolean, readChar, readEnum, readHistogram, readIncompleteLong, readInt24, readLimitToCapacity, readPositionRemaining, readPositionUnlimited, readStopBit, readStopBitChar, readStopBitDecimal, readStopBitDouble, readUnsignedInt, readUnsignedInt24, readUnsignedShort, readUtf8, readUtf8, readUtf8, readUtf8, readWithLength, readWithLength, readWithLength0, unsafeRead, unsafeReadObject, unsafeReadObject
bytesMethodWriter, writeObject
append, append, append, append, append, append8bit, append8bit, append8bit, append8bit, append8bit, appendBase, appendBase16, appendBase16, appendDateMillis, appendDecimal, appendTimeMillis, writer
appendUtf8, appendUtf8, appendUtf8, appendUtf8, appendUtf8, appendUtf8, copyFrom, outputStream, rawWriteByte, rawWriteInt, rawWriteLong, unsafeWrite, unsafeWriteObject, unsafeWriteObject, write, write, write, write, write, write8bit, write8bit, write8bit, writeBigDecimal, writeBigInteger, writeChar, writeEnum, writeHistogram, writeInt24, writePositionForHeader, writePositionRemaining, writeSome, writeStopBit, writeStopBit, writeStopBit, writeStopBitDecimal, writeUnsignedByte, writeUnsignedInt, writeUnsignedInt24, writeUnsignedShort, writeUtf8, writeUtf8, writeWithLength
prepend
adjustHexDumpIndentation, retainedHexDumpDescription, writeHexDumpDescription
@Deprecated protected static final boolean DISABLE_THREAD_SAFETY
@NotNull protected @NotNull BytesStore<Bytes<U>,U> bytesStore
protected long readPosition
protected long writeLimit
protected boolean isPresent
public boolean isDirectMemory()
BytesStore
isDirectMemory
in interface BytesStore<Bytes<U>,U>
public boolean canReadDirect(long length)
RandomDataInput
canReadDirect
in interface RandomDataInput
length
- the number of bytes to check.public void move(long from, long to, long length) throws BufferUnderflowException, IllegalStateException, ArithmeticException
BytesStore
move
in interface BytesStore<Bytes<U>,U>
from
- the index of the first byte to be movedto
- the index where the first byte should be moved tolength
- the number of bytes to be movedBufferUnderflowException
- if there's not enough data to be movedIllegalStateException
- if the BytesStore is in an unusable stateArithmeticException
- if the move would result in an index overflow@NotNull public @NotNull Bytes<U> compact() throws IllegalStateException
Bytes
This operation is useful to free up space for writing by discarding bytes that have already been read.
compact
in interface Bytes<U>
IllegalStateException
- if this Bytes object has been previously released.@NotNull public @NotNull Bytes<U> clear() throws IllegalStateException
Bytes
clear
in interface Bytes<U>
clear
in interface StreamingCommon<Bytes<U>>
IllegalStateException
- if this Bytes object has been previously released.@NotNull public @NotNull Bytes<U> clearAndPad(long length) throws BufferOverflowException
BytesPrepender
clearAndPad
in interface BytesPrepender<Bytes<U>>
length
- the padding lengthBufferOverflowException
- if the length is greater than the difference of capacity() and start()public long readLimit()
If the resource is closed, the returned value is unspecified.
public long writeLimit()
If the resource is closed, the returned value is unspecified.
public long realCapacity()
BytesStore
realCapacity
in interface Bytes<U>
realCapacity
in interface BytesStore<Bytes<U>,U>
realCapacity
in interface RandomDataInput
realCapacity
in interface StreamingDataOutput<Bytes<U>>
public boolean canWriteDirect(long count)
StreamingDataOutput
canWriteDirect
in interface StreamingDataOutput<Bytes<U>>
count
- the number of bytes to write.public long capacity()
BytesStore
capacity
in interface BytesStore<Bytes<U>,U>
@Nullable public U underlyingObject()
underlyingObject
in interface BytesStore<Bytes<U>,U>
public int length()
BytesStore
length
in interface CharSequence
length
in interface BytesStore<Bytes<U>,U>
public long start()
public long readPosition()
The read position is start() <= readPosition() && readPosition() <= readLimit() && readPosition < safeLimit()
If the resource is closed, the returned value is unspecified.
public long writePosition()
The write position is readPosition() <= writePosition() && writePosition() <= writeLimit()
If the resource is closed, the returned value is unspecified.
public boolean compareAndSwapInt(long offset, int expected, int value) throws BufferOverflowException, IllegalStateException
RandomDataInput
compareAndSwapInt
in interface BytesStore<Bytes<U>,U>
compareAndSwapInt
in interface RandomDataInput
compareAndSwapInt
in interface RandomDataOutput<Bytes<U>>
offset
- to perform CASexpected
- valuevalue
- to setBufferOverflowException
- if the capacity of this RandomDataOutput was exceeded.IllegalStateException
- if releasedpublic void testAndSetInt(long offset, int expected, int value) throws BufferOverflowException, IllegalStateException
RandomDataOutput
testAndSetInt
in interface RandomDataInput
testAndSetInt
in interface RandomDataOutput<Bytes<U>>
offset
- the offset at which to perform the test-and-set operation.expected
- the expected current value.value
- the new value to set if the current value matches the expected value.BufferOverflowException
- if the capacity of this RandomDataOutput was exceeded.IllegalStateException
- if this RandomDataOutput has been previously released.public boolean compareAndSwapLong(long offset, long expected, long value) throws BufferOverflowException, IllegalStateException
RandomDataInput
compareAndSwapLong
in interface BytesStore<Bytes<U>,U>
compareAndSwapLong
in interface RandomDataInput
compareAndSwapLong
in interface RandomDataOutput<Bytes<U>>
offset
- to perform CASexpected
- valuevalue
- to setBufferOverflowException
- if the capacity of this RandomDataOutput was exceeded.IllegalStateException
- if released@NotNull public @NotNull AbstractBytes<U> append(double d) throws BufferOverflowException, IllegalStateException
append
in interface ByteStringAppender<Bytes<U>>
d
- the double value to append.BufferOverflowException
- if there is not enough space to write the double.IllegalStateException
- if this buffer is closed.@NotNull public @NotNull Bytes<U> append(float f) throws BufferOverflowException, IllegalStateException
append
in interface ByteStringAppender<Bytes<U>>
f
- the float value to append.BufferOverflowException
- if there is not enough space to write the float.IllegalStateException
- if this buffer is closed.@NotNull public @NotNull Bytes<U> append(int value) throws BufferOverflowException, IllegalArgumentException, IllegalStateException
ByteStringAppender
append
in interface ByteStringAppender<Bytes<U>>
value
- the integer value to appendBufferOverflowException
- if the relative append operation exceeds the underlying buffer's capacityIllegalStateException
- if the underlying buffer was releasedIllegalArgumentException
@NotNull public @NotNull Bytes<U> append(long value) throws BufferOverflowException, IllegalStateException
ByteStringAppender
append
in interface ByteStringAppender<Bytes<U>>
value
- the long number to appendBufferOverflowException
- if the relative append operation exceeds the underlying buffer's capacityIllegalStateException
- if the underlying buffer was releasedpublic Decimaliser decimaliser()
ByteStringAppender
decimaliser
in interface ByteStringAppender<Bytes<U>>
public Bytes<U> decimaliser(Decimaliser decimaliser)
ByteStringAppender
The Decimaliser is an interface which can be implemented to provide custom logic for rendering decimal numbers in this ByteStringAppender.
decimaliser
in interface ByteStringAppender<Bytes<U>>
decimaliser
- The Decimaliser to be associated with this ByteStringAppender.public boolean fpAppend0()
fpAppend0
in interface ByteStringAppender<Bytes<U>>
public Bytes<U> fpAppend0(boolean append0)
fpAppend0
in interface ByteStringAppender<Bytes<U>>
append0
- Does floating point add .0 to indicate it is a floating point even if redundant.public void append(boolean negative, long mantissa, int exponent)
append
in interface DecimalAppender
negative
- indicates if the number is negative.mantissa
- the mantissa of the number to append.exponent
- the exponent indicating the position of the decimal point.public long appendAndReturnLength(long writePosition, boolean negative, long mantissa, int exponent, boolean append0)
appendAndReturnLength
in interface RandomDataOutput<Bytes<U>>
@NotNull public @NotNull Bytes<U> append(double d, int decimalPlaces) throws BufferOverflowException, IllegalArgumentException, IllegalStateException, ArithmeticException
ByteStringAppender
If the number would normally be printed with more decimal places, the number is rounded.
append
in interface ByteStringAppender<Bytes<U>>
d
- to appenddecimalPlaces
- to always produceBufferOverflowException
- if the capacity of the underlying buffer was exceededIllegalArgumentException
- if the decimalPlaces is negative or too largeIllegalStateException
- if the underlying buffer was releasedArithmeticException
@NotNull public @NotNull Bytes<U> readPosition(long position) throws BufferUnderflowException, IllegalStateException
StreamingDataInput
readPosition
in interface StreamingDataInput<Bytes<U>>
position
- the new read position, must be non-negativeBufferUnderflowException
- if the new position is greater than the limitIllegalStateException
- if a required state for this operation is not met@NotNull public @NotNull Bytes<U> readLimit(long limit) throws BufferUnderflowException
StreamingDataInput
readLimit
in interface StreamingDataInput<Bytes<U>>
limit
- the new read limit, must be non-negativeBufferUnderflowException
- if the new limit is less than the read position@NotNull public @NotNull Bytes<U> writePosition(long position) throws BufferOverflowException
StreamingDataOutput
writePosition
in interface StreamingDataOutput<Bytes<U>>
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 public @NotNull Bytes<U> readSkip(long bytesToSkip) throws BufferUnderflowException, IllegalStateException
StreamingDataInput
readSkip
in interface StreamingDataInput<Bytes<U>>
bytesToSkip
- the number of bytes to skipBufferUnderflowException
- if the new read position is outside the limits of the data sourceIllegalStateException
- if a required state for this operation is not metpublic long readPositionForHeader(boolean skipPadding)
StreamingDataInput
readPositionForHeader
in interface StreamingDataInput<Bytes<U>>
skipPadding
- if true, aligns the read position to a 4-byte boundary by skipping padding bytespublic void uncheckedReadSkipOne()
StreamingDataInput
uncheckedReadSkipOne
in interface StreamingDataInput<Bytes<U>>
public void uncheckedReadSkipBackOne()
StreamingDataInput
uncheckedReadSkipBackOne
in interface StreamingDataInput<Bytes<U>>
@NotNull public @NotNull Bytes<U> writeSkip(long bytesToSkip) throws BufferOverflowException, IllegalStateException
StreamingDataOutput
writeSkip
in interface StreamingDataOutput<Bytes<U>>
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 released@NotNull public @NotNull Bytes<U> writeLimit(long limit) throws BufferOverflowException
StreamingDataOutput
writeLimit
in interface StreamingDataOutput<Bytes<U>>
limit
- The new write limit. It must be a non-negative number.BufferOverflowException
- if the specified limit is less than the current write position.protected void performRelease()
performRelease
in class net.openhft.chronicle.core.io.AbstractReferenceCounted
public int readUnsignedByte() throws IllegalStateException
StreamingDataInput
readUnsignedByte
in interface StreamingDataInput<Bytes<U>>
IllegalStateException
- if a required state for this operation is not metpublic int readUnsignedByte(long offset) throws BufferUnderflowException, IllegalStateException
RandomDataInput
readUnsignedByte
in interface RandomDataInput
offset
- the location from where the unsigned byte value is read.BufferUnderflowException
- if the offset is outside the bounds of the byte source.IllegalStateException
- if the byte source has been released.public int uncheckedReadUnsignedByte()
StreamingDataInput
uncheckedReadUnsignedByte
in interface StreamingDataInput<Bytes<U>>
public byte readByte() throws IllegalStateException
StreamingDataInput
readByte
in interface StreamingDataInput<Bytes<U>>
IllegalStateException
- if a required state for this operation is not metpublic int peekUnsignedByte() throws IllegalStateException
StreamingDataInput
peekUnsignedByte
in interface StreamingDataInput<Bytes<U>>
IllegalStateException
- if a required state for this operation is not metpublic short readShort() throws BufferUnderflowException, IllegalStateException
StreamingDataInput
readShort
in interface StreamingDataInput<Bytes<U>>
BufferUnderflowException
- if there's not enough data to readIllegalStateException
- if a required state for this operation is not metpublic int readInt() throws BufferUnderflowException, IllegalStateException
StreamingDataInput
readInt
in interface StreamingDataInput<Bytes<U>>
BufferUnderflowException
- if there's not enough data to readIllegalStateException
- if a required state for this operation is not metpublic byte readVolatileByte(long offset) throws BufferUnderflowException, IllegalStateException
RandomDataInput
readVolatileByte
in interface RandomDataInput
offset
- the location from where the byte value is read.BufferUnderflowException
- if the offset is beyond the limits of the byte source.IllegalStateException
- if the byte source has been released.public short readVolatileShort(long offset) throws BufferUnderflowException, IllegalStateException
RandomDataInput
readVolatileShort
in interface RandomDataInput
offset
- the location from where the short value is read.BufferUnderflowException
- if the offset is beyond the limits of the byte source.IllegalStateException
- if the byte source has been released.public int readVolatileInt(long offset) throws BufferUnderflowException, IllegalStateException
RandomDataInput
readVolatileInt
in interface RandomDataInput
offset
- the location from where the int value is read.BufferUnderflowException
- if the offset is beyond the limits of the byte source.IllegalStateException
- if the byte source has been released.public long readVolatileLong(long offset) throws BufferUnderflowException, IllegalStateException
RandomDataInput
readVolatileLong
in interface RandomDataInput
offset
- the location from where the long value is read.BufferUnderflowException
- if the offset is beyond the limits of the byte source.IllegalStateException
- if the byte source has been released.public long readLong() throws BufferUnderflowException, IllegalStateException
StreamingDataInput
readLong
in interface StreamingDataInput<Bytes<U>>
BufferUnderflowException
- if there's not enough data to readIllegalStateException
- if a required state for this operation is not metpublic float readFloat() throws BufferUnderflowException, IllegalStateException
StreamingDataInput
readFloat
in interface StreamingDataInput<Bytes<U>>
BufferUnderflowException
- if there's not enough data to readIllegalStateException
- if a required state for this operation is not metpublic double readDouble() throws BufferUnderflowException, IllegalStateException
StreamingDataInput
readDouble
in interface StreamingDataInput<Bytes<U>>
BufferUnderflowException
- if there's not enough data to readIllegalStateException
- if a required state for this operation is not metpublic int readVolatileInt() throws BufferUnderflowException, IllegalStateException
StreamingDataInput
readVolatileInt
in interface StreamingDataInput<Bytes<U>>
BufferUnderflowException
- if there's not enough data to readIllegalStateException
- if a required state for this operation is not metpublic long readVolatileLong() throws BufferUnderflowException, IllegalStateException
StreamingDataInput
readVolatileLong
in interface StreamingDataInput<Bytes<U>>
BufferUnderflowException
- if there's not enough data to readIllegalStateException
- if a required state for this operation is not metprotected long readOffsetPositionMoved(long adding) throws BufferUnderflowException, IllegalStateException
@NotNull public @NotNull Bytes<U> writeByte(long offset, byte i) throws BufferOverflowException, IllegalStateException
RandomDataOutput
writeByte
in interface RandomDataOutput<Bytes<U>>
offset
- The non-negative position within the data stream to write the byte to.i
- The byte value to write.BufferOverflowException
- If the specified offset exceeds the available capacity.IllegalStateException
- if released@NotNull public @NotNull Bytes<U> writeShort(long offset, short i) throws BufferOverflowException, IllegalStateException
RandomDataOutput
writeShort
in interface RandomDataOutput<Bytes<U>>
offset
- The non-negative position within the data stream to write the short integer to.i
- The short integer value to write.BufferOverflowException
- If the specified offset exceeds the available capacity.IllegalStateException
- if released@NotNull public @NotNull Bytes<U> writeInt(long offset, int i) throws BufferOverflowException, IllegalStateException
RandomDataOutput
writeInt
in interface RandomDataOutput<Bytes<U>>
offset
- The non-negative position within the data stream to write the integer to.i
- The integer value to write.BufferOverflowException
- If the specified offset exceeds the available capacity.IllegalStateException
- if released@NotNull public @NotNull Bytes<U> writeOrderedInt(long offset, int i) throws BufferOverflowException, IllegalStateException
RandomDataOutput
writeOrderedInt
in interface RandomDataOutput<Bytes<U>>
offset
- The non-negative position within the data stream to write the integer to.i
- The integer value to write.BufferOverflowException
- If the specified offset exceeds the available capacity.IllegalStateException
- if released@NotNull public @NotNull Bytes<U> writeLong(long offset, long i) throws BufferOverflowException, IllegalStateException
RandomDataOutput
writeLong
in interface RandomDataOutput<Bytes<U>>
offset
- The non-negative position within the data stream to write the long integer to.i
- The long integer value to write.BufferOverflowException
- If the specified offset exceeds the available capacity.IllegalStateException
- if released@NotNull public @NotNull Bytes<U> writeOrderedLong(long offset, long i) throws BufferOverflowException, IllegalStateException
RandomDataOutput
writeOrderedLong
in interface RandomDataOutput<Bytes<U>>
offset
- The non-negative position within the data stream to write the long integer to.i
- The long integer value to write.BufferOverflowException
- If the specified offset exceeds the available capacity.IllegalStateException
- if released@NotNull public @NotNull Bytes<U> writeFloat(long offset, float d) throws BufferOverflowException, IllegalStateException
RandomDataOutput
writeFloat
in interface RandomDataOutput<Bytes<U>>
offset
- The non-negative position within the data stream to write the float to.d
- The float value to write.BufferOverflowException
- If the specified offset exceeds the available capacity.IllegalStateException
- if released@NotNull public @NotNull Bytes<U> writeDouble(long offset, double d) throws BufferOverflowException, IllegalStateException
RandomDataOutput
writeDouble
in interface RandomDataOutput<Bytes<U>>
offset
- The non-negative position within the data stream to write the double to.d
- The double value to write.BufferOverflowException
- If the specified offset exceeds the available capacity.IllegalStateException
- if released@NotNull public @NotNull Bytes<U> writeVolatileByte(long offset, byte i8) throws BufferOverflowException, IllegalStateException
RandomDataOutput
writeVolatileByte
in interface RandomDataOutput<Bytes<U>>
offset
- The non-negative position within the data stream to write the byte to.i8
- The byte value to write.BufferOverflowException
- If the specified offset exceeds the available capacity.IllegalStateException
- if released@NotNull public @NotNull Bytes<U> writeVolatileShort(long offset, short i16) throws BufferOverflowException, IllegalStateException
RandomDataOutput
writeVolatileShort
in interface RandomDataOutput<Bytes<U>>
offset
- The non-negative position within the data stream to write the short to.i16
- The short value to write.BufferOverflowException
- If the specified offset exceeds the available capacity.IllegalStateException
- if released@NotNull public @NotNull Bytes<U> writeVolatileInt(long offset, int i32) throws BufferOverflowException, IllegalStateException
RandomDataOutput
writeVolatileInt
in interface RandomDataOutput<Bytes<U>>
offset
- The non-negative position within the data stream to write the integer to.i32
- The integer value to write.BufferOverflowException
- If the specified offset exceeds the available capacity.IllegalStateException
- if released@NotNull public @NotNull Bytes<U> writeVolatileLong(long offset, long i64) throws BufferOverflowException, IllegalStateException
RandomDataOutput
writeVolatileLong
in interface RandomDataOutput<Bytes<U>>
offset
- The non-negative position within the data stream to write the long integer to.i64
- The long integer value to write.BufferOverflowException
- If the specified offset exceeds the available capacity.IllegalStateException
- if released@NotNull public @NotNull Bytes<U> write(@NotNull @NotNull RandomDataInput bytes) throws IllegalStateException, BufferOverflowException
StreamingDataOutput
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.write
in interface StreamingDataOutput<Bytes<U>>
bytes
- the RandomDataInput
from which data is read.IllegalStateException
- if releasedBufferOverflowException
- if there is not enough space left in the output stream.public Bytes<U> write(@NotNull @NotNull BytesStore<?,?> bytes) throws BufferOverflowException, IllegalStateException
StreamingDataOutput
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.write
in interface StreamingDataOutput<Bytes<U>>
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)
@NotNull public @NotNull Bytes<U> write(long offsetInRDO, byte[] byteArray, int offset, int length) throws BufferOverflowException, IllegalStateException
RandomDataOutput
byteArray
to this Bytes object starting at writeOffset
taking
content starting at readOffset
but copying at most length
bytes.
Does not update cursors e.g. writePosition()
write
in interface RandomDataOutput<Bytes<U>>
offsetInRDO
- the non-negative offset within the data output where the segment should be written.byteArray
- the byte array containing the segment to be written.offset
- the non-negative offset within the byte array where the segment begins.length
- the non-negative length of the segment.BufferOverflowException
- if the capacity of this data output was exceeded.IllegalStateException
- if this data output has been previously released.public void write(long offsetInRDO, @NotNull @NotNull ByteBuffer bytes, int offset, int length) throws BufferOverflowException, IllegalStateException
RandomDataOutput
Does not update cursors e.g. writePosition()
write
in interface RandomDataOutput<Bytes<U>>
offsetInRDO
- the non-negative offset within the data output where the segment should be written.bytes
- the ByteBuffer containing the segment to be written.offset
- the non-negative offset within the ByteBuffer where the segment begins.length
- the non-negative length of the segment.BufferOverflowException
- if the capacity of this data output was exceeded.IllegalStateException
- if this data output has been previously released.@NotNull public @NotNull Bytes<U> write(long writeOffset, @NotNull @NotNull RandomDataInput bytes, long readOffset, long length) throws BufferOverflowException, BufferUnderflowException, IllegalStateException
RandomDataOutput
writePosition()
of this output nor the RandomCommon.readPosition()
of the input.write
in interface RandomDataOutput<Bytes<U>>
writeOffset
- the non-negative offset within this data output where the segment should be written.bytes
- the RandomDataInput source containing the segment to be written.readOffset
- the non-negative offset within the source where the segment begins.length
- the non-negative length of the segment.BufferOverflowException
- if the capacity of this data output was exceeded.BufferUnderflowException
- if the source does not have enough data to fill the length.IllegalStateException
- if this data output has been previously released.@NotNull public @NotNull Bytes<U> write8bit(@NotNull @NotNull String text, int start, int length) throws BufferOverflowException, IndexOutOfBoundsException, ArithmeticException, IllegalStateException, BufferUnderflowException
StreamingDataOutput
write8bit
in interface StreamingDataOutput<Bytes<U>>
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.BufferOverflowException
IndexOutOfBoundsException
ArithmeticException
IllegalStateException
BufferUnderflowException
@NotNull public @NotNull Bytes<U> write8bit(@Nullable @Nullable BytesStore bs) throws BufferOverflowException, IllegalStateException, BufferUnderflowException
public long write8bit(long position, @NotNull @NotNull BytesStore bs)
RandomDataOutput
write8bit
in interface RandomDataOutput<Bytes<U>>
position
- the position at which the BytesStore content should be written.bs
- the BytesStore instance to write.public long write8bit(long position, @NotNull @NotNull String s, int start, int length)
RandomDataOutput
write8bit
in interface RandomDataOutput<Bytes<U>>
position
- the position at which the string should be written.s
- the string to write.start
- the starting index from where characters are to be taken from the string.length
- the number of characters to be written from the string.protected void writeCheckOffset(long offset, long adding) throws BufferOverflowException, IllegalStateException
public byte readByte(long offset) throws BufferUnderflowException, IllegalStateException
RandomDataInput
readByte
in interface RandomDataInput
offset
- the location from where the byte value is read.BufferUnderflowException
- if the offset is outside the bounds of the byte source.IllegalStateException
- if the byte source has been released.public int peekUnsignedByte(long offset) throws IllegalStateException
RandomDataInput
peekUnsignedByte
in interface RandomDataInput
offset
- the location from where the unsigned byte value is read.IllegalStateException
- if the byte source has been released.public short readShort(long offset) throws BufferUnderflowException, IllegalStateException
RandomDataInput
readShort
in interface RandomDataInput
offset
- the location from where the short value is read.BufferUnderflowException
- if the offset is outside the bounds of the byte source.IllegalStateException
- if the byte source has been released.public int readInt(long offset) throws BufferUnderflowException, IllegalStateException
RandomDataInput
readInt
in interface RandomDataInput
offset
- the location from where the 32-bit integer value is read.BufferUnderflowException
- if the offset is outside the bounds of the byte source.IllegalStateException
- if the byte source has been released.public long readLong(long offset) throws BufferUnderflowException, IllegalStateException
RandomDataInput
readLong
in interface RandomDataInput
offset
- the location from where the long value is read.BufferUnderflowException
- if the offset is outside the bounds of the byte source.IllegalStateException
- if the byte source has been released.public float readFloat(long offset) throws BufferUnderflowException, IllegalStateException
RandomDataInput
readFloat
in interface RandomDataInput
offset
- the location from where the float value is read.BufferUnderflowException
- if the offset is beyond the limits of the byte source.IllegalStateException
- if the byte source has been released.public double readDouble(long offset) throws BufferUnderflowException, IllegalStateException
RandomDataInput
readDouble
in interface RandomDataInput
offset
- the location from where the double value is read.BufferUnderflowException
- if the offset is beyond the limits of the byte source.IllegalStateException
- if the byte source has been released.protected void readCheckOffset(long offset, long adding, boolean given) throws BufferUnderflowException, IllegalStateException
@NotNull public @NotNull Bytes<U> writeByte(byte i8) throws BufferOverflowException, IllegalStateException
StreamingDataOutput
writeByte
in interface StreamingDataOutput<Bytes<U>>
i8
- The byte to be written.BufferOverflowException
- if there is insufficient space in the buffer.IllegalStateException
- if released@NotNull public @NotNull Bytes<U> prewrite(byte[] bytes) throws BufferOverflowException, IllegalStateException
BytesPrepender
prewrite
in interface BytesPrepender<Bytes<U>>
bytes
- the byte array to prependBufferOverflowException
- if the capacity of the underlying buffer was exceededIllegalStateException
- if the buffer is in an invalid state@NotNull public @NotNull Bytes<U> prewrite(@NotNull @NotNull BytesStore bytes) throws BufferOverflowException, IllegalStateException
BytesPrepender
prewrite
in interface BytesPrepender<Bytes<U>>
bytes
- the BytesStore to prependBufferOverflowException
- if the capacity of the underlying buffer was exceededIllegalStateException
- if the buffer is in an invalid state@NotNull public @NotNull Bytes<U> prewriteByte(byte i8) throws BufferOverflowException, IllegalStateException
BytesPrepender
prewriteByte
in interface BytesPrepender<Bytes<U>>
i8
- the byte to prependBufferOverflowException
- if the capacity of the underlying buffer was exceededIllegalStateException
- if the buffer is in an invalid state@NotNull public @NotNull Bytes<U> prewriteInt(int i) throws BufferOverflowException, IllegalStateException
BytesPrepender
prewriteInt
in interface BytesPrepender<Bytes<U>>
i
- the int to prependBufferOverflowException
- if the capacity of the underlying buffer was exceededIllegalStateException
- if the buffer is in an invalid state@NotNull public @NotNull Bytes<U> prewriteShort(short i) throws BufferOverflowException, IllegalStateException
BytesPrepender
prewriteShort
in interface BytesPrepender<Bytes<U>>
i
- the short to prependBufferOverflowException
- if the capacity of the underlying buffer was exceededIllegalStateException
- if the buffer is in an invalid state@NotNull public @NotNull Bytes<U> prewriteLong(long l) throws BufferOverflowException, IllegalStateException
BytesPrepender
prewriteLong
in interface BytesPrepender<Bytes<U>>
l
- the long to prependBufferOverflowException
- if the capacity of the underlying buffer was exceededIllegalStateException
- if the buffer is in an invalid stateprotected final long writeOffsetPositionMoved(long adding) throws BufferOverflowException, IllegalStateException
protected long writeOffsetPositionMoved(long adding, long advance) throws BufferOverflowException, IllegalStateException
protected void uncheckedWritePosition(long writePosition)
protected long prewriteOffsetPositionMoved(long subtracting) throws BufferOverflowException, IllegalStateException
@NotNull public @NotNull Bytes<U> writeShort(short i16) throws BufferOverflowException, IllegalStateException
StreamingDataOutput
writeShort
in interface StreamingDataOutput<Bytes<U>>
i16
- The short integer to be written.BufferOverflowException
- if there is insufficient space in the buffer.IllegalStateException
- if released@NotNull public @NotNull Bytes<U> writeInt(int i) throws BufferOverflowException, IllegalStateException
StreamingDataOutput
writeInt
in interface StreamingDataOutput<Bytes<U>>
i
- The integer to be written.BufferOverflowException
- if there is insufficient space in the buffer.IllegalStateException
- if released@NotNull public @NotNull Bytes<U> writeIntAdv(int i, int advance) throws BufferOverflowException, IllegalStateException
StreamingDataOutput
writeIntAdv
in interface StreamingDataOutput<Bytes<U>>
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 public @NotNull Bytes<U> writeLong(long i64) throws BufferOverflowException, IllegalStateException
StreamingDataOutput
writeLong
in interface StreamingDataOutput<Bytes<U>>
i64
- The long integer to be written.BufferOverflowException
- if there is insufficient space in the buffer.IllegalStateException
- if released@NotNull public @NotNull Bytes<U> writeLongAdv(long i64, int advance) throws BufferOverflowException, IllegalStateException
StreamingDataOutput
writeLongAdv
in interface StreamingDataOutput<Bytes<U>>
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 public @NotNull Bytes<U> writeFloat(float f) throws BufferOverflowException, IllegalStateException
StreamingDataOutput
writeFloat
in interface StreamingDataOutput<Bytes<U>>
f
- The floating-point number to be written.BufferOverflowException
- if there is insufficient space in the buffer.IllegalStateException
- if released@NotNull public @NotNull Bytes<U> writeDouble(double d) throws BufferOverflowException, IllegalStateException
StreamingDataOutput
writeDouble
in interface StreamingDataOutput<Bytes<U>>
d
- The double-precision floating-point number to be written.BufferOverflowException
- if there is insufficient space in the buffer.IllegalStateException
- if released@NotNull public @NotNull Bytes<U> writeDoubleAndInt(double d, int i) throws BufferOverflowException, IllegalStateException
StreamingDataOutput
writeDoubleAndInt
in interface StreamingDataOutput<Bytes<U>>
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 releasedpublic int read(byte[] bytes, int off, int len) throws BufferUnderflowException, IllegalStateException
StreamingDataInput
read
in interface StreamingDataInput<Bytes<U>>
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 readIllegalStateException
- if a required state for this operation is not metpublic long read(long offsetInRDI, byte[] bytes, int offset, int length) throws IllegalStateException
RandomDataInput
read
in interface RandomDataInput
offsetInRDI
- the offset in the byte sequence from which to start reading.bytes
- the byte array into which the data is read.offset
- the start offset in the byte array at which the data is written.length
- the maximum number of bytes to read.IllegalStateException
- if the byte sequence has been released.@NotNull public @NotNull Bytes<U> write(byte[] byteArray, int offset, int length) throws BufferOverflowException, IllegalStateException, IllegalArgumentException
StreamingDataOutput
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.write
in interface StreamingDataOutput<Bytes<U>>
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 negativeprotected int safeCopySize()
@NotNull public @NotNull Bytes<U> writeSome(@NotNull @NotNull ByteBuffer buffer) throws BufferOverflowException, IllegalStateException, BufferUnderflowException
StreamingDataOutput
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.writeSome
in interface StreamingDataOutput<Bytes<U>>
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.@NotNull public @NotNull Bytes<U> writeBoolean(boolean flag) throws BufferOverflowException, IllegalStateException
StreamingDataOutput
writeBoolean
in interface StreamingDataOutput<Bytes<U>>
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 public @NotNull Bytes<U> writeOrderedInt(int i) throws BufferOverflowException, IllegalStateException
StreamingDataOutput
writeOrderedInt
in interface StreamingDataOutput<Bytes<U>>
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 public @NotNull Bytes<U> writeOrderedLong(long i) throws BufferOverflowException, IllegalStateException
StreamingDataOutput
writeOrderedLong
in interface StreamingDataOutput<Bytes<U>>
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.public long addressForRead(long offset) throws BufferUnderflowException, IllegalStateException
offset
- within this buffer. addressForRead(start()) is the actual addressForRead of the first byte.BufferUnderflowException
- if the offset is before the start() or the after the capacity()IllegalStateException
- if the buffer has been closed.public long addressForWrite(long offset) throws BufferOverflowException, IllegalStateException
offset
- within this buffer. addressForRead(start()) is the actual addressForRead of the first byte.BufferOverflowException
- if the offset is before the start() or the after the capacity()IllegalStateException
public long addressForWritePosition() throws BufferOverflowException, IllegalStateException
BufferOverflowException
- if the current write position is before the start or after the capacity.IllegalStateException
- if the buffer state doesn't allow the operation.@NotNull public @NotNull String toString()
toString
in interface CharSequence
toString
in class net.openhft.chronicle.core.io.AbstractReferenceCounted
public void nativeRead(long position, long address, long size) throws BufferUnderflowException, IllegalStateException
RandomDataInput
nativeRead
in interface RandomDataInput
position
- the starting point within the byte source from which data is copied.address
- the destination address in native memory.size
- the number of bytes to transfer.BufferUnderflowException
- if the specified position or size exceeds the byte source limits.IllegalStateException
- if the byte source has been released.public void nativeWrite(long address, long position, long size) throws BufferOverflowException, IllegalStateException
RandomDataOutput
nativeWrite
in interface RandomDataOutput<Bytes<U>>
address
- the address in the native memory from where data should be copied.position
- the position in the BytesStore where data should be written.size
- the size of the data, in bytes, to be copied from the native memory.BufferOverflowException
- if the capacity of this BytesStore was exceeded.IllegalStateException
- if this BytesStore has been previously released.@NotNull public @NotNull BytesStore bytesStore()
Bytes
The BytesStore represents the underlying storage of bytes that the Bytes object is manipulating.
bytesStore
in interface Bytes<U>
bytesStore
in interface BytesStore<Bytes<U>,U>
protected void bytesStore(BytesStore<Bytes<U>,U> bytesStore)
public int lastDecimalPlaces()
ByteStringParser
ByteStringParser.parseDouble()
or ByteStringParser.parseLongDecimal()
methods).lastDecimalPlaces
in interface ByteStringParser<Bytes<U>>
public void lastDecimalPlaces(int lastDecimalPlaces)
ByteStringParser
lastDecimalPlaces
in interface ByteStringParser<Bytes<U>>
lastDecimalPlaces
- the number of decimal places to set, if positive; otherwise 0.public boolean lastNumberHadDigits()
ByteStringParser
lastNumberHadDigits
in interface ByteStringParser<Bytes<U>>
public void lastNumberHadDigits(boolean lastNumberHadDigits)
ByteStringParser
lastNumberHadDigits
in interface ByteStringParser<Bytes<U>>
lastNumberHadDigits
- the new value to set, true if the last parsed number had digits, false otherwise.public BytesStore<Bytes<U>,U> copy() throws IllegalStateException
Bytes
RandomCommon.readPosition()
and RandomCommon.readLimit()
.
The copy will have its own separate storage and state, and modifications to the copy will not affect the original Bytes object, and vice versa.
copy
in interface Bytes<U>
copy
in interface BytesStore<Bytes<U>,U>
IllegalStateException
- If this Bytes object is in an illegal state for copying.public boolean isElastic()
Bytes
Bytes.realCapacity()
.
Elastic Bytes objects can automatically grow to accommodate additional data, whereas non-elastic ones have a fixed capacity.
public void lenient(boolean lenient)
StreamingDataInput
false
and empty string.lenient
in interface StreamingDataInput<Bytes<U>>
lenient
- if true, return nothing rather than error.public boolean lenient()
lenient
in interface StreamingDataInput<Bytes<U>>
public int byteCheckSum() throws net.openhft.chronicle.core.io.IORuntimeException, BufferUnderflowException, IllegalStateException
BytesStore
byteCheckSum
in interface BytesStore<Bytes<U>,U>
BufferUnderflowException
- if there's not enough data to be movedIllegalStateException
- if the BytesStore has been releasednet.openhft.chronicle.core.io.ClosedIllegalStateException
- if this Bytes has been releasednet.openhft.chronicle.core.io.IORuntimeException
public int byteCheckSum(long start, long end) throws BufferUnderflowException, IllegalStateException
BytesStore
byteCheckSum
in interface BytesStore<Bytes<U>,U>
start
- the index of the first byte to sumend
- the index of the last byte to sumBufferUnderflowException
- if the specified indexes are outside the limits of the BytesStoreIllegalStateException
- if the BytesStore has been releasedpublic boolean startsWith(@Nullable @Nullable BytesStore bytesStore) throws IllegalStateException
BytesStore
startsWith
in interface BytesStore<Bytes<U>,U>
bytesStore
- the BytesStore to compare withtrue
if the content of this BytesStore starts with bytesStorenet.openhft.chronicle.core.io.ClosedIllegalStateException
- if this Bytes has been releasedIllegalStateException
- if this Bytes is in an unusable state@NotNull public @NotNull UncheckedRandomDataInput acquireUncheckedInput()
HasUncheckedRandomDataInput
acquireUncheckedInput
in interface HasUncheckedRandomDataInput
public int byteCheckSum(int start, int end) throws BufferUnderflowException, IllegalStateException
start
- the index of the first byte to sumend
- the index of the last byte to sumBufferUnderflowException
- if the specified indexes are outside the limits of the BytesStoreIllegalStateException
- if the BytesStore has been releasedpublic boolean isImmutableEmptyByteStore()
BytesStore
isImmutableEmptyByteStore
in interface BytesStore<Bytes<U>,U>
public int copyTo(byte[] bytes) throws BufferUnderflowException, IllegalStateException
RandomDataInput
RandomCommon.readPosition()
up to RandomCommon.readLimit()
.copyTo
in interface RandomDataInput
bytes
- the target byte array to which the data is copied.BufferUnderflowException
- if the source's read position or limit is beyond the byte source limits.IllegalStateException
- if the byte source has been released.@Deprecated public byte[] internalNumberBuffer()
internalNumberBuffer
in interface ByteStringAppender<Bytes<U>>
internalNumberBuffer
in interface RandomDataOutput<Bytes<U>>
internalNumberBuffer
in interface StreamingDataOutput<Bytes<U>>
Copyright © 2023. All rights reserved.