public interface Bytes<Underlying> extends BytesStore<Bytes<Underlying>,Underlying>, BytesIn<Underlying>, BytesOut<Underlying>
start() <= readPosition() <= writePosition() <= writeLimit() <= capacity()
Also readLimit() == writePosition() && readPosition() <= safeLimit()
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_BYTE_BUFFER_CAPACITY |
static int |
MAX_BYTE_BUFFER_CAPACITY
Deprecated.
|
static long |
MAX_CAPACITY |
static int |
MAX_HEAP_CAPACITY |
charToString
JAVA9_STRING_CODER_LATIN, JAVA9_STRING_CODER_UTF16
Modifier and Type | Method and Description |
---|---|
static @NotNull VanillaBytes |
allocateDirect(@NotNull byte[] bytes)
Creates and returns a new fix sized wrapper for native (64-bit address)
memory with the contents copied from the given
bytes array. |
static @NotNull VanillaBytes<Void> |
allocateDirect(long capacity)
Creates and returns a new fix sized wrapper for native (64-bit address)
memory with the given
capacity . |
static @NotNull NativeBytes<Void> |
allocateElasticDirect()
Creates and returns a new elastic wrapper for native (64-bit address)
memory with zero initial capacity which will be resized as required.
|
static @NotNull NativeBytes<Void> |
allocateElasticDirect(long initialCapacity)
Creates and returns a new elastic wrapper for native (64-bit address)
memory with the given
initialCapacity which will be resized as required. |
static @NotNull OnHeapBytes |
allocateElasticOnHeap()
Creates and returns a new elastic wrapper for on heap memory with the
initialCapacity 32 bytes which will be resized as required. |
static @NotNull OnHeapBytes |
allocateElasticOnHeap(int initialCapacity)
Creates and returns a new elastic wrapper for on heap memory with the specified
initialCapacity which will be resized as required. |
default @NotNull Bytes<Underlying> |
bytesForRead()
Creates a slice of the current Bytes based on its readPosition and limit.
|
@Nullable BytesStore |
bytesStore() |
@NotNull Bytes<Underlying> |
clear()
Set the readPosition= writePosition = start, writeLimit = capacity
|
@NotNull Bytes<Underlying> |
compact()
Compact these Bytes by moving the readPosition to the start.
|
BytesStore<Bytes<Underlying>,Underlying> |
copy() |
default long |
copyTo(@NotNull BytesStore store)
Copies bytes from this Bytes to another ByteStore.
|
default void |
copyTo(@NotNull OutputStream out)
Copies bytes from this Bytes to a specified OutputStream.
|
static @NotNull Bytes<?> |
directFrom(@NotNull String text)
Converts text to bytes using ISO-8859-1 encoding and return a Bytes ready for reading.
|
static @NotNull Bytes<ByteBuffer> |
elasticByteBuffer()
Creates and returns a new elastic wrapper for a direct (off-heap) ByteBuffer with a default capacity
which will be resized as required.
|
static @NotNull Bytes<ByteBuffer> |
elasticByteBuffer(int initialCapacity)
Creates and returns a new elastic wrapper for a direct (off-heap) ByteBuffer with
the given
initialCapacity which will be resized as required. |
static @NotNull Bytes<ByteBuffer> |
elasticByteBuffer(int initialCapacity,
int maxCapacity)
Creates and returns a new elastic wrapper for a direct (off-heap) ByteBuffer with
the given
initialCapacity which will be resized as required up
to the given maxSize . |
static @NotNull Bytes<ByteBuffer> |
elasticHeapByteBuffer()
Creates and returns a new elastic wrapper for a heap ByteBuffer with
the
initialCapacity 128 bytes which will be resized as required. |
static @NotNull Bytes<ByteBuffer> |
elasticHeapByteBuffer(int initialCapacity)
Creates and returns a new elastic wrapper for a heap ByteBuffer with
the given
initialCapacity which will be resized as required. |
default void |
ensureCapacity(long desiredCapacity)
Grows the buffer if the buffer is elastic, if the buffer is not elastic and there is not
enough capacity then this method will
throws
BufferOverflowException |
static <T> Bytes<T> |
forFieldGroup(T t,
String groupName) |
static @NotNull Bytes<?> |
from(@NotNull CharSequence text)
Converts text to bytes using ISO-8859-1 encoding and returns a Bytes ready for reading.
|
static @NotNull Bytes<byte[]> |
from(@NotNull String text)
Converts text to bytes using ISO-8859-1 encoding and returns a Bytes ready for reading.
|
static Bytes<?> |
fromDirect(@NotNull CharSequence text) |
static @NotNull Bytes |
fromHexString(@NotNull String s) |
static Bytes<?> |
fromString(String text)
Deprecated.
|
default long |
indexOf(@NotNull Bytes source)
Returns the index within this Bytes of the first occurrence of the
specified sub-bytes.
|
default long |
indexOf(@NotNull Bytes source,
int fromIndex)
Deprecated.
|
static int |
indexOf(@NotNull BytesStore source,
@NotNull BytesStore target,
int fromIndex)
Code shared by String and StringBuffer to do searches.
|
default int |
indexOf(@NotNull BytesStore source,
int fromIndex)
Returns the index within this Bytes of the first occurrence of the
specified sub-bytes.
|
default boolean |
isClear()
Returns if the
readPosition is at the start and
the writeLimit is at the end . |
boolean |
isElastic()
Returns if this Bytes is elastic.
|
default boolean |
isEqual(String s) |
default @NotNull BigDecimal |
readBigDecimal() |
default @NotNull BigInteger |
readBigInteger() |
default <T extends ReadBytesMarshallable> |
readMarshallableLength16(Class<T> tClass,
T object) |
default void |
readWithLength(long length,
@NotNull BytesOut<Underlying> bytesOut) |
default boolean |
readWrite()
Returns
true . |
default long |
realCapacity()
Returns the actual capacity that can be potentially read.
|
default long |
safeLimit() |
default boolean |
sharedMemory() |
default @NotNull String |
toHexString() |
default @NotNull String |
toHexString(long maxLength)
Displays the hex data of
Bytes from the readPosition up to the specified length. |
default @NotNull String |
toHexString(long offset,
long maxLength)
Displays the hex data of
Bytes with the specified maximum length from the specified offset. |
static @NotNull String |
toString(@NotNull Bytes<?> buffer)
Creates and returns a string from the
readPosition to the readLimit , The buffer is not modified
by this call |
static @NotNull String |
toString(@NotNull Bytes<?> buffer,
long maxLen)
Creates and returns a string from the
readPosition to the readLimit with a specified maximum length, The buffer is not modified
by this call. |
static @NotNull String |
toString(@NotNull Bytes buffer,
long position,
long len)
Creates and returns a string from the bytes of a given buffer with a specified length and from an specified offset.
|
default boolean |
unchecked() |
default @NotNull Bytes<Underlying> |
unchecked(boolean unchecked)
Returns a Bytes which is optionally unchecked.
|
default void |
unwrite(long fromOffset,
int count)
Will un-write a specified number of bytes from an offset from this Bytes.
|
static Bytes<byte[]> |
valueOf(String text) |
static @NotNull Bytes<byte[]> |
wrapForRead(@NotNull byte[] byteArray)
Wraps the byte[] ready for reading
Method for convenience only - might not be ideal for performance (creates garbage).
|
static @NotNull Bytes<ByteBuffer> |
wrapForRead(@NotNull ByteBuffer byteBuffer)
Wrap the ByteBuffer ready for reading
Method for convenience only - might not be ideal for performance (creates garbage).
|
static @NotNull Bytes<byte[]> |
wrapForWrite(@NotNull byte[] byteArray)
Wraps the byte[] ready for writing
Method for convenience only - might not be ideal for performance (creates garbage).
|
static @NotNull Bytes<ByteBuffer> |
wrapForWrite(@NotNull ByteBuffer byteBuffer)
Wraps the ByteBuffer ready for writing
Method for convenience only - might not be ideal for performance (creates garbage).
|
default Bytes |
write(InputStream inputStream) |
default void |
writeMarshallableLength16(WriteBytesMarshallable marshallable) |
addAndGetDoubleNotAtomic, addAndGetFloatNotAtomic, addAndGetIntNotAtomic, addAndGetShortNotAtomic, addAndGetUnsignedByteNotAtomic, byteCheckSum, byteCheckSum, bytesForWrite, capacity, charAt, cipher, cipher, contentEquals, elasticByteBuffer, empty, endsWith, equalBytes, forFields, from, hash, inside, inside, isDirectMemory, isEmpty, isEqual, lazyNativeBytesStoreWithFixedCapacity, length, move, nativePointer, nativeStore, nativeStoreWithFixedCapacity, startsWith, startsWith, subSequence, to8bitString, toDebugString, toDebugString, underlyingObject, wrap, wrap, wrap, writeMaxInt, writeMaxLong, zeroOut
append, append, nativeWrite, write, write, write, write, write, write8bit, write8bit, writeBoolean, writeByte, writeByte, writeDouble, writeFloat, writeInt, writeInt24, writeLong, writeOrderedDouble, writeOrderedFloat, writeOrderedInt, writeOrderedLong, writeShort, writeUnsignedByte, writeUnsignedInt, writeUnsignedShort, writeUtf8, writeUtf8Limited, writeVolatileByte, writeVolatileDouble, writeVolatileFloat, writeVolatileInt, writeVolatileLong, writeVolatileShort
chars, codePoints, toString
bytesMethodReader, bytesMethodReaderBuilder, readObject
addAndGetDouble, addAndGetFloat, addAndGetInt, addAndGetLong, canReadDirect, compareUtf8, copyTo, copyTo, createCharToString, fastHash, findByte, nativeRead, parseLong, peekUnsignedByte, peekVolatileInt, printable, read, readBoolean, readByte, readDouble, readFloat, readIncompleteLong, readInt, readLong, readShort, readUnsignedByte, readUnsignedInt, readUnsignedInt24, readUnsignedShort, readUtf8, readUtf8Limited, readUtf8Limited, readVolatileByte, readVolatileDouble, readVolatileFloat, readVolatileInt, readVolatileLong, readVolatileShort, subBytes, toByteArray, toTemporaryDirectByteBuffer
lastDecimalPlaces, lastDecimalPlaces, lastNumberHadDigits, lastNumberHadDigits, parse8bit, parse8bit, parse8bit, parse8bit, parse8bit, parseBigDecimal, parseBoolean, parseBoolean, parseDouble, parseFloat, parseInt, parseLong, parseLongDecimal, parseUTF, parseUTF, parseUTF, parseUtf8, parseUtf8, parseUtf8, reader, skipTo
inputStream, lenient, lenient, parseHexLong, parseUTF, parseUtf8, parseUtf8, peekUnsignedByte, rawReadByte, rawReadInt, rawReadLong, read, read, read, read, read, read, read8bit, read8bit, read8bit, read8bit, readBoolean, readByte, readChar, readDouble, readEnum, readFloat, readHistogram, readIncompleteLong, readInt, readInt24, readLimit, readLimitToCapacity, readLong, readPosition, readPositionForHeader, readPositionRemaining, readPositionUnlimited, readShort, readSkip, readStopBit, readStopBitChar, readStopBitDecimal, readStopBitDouble, readUnsignedByte, readUnsignedInt, readUnsignedInt24, readUnsignedShort, readUtf8, readUtf8, readUtf8, readUtf8, readUTFΔ, readUTFΔ, readVolatileInt, readVolatileLong, readWithLength, readWithLength, readWithLength0, uncheckedReadSkipBackOne, uncheckedReadSkipOne, uncheckedReadUnsignedByte, unsafeRead, unsafeReadObject, unsafeReadObject
bytesMethodWriter, writeObject
append, append, append, append, append, append, append, append, append, append, append8bit, append8bit, append8bit, append8bit, append8bit, appendBase, appendBase16, appendBase16, appendDateMillis, appendDecimal, appendTimeMillis, writer
alignBy, appendUtf8, appendUtf8, appendUtf8, appendUtf8, appendUtf8, appendUtf8, canWriteDirect, copyFrom, outputStream, rawWriteByte, rawWriteInt, rawWriteLong, unsafeWrite, unsafeWriteObject, unsafeWriteObject, write, write, write, write, write, write, write, write, write8bit, write8bit, write8bit, write8bit, write8bit, writeBigDecimal, writeBigInteger, writeBoolean, writeByte, writeChar, writeDouble, writeDoubleAndInt, writeEnum, writeFloat, writeHistogram, writeInt, writeInt24, writeIntAdv, writeLimit, writeLong, writeLongAdv, writeOrderedInt, writeOrderedLong, writePosition, writePositionForHeader, writePositionRemaining, writeShort, writeSkip, writeSome, writeSome, writeStopBit, writeStopBit, writeStopBit, writeStopBitDecimal, writeUnsignedByte, writeUnsignedInt, writeUnsignedInt24, writeUnsignedShort, writeUtf8, writeUtf8, writeUTFΔ, writeWithLength
clearAndPad, prepend, prewrite, prewrite, prewriteByte, prewriteInt, prewriteLong, prewriteShort
comment, indent, retainsComments
static final long MAX_CAPACITY
static final int MAX_HEAP_CAPACITY
@Deprecated static final int MAX_BYTE_BUFFER_CAPACITY
static final int DEFAULT_BYTE_BUFFER_CAPACITY
@NotNull static @NotNull Bytes<ByteBuffer> elasticByteBuffer()
@NotNull static @NotNull Bytes<ByteBuffer> elasticByteBuffer(int initialCapacity)
initialCapacity
which will be resized as required.initialCapacity
- the initial non-negative capacity given in bytesinitialCapacity
which will be resized as required@NotNull static @NotNull Bytes<ByteBuffer> elasticByteBuffer(int initialCapacity, int maxCapacity)
initialCapacity
which will be resized as required up
to the given maxSize
.initialCapacity
- the initial non-negative capacity given in bytesmaxCapacity
- the max capacity given in bytes equal or greater than initialCapacityinitialCapacity
which will be resized as required up
to the given maxCapacity
@NotNull static @NotNull Bytes<ByteBuffer> elasticHeapByteBuffer(int initialCapacity)
initialCapacity
which will be resized as required.initialCapacity
- the initial non-negative capacity given in bytesinitialCapacity
which will be resized as required@NotNull static @NotNull Bytes<ByteBuffer> elasticHeapByteBuffer()
initialCapacity
128 bytes which will be resized as required.initialCapacity
128 bytes which will be resized as required@NotNull static @NotNull Bytes<ByteBuffer> wrapForRead(@NotNull @NotNull ByteBuffer byteBuffer)
import net.openhft.chronicle.bytes.Bytes;
import java.nio.ByteBuffer;
public class ChronicleBytesWithByteBufferExampleTest {
private static final String HELLO_WORLD = "hello world";
public static void main(String[] args)
throws InterruptedException {
//setup Bytes and ByteBuffer to write from
Bytes b = Bytes.elasticByteBuffer();
ByteBuffer toWriteFrom = ByteBuffer.allocate(HELLO_WORLD.length());
toWriteFrom.put(HELLO_WORLD.getBytes(), 0, HELLO_WORLD.length());
toWriteFrom.flip();
byte[] toReadTo = new byte[HELLO_WORLD.length()];
doWrite(b, toWriteFrom);
ByteBuffer byteBuffer = doRead(b);
//check result
final StringBuilder sb = new StringBuilder();
for (int i = 0; i < HELLO_WORLD.length(); i++) {
sb.append((char) byteBuffer.get());
}
assert sb.toString().equals(HELLO_WORLD): "Failed - strings not equal!";
}
private static void doWrite(Bytes b, ByteBuffer toWrite) {
//no garbage when writing to Bytes from ByteBuffer
b.clear();
b.write(b.writePosition(), toWrite, toWrite.position(), toWrite.limit());
}
private static ByteBuffer doRead(Bytes b) {
//no garbage when getting the underlying ByteBuffer
assert b.underlyingObject() instanceof ByteBuffer;
ByteBuffer byteBuffer = (ByteBuffer) b.underlyingObject();
return byteBuffer;
}
}
byteBuffer
- to wrap@NotNull static @NotNull Bytes<ByteBuffer> wrapForWrite(@NotNull @NotNull ByteBuffer byteBuffer)
import net.openhft.chronicle.bytes.Bytes;
import java.nio.ByteBuffer;
public class ChronicleBytesWithByteBufferExampleTest {
private static final String HELLO_WORLD = "hello world";
public static void main(String[] args)
throws InterruptedException {
//setup Bytes and ByteBuffer to write from
Bytes b = Bytes.elasticByteBuffer();
ByteBuffer toWriteFrom = ByteBuffer.allocate(HELLO_WORLD.length());
toWriteFrom.put(HELLO_WORLD.getBytes(), 0, HELLO_WORLD.length());
toWriteFrom.flip();
byte[] toReadTo = new byte[HELLO_WORLD.length()];
doWrite(b, toWriteFrom);
ByteBuffer byteBuffer = doRead(b);
//check result
final StringBuilder sb = new StringBuilder();
for (int i = 0; i < HELLO_WORLD.length(); i++) {
sb.append((char) byteBuffer.get());
}
assert sb.toString().equals(HELLO_WORLD): "Failed - strings not equal!";
}
private static void doWrite(Bytes b, ByteBuffer toWrite) {
//no garbage when writing to Bytes from ByteBuffer
b.clear();
b.write(b.writePosition(), toWrite, toWrite.position(), toWrite.limit());
}
private static ByteBuffer doRead(Bytes b) {
//no garbage when getting the underlying ByteBuffer
assert b.underlyingObject() instanceof ByteBuffer;
ByteBuffer byteBuffer = (ByteBuffer) b.underlyingObject();
return byteBuffer;
}
}
byteBuffer
- to wrap@NotNull static @NotNull Bytes<byte[]> wrapForRead(@NotNull @NotNull byte[] byteArray)
import net.openhft.chronicle.bytes.Bytes;
import java.nio.charset.Charset;
public class ChronicleBytesWithPrimByteArrayExampleTest {
private static final Charset ISO_8859 = Charset.forName("ISO-8859-1");
private static final String HELLO_WORLD = "hello world";
public static void main(String[] args) {
//setup Bytes and byte[]s to write from and read to
Bytes b = Bytes.elasticByteBuffer();
byte[] toWriteFrom = HELLO_WORLD.getBytes(ISO_8859);
byte[] toReadTo = new byte[HELLO_WORLD.length()];
doWrite(b, toWriteFrom);
doRead(b, toReadTo);
//check result
final StringBuilder sb = new StringBuilder();
for (int i = 0; i < HELLO_WORLD.length(); i++) {
sb.append((char) toReadTo[i]);
}
assert sb.toString().equals(HELLO_WORLD): "Failed - strings not equal!";
}
private static void doWrite(Bytes b, byte[] toWrite) {
//no garbage when writing to Bytes from byte[]
b.clear();
b.write(toWrite);
}
private static void doRead(Bytes b, byte[] toReadTo) {
//no garbage when reading from Bytes into byte[]
b.read( toReadTo, 0, HELLO_WORLD.length());
}
}
byteArray
- to wrap@NotNull static @NotNull Bytes<byte[]> wrapForWrite(@NotNull @NotNull byte[] byteArray)
import net.openhft.chronicle.bytes.Bytes;
import java.nio.charset.Charset;
public class ChronicleBytesWithPrimByteArrayExampleTest {
private static final Charset ISO_8859 = Charset.forName("ISO-8859-1");
private static final String HELLO_WORLD = "hello world";
public static void main(String[] args) {
//setup Bytes and byte[]s to write from and read to
Bytes b = Bytes.elasticByteBuffer();
byte[] toWriteFrom = HELLO_WORLD.getBytes(ISO_8859);
byte[] toReadTo = new byte[HELLO_WORLD.length()];
doWrite(b, toWriteFrom);
doRead(b, toReadTo);
//check result
final StringBuilder sb = new StringBuilder();
for (int i = 0; i < HELLO_WORLD.length(); i++) {
sb.append((char) toReadTo[i]);
}
assert sb.toString().equals(HELLO_WORLD): "Failed - strings not equal!";
}
private static void doWrite(Bytes b, byte[] toWrite) {
//no garbage when writing to Bytes from byte[]
b.clear();
b.write(toWrite);
}
private static void doRead(Bytes b, byte[] toReadTo) {
//no garbage when reading from Bytes into byte[]
b.read( toReadTo, 0, HELLO_WORLD.length());
}
}
byteArray
- to wrap@NotNull static @NotNull Bytes<?> from(@NotNull @NotNull CharSequence text)
Note: this returns a direct Bytes now
from
in interface BytesStore<Bytes<Underlying>,Underlying>
text
- to convertstatic Bytes<?> fromDirect(@NotNull @NotNull CharSequence text)
@Deprecated static Bytes<?> fromString(String text)
@NotNull static @NotNull Bytes<?> directFrom(@NotNull @NotNull String text)
Note: this returns a direct Bytes now
text
- to convert@NotNull static @NotNull Bytes<byte[]> from(@NotNull @NotNull String text)
The returned Bytes is allocated on the heap.
from
in interface BytesStore<Bytes<Underlying>,Underlying>
text
- to convert@NotNull static @NotNull VanillaBytes<Void> allocateDirect(long capacity) throws IllegalArgumentException
capacity
.capacity
- the non-negative capacity given in bytescapacity
IllegalArgumentException
@NotNull static @NotNull NativeBytes<Void> allocateElasticDirect()
@NotNull static @NotNull NativeBytes<Void> allocateElasticDirect(long initialCapacity) throws IllegalArgumentException
initialCapacity
which will be resized as required.initialCapacity
- the initial non-negative capacity given in bytesinitialCapacity
which will be resized as requiredIllegalArgumentException
@NotNull static @NotNull OnHeapBytes allocateElasticOnHeap()
initialCapacity
32 bytes which will be resized as required.@NotNull static @NotNull OnHeapBytes allocateElasticOnHeap(int initialCapacity)
initialCapacity
which will be resized as required.initialCapacity
- the initial capacity of the wrapper in bytes@NotNull static @NotNull String toString(@NotNull @NotNull Bytes<?> buffer) throws BufferUnderflowException, IllegalStateException, IllegalArgumentException
readPosition
to the readLimit
, The buffer is not modified
by this callbuffer
- the buffer to usereadPosition
to the readLimit
BufferUnderflowException
IllegalStateException
IllegalArgumentException
@NotNull static @NotNull String toString(@NotNull @NotNull Bytes<?> buffer, long maxLen) throws BufferUnderflowException, IllegalStateException, IllegalArgumentException
readPosition
to the readLimit
with a specified maximum length, The buffer is not modified
by this call.
If the length of the string between readPosition
to readLimit
is greater than the specified maximum length,
the "..." will be appended to the resulting string; in this case the length of the resulting string will be the specified maximum length+3.
buffer
- the buffer to usemaxLen
- the maximum length from the buffer, used to create a new stringreadPosition
to the readLimit
of the bufferBufferUnderflowException
IllegalStateException
IllegalArgumentException
@NotNull static @NotNull String toString(@NotNull @NotNull Bytes buffer, long position, long len)
buffer
- the buffer to useposition
- the offset position to create the string fromlen
- the number of characters to include in the string@NotNull static @NotNull VanillaBytes allocateDirect(@NotNull @NotNull byte[] bytes) throws IllegalArgumentException
bytes
array.
Changes in the given bytes
will not be affected by writes in
the returned wrapper or vice versa.
bytes
- array to copybytes
arrayIllegalArgumentException
static int indexOf(@NotNull @NotNull BytesStore source, @NotNull @NotNull BytesStore target, int fromIndex) throws IllegalStateException
source
- the read bytes being searched.target
- the read bytes being searched for.fromIndex
- the index to begin searching from,IllegalStateException
@NotNull default @NotNull Bytes<Underlying> unchecked(boolean unchecked) throws IllegalStateException
this
is elastic.unchecked
- if true, minimal bounds checks will be performedIllegalStateException
- if the underlying BytesStore has been releaseddefault boolean unchecked()
default long safeLimit()
safeLimit
in interface BytesStore<Bytes<Underlying>,Underlying>
default boolean isClear()
BytesStore
readPosition
is at the start
and
the writeLimit
is at the end
.
I.e start() == readPosition() && writeLimit() == capacity()
isClear
in interface BytesStore<Bytes<Underlying>,Underlying>
readPosition
is at the start
and
the writeLimit
is at the end
default long realCapacity()
RandomDataInput
realCapacity
in interface BytesStore<Bytes<Underlying>,Underlying>
realCapacity
in interface RandomDataInput
realCapacity
in interface StreamingDataOutput<Bytes<Underlying>>
BytesStore<Bytes<Underlying>,Underlying> copy() throws IllegalStateException
copy
in interface BytesStore<Bytes<Underlying>,Underlying>
IllegalStateException
@NotNull default @NotNull String toHexString()
@NotNull default @NotNull String toHexString(long maxLength)
Bytes
from the readPosition
up to the specified length.maxLength
- limit the number of bytes to be dumped@NotNull default @NotNull String toHexString(long offset, long maxLength)
Bytes
with the specified maximum length from the specified offset.offset
- the specified offset to start frommaxLength
- limit the number of bytes to be dumpedboolean isElastic()
realCapacity()
.default void ensureCapacity(long desiredCapacity) throws IllegalArgumentException, IllegalStateException
BufferOverflowException
desiredCapacity
- the capacity that you requiredIllegalArgumentException
- if the buffer is not elastic and there is not enough spaceIllegalStateException
@NotNull default @NotNull Bytes<Underlying> bytesForRead() throws IllegalStateException
bytesForRead
in interface BytesStore<Bytes<Underlying>,Underlying>
IllegalStateException
- if the underlying BytesStore has been released@Nullable @Nullable BytesStore bytesStore()
bytesStore
in interface BytesStore<Bytes<Underlying>,Underlying>
default boolean isEqual(String s) throws IllegalStateException
IllegalStateException
@NotNull @NotNull Bytes<Underlying> compact() throws IllegalStateException
IllegalStateException
default long copyTo(@NotNull @NotNull BytesStore store) throws IllegalStateException
copyTo
in interface BytesStore<Bytes<Underlying>,Underlying>
copyTo
in interface StreamingDataInput<Bytes<Underlying>>
store
- the BytesStore to copy toIllegalStateException
- if this BytesStore has been releaseddefault void copyTo(@NotNull @NotNull OutputStream out) throws IOException, IllegalStateException
copyTo
in interface BytesStore<Bytes<Underlying>,Underlying>
copyTo
in interface StreamingDataInput<Bytes<Underlying>>
out
- the specified OutputStream that this BytesStore is copied toIllegalStateException
- if this Bytes has been releasedIOException
- if an I/O error occursOutputStream
default boolean sharedMemory()
default void unwrite(long fromOffset, int count) throws BufferUnderflowException, BufferOverflowException, IllegalStateException
Calling this method will update the cursors of this Bytes.
fromOffset
- the offset from the target bytescount
- the number of bytes to un-writeBufferUnderflowException
BufferOverflowException
IllegalStateException
@NotNull default @NotNull BigDecimal readBigDecimal() throws ArithmeticException, BufferUnderflowException, IllegalStateException
@NotNull default @NotNull BigInteger readBigInteger() throws ArithmeticException, BufferUnderflowException, IllegalStateException
default long indexOf(@NotNull @NotNull Bytes source) throws IllegalStateException
The returned index is the smallest value k for which:
If no such value of k exists, thenthis.startsWith(bytes, k)
-1
is returned.source
- the sub-bytes to search for.-1
if there is no such occurrence.IllegalStateException
default int indexOf(@NotNull @NotNull BytesStore source, int fromIndex) throws IllegalStateException
The returned index is the smallest value k for which:
If no such value of k exists, thenthis.startsWith(bytes, k)
-1
is returned.source
- the sub-bytes to search for.fromIndex
- start the search from this offset-1
if there is no such occurrence.IllegalStateException
@Deprecated default long indexOf(@NotNull @NotNull Bytes source, int fromIndex) throws IllegalStateException
IllegalStateException
@NotNull @NotNull Bytes<Underlying> clear() throws IllegalStateException
StreamingCommon
clear
in interface StreamingCommon<Bytes<Underlying>>
IllegalStateException
default boolean readWrite()
BytesStore
true
.readWrite
in interface BytesStore<Bytes<Underlying>,Underlying>
default void readWithLength(long length, @NotNull @NotNull BytesOut<Underlying> bytesOut) throws BufferUnderflowException, net.openhft.chronicle.core.io.IORuntimeException, BufferOverflowException, IllegalStateException
BufferUnderflowException
net.openhft.chronicle.core.io.IORuntimeException
BufferOverflowException
IllegalStateException
default <T extends ReadBytesMarshallable> T readMarshallableLength16(Class<T> tClass, T object) throws BufferUnderflowException, IllegalStateException
readMarshallableLength16
in interface BytesIn<Underlying>
BufferUnderflowException
IllegalStateException
default void writeMarshallableLength16(WriteBytesMarshallable marshallable) throws IllegalArgumentException, BufferOverflowException, IllegalStateException, BufferUnderflowException
writeMarshallableLength16
in interface BytesOut<Underlying>
IllegalArgumentException
BufferOverflowException
IllegalStateException
BufferUnderflowException
default Bytes write(InputStream inputStream) throws IOException, BufferOverflowException, IllegalStateException
Copyright © 2021. All rights reserved.