public interface Bytes<Underlying> extends BytesStore<Bytes<Underlying>,Underlying>, BytesIn<Underlying>, BytesOut<Underlying>
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_BYTE_BUFFER_CAPACITY |
static int |
MAX_BYTE_BUFFER_CAPACITY |
static long |
MAX_CAPACITY |
charToStringJAVA9_STRING_CODER_LATIN, JAVA9_STRING_CODER_UTF16| Modifier and Type | Method and Description |
|---|---|
static Bytes |
allocateDirect(byte[] bytes)
copies the contents of bytes into a direct byte buffer
|
static VanillaBytes<Void> |
allocateDirect(long capacity)
Allocate a fixed size buffer read for writing.
|
static NativeBytes<Void> |
allocateElasticDirect()
Allocate an elastic buffer with initially no size.
|
static NativeBytes<Void> |
allocateElasticDirect(long initialCapacity)
Allocate an elastic buffer with initially no size.
|
default Bytes<Underlying> |
bytesForRead()
Creates a slice of the current Bytes based on its position() and limit().
|
BytesStore |
bytesStore() |
Bytes<Underlying> |
clear()
Set the readPosition= writePosition = start, writeLimit = capacity
|
Bytes<Underlying> |
compact()
Compact these Bytes by moving the readPosition to the start.
|
BytesStore<Bytes<Underlying>,Underlying> |
copy() |
default long |
copyTo(BytesStore store)
copy bytes from one ByteStore to another
|
default void |
copyTo(OutputStream out) |
static Bytes<ByteBuffer> |
elasticByteBuffer() |
static Bytes<ByteBuffer> |
elasticByteBuffer(int initialCapacity)
Returns an elastic wrapper for a direct ByteBuffer which will be resized as required, with
the given initial capacity.
|
static Bytes<ByteBuffer> |
elasticByteBuffer(int initialCapacity,
int maxSize) |
static Bytes<ByteBuffer> |
elasticHeapByteBuffer(int initialCapacity)
Returns an elastic wrapper for a heap ByteBuffer which will be resized as required, with
the given initial capacity.
|
default void |
ensureCapacity(long size)
grow 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 Bytes<byte[]> |
from(CharSequence text)
Convert text to bytes using ISO-8859-1 encoding and return a Bytes ready for reading.
|
static Bytes |
fromHexString(String s) |
static Bytes<byte[]> |
fromString(String text) |
default long |
indexOf(Bytes source)
Returns the index within this bytes of the first occurrence of the
specified sub-bytes.
|
default long |
indexOf(Bytes source,
int fromIndex)
Deprecated.
|
static int |
indexOf(BytesStore source,
BytesStore target,
int fromIndex)
Code shared by String and StringBuffer to do searches.
|
default int |
indexOf(BytesStore source,
int fromIndex)
Returns the index within this bytes of the first occurrence of the
specified subbytes.
|
default boolean |
isClear()
The Bytes are clear if start() == readPosition() && writeLimit() == capacity()
|
boolean |
isElastic() |
default boolean |
isEqual(String s) |
int |
lastDecimalPlaces() |
void |
lastDecimalPlaces(int lastDecimalPlaces)
Store the last number of decimal places.
|
default void |
parse8bit(Appendable buffer,
StopCharsTester stopCharsTester)
parse text with ISO-8859-1 decoding as character terminated.
|
default void |
parse8bit(Appendable buffer,
StopCharTester stopCharTester)
parse text with ISO-8859-1 decoding as character terminated.
|
default BigDecimal |
parseBigDecimal() |
default Boolean |
parseBoolean(StopCharTester tester)
Return true or false, or null if it could not be detected
as true or false.
|
default double |
parseDouble()
parse text as a double decimal.
|
default long |
parseLong()
parse text as a long integer.
|
default long |
parseLongDecimal()
Parse the significant digits of a decimal number.
|
default void |
parseUTF(Appendable buffer,
StopCharsTester stopCharsTester)
Deprecated.
|
default void |
parseUTF(Appendable buffer,
StopCharTester stopCharTester)
Deprecated.
|
default String |
parseUTF(StopCharTester stopCharTester)
Deprecated.
|
default void |
parseUtf8(Appendable buffer,
StopCharsTester stopCharsTester)
parse text with UTF-8 decoding as one or two character terminated.
|
default void |
parseUtf8(Appendable buffer,
StopCharTester stopCharTester)
parse text with UTF-8 decoding as character terminated.
|
default String |
parseUtf8(StopCharTester stopCharTester)
parse text with UTF-8 decoding as character terminated.
|
default BigDecimal |
readBigDecimal() |
default BigInteger |
readBigInteger() |
default Reader |
reader()
Access these bytes as an ISO-8859-1 encoded Reader
|
default void |
readWithLength(long length,
BytesOut<Underlying> bytesOut) |
default boolean |
readWrite() |
default long |
realCapacity() |
default long |
safeLimit() |
default boolean |
sharedMemory() |
default boolean |
skipTo(StopCharTester tester)
Skip text until a terminating character is reached.
|
default String |
toHexString()
display the hex data of
Bytes from the position() to the limit() |
default String |
toHexString(long maxLength)
display the hex data of
Bytes from the position() to the limit() |
default String |
toHexString(long offset,
long maxLength)
display the hex data of
Bytes from the position() to the limit() |
static String |
toString(Bytes<?> buffer)
Creates a string from the
position to the limit, The buffer is not modified
by this call |
static String |
toString(Bytes<?> buffer,
long maxLen)
Creates a string from the
position to the limit, The buffer is not modified
by this call |
static String |
toString(Bytes buffer,
long position,
long len)
The buffer is not modified by this call
|
default boolean |
unchecked() |
default Bytes<Underlying> |
unchecked(boolean unchecked)
Return a Bytes which is optionally unchecked.
|
default void |
unwrite(long fromOffset,
int count) |
static Bytes<byte[]> |
wrapForRead(byte[] byteArray)
Wrap the byte[] ready for reading
|
static Bytes<ByteBuffer> |
wrapForRead(ByteBuffer byteBuffer) |
static Bytes<byte[]> |
wrapForWrite(byte[] byteArray)
Wrap the byte[] ready for writing
|
static Bytes<ByteBuffer> |
wrapForWrite(ByteBuffer byteBuffer) |
addAndGetByteNotAtomic, addAndGetDoubleNotAtomic, addAndGetFloatNotAtomic, addAndGetIntNotAtomic, addAndGetLongNotAtomic, addAndGetShortNotAtomic, addAndGetUnsignedByteNotAtomic, addAndGetUnsignedIntNotAtomic, addAndGetUnsignedShortNotAtomic, byteCheckSum, bytesForWrite, capacity, charAt, cipher, cipher, contentEquals, empty, endsWith, equalBytes, inside, isDirectMemory, isEmpty, isPresent, isPresent, length, longCheckSum, move, nativePointer, startsWith, startsWith, subSequence, to8bitString, toDebugString, toDebugString, underlyingObject, wrap, wrap, wrap, writeMaxLong, zeroOutaddAndGetDouble, addAndGetFloat, addAndGetInt, addAndGetLong, 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, toTemporaryDirectByteBufferappend, append, nativeWrite, write, write, write, write, write, writeBoolean, writeByte, writeByte, writeDouble, writeFloat, writeInt, writeInt24, writeLong, writeOrderedDouble, writeOrderedFloat, writeOrderedInt, writeOrderedLong, writeShort, writeUnsignedByte, writeUnsignedInt, writeUnsignedShort, writeUtf8, writeUtf8Limited, writeVolatileByte, writeVolatileDouble, writeVolatileFloat, writeVolatileInt, writeVolatileLong, writeVolatileShortchars, codePoints, toStringinputStream, nativeRead, parseHexLong, parseUTF, parseUtf8, peekUnsignedByte, read, read, read, read, read8bit, read8bit, read8bit, read8bit, readBoolean, readByte, readDouble, readEnum, readFloat, readHistogram, readInt, readLimit, readLong, readPosition, readPositionRemaining, readPositionUnlimited, readShort, readSkip, readStopBit, readStopBitDecimal, readStopBitDouble, readUnsignedByte, readUnsignedInt, readUnsignedInt24, readUnsignedShort, readUtf8, readUtf8, readUTFΔ, readUTFΔ, readVolatileInt, readVolatileLong, readWithLength, readWithLength, uncheckedReadSkipBackOne, uncheckedReadSkipOne, uncheckedReadUnsignedByteappend, append, append, append, append, append, append, append, append8bit, append8bit, append8bit, appendBase, appendDateMillis, appendDecimal, appendTimeMillis, writerappendUtf8, appendUtf8, appendUtf8, appendUtf8, appendUtf8, appendUtf8, copyFrom, nativeWrite, outputStream, write, write, write, write, write, write, write8bit, write8bit, write8bit, write8bit, writeBigDecimal, writeBigInteger, writeBoolean, writeByte, writeDouble, writeEnum, writeFloat, writeHistogram, writeInt, writeInt24, writeIntAdv, writeLimit, writeLong, writeLongAdv, writeOrderedInt, writeOrderedLong, writePosition, writePositionRemaining, writeShort, writeSkip, writeSome, writeSome, writeStopBit, writeStopBit, writeStopBitDecimal, writeUnsignedByte, writeUnsignedInt, writeUnsignedShort, writeUtf8, writeUtf8, writeUTFΔ, writeWithLengthclearAndPad, prepend, prewrite, prewrite, prewriteByte, prewriteInt, prewriteLong, prewriteShortstatic final long MAX_CAPACITY
static final int MAX_BYTE_BUFFER_CAPACITY
static final int DEFAULT_BYTE_BUFFER_CAPACITY
static Bytes<ByteBuffer> elasticByteBuffer()
static Bytes<ByteBuffer> elasticByteBuffer(int initialCapacity, int maxSize)
static Bytes<ByteBuffer> elasticByteBuffer(int initialCapacity)
@NotNull static Bytes<ByteBuffer> elasticHeapByteBuffer(int initialCapacity)
static Bytes<ByteBuffer> wrapForRead(@NotNull ByteBuffer byteBuffer)
byteBuffer - to readstatic Bytes<ByteBuffer> wrapForWrite(@NotNull ByteBuffer byteBuffer)
byteBuffer - to readstatic Bytes<byte[]> wrapForRead(@NotNull byte[] byteArray)
byteArray - to wrapstatic Bytes<byte[]> wrapForWrite(@NotNull byte[] byteArray)
byteArray - to wrapstatic Bytes<byte[]> from(@NotNull CharSequence text) throws IllegalArgumentException, IllegalStateException
from in interface BytesStore<Bytes<Underlying>,Underlying>text - to convertIllegalArgumentExceptionIllegalStateExceptionstatic Bytes<byte[]> fromString(@NotNull String text) throws IllegalArgumentException, IllegalStateException
static VanillaBytes<Void> allocateDirect(long capacity) throws IllegalArgumentException
capacity - minimum to allocateIllegalArgumentExceptionstatic NativeBytes<Void> allocateElasticDirect()
static NativeBytes<Void> allocateElasticDirect(long initialCapacity) throws IllegalArgumentException
IllegalArgumentExceptionstatic String toString(@NotNull Bytes<?> buffer) throws BufferUnderflowException
position to the limit, The buffer is not modified
by this callbuffer - the buffer to useposition to the limitBufferUnderflowExceptionstatic String toString(@NotNull Bytes<?> buffer, long maxLen) throws BufferUnderflowException
position to the limit, The buffer is not modified
by this callbuffer - the buffer to usemaxLen - of the result returnedposition to the limitBufferUnderflowExceptionstatic String toString(@NotNull Bytes buffer, long position, long len) throws BufferUnderflowException
buffer - the buffer to useposition - the position to create the string fromlen - the number of characters to show in the stringpositionBufferUnderflowException@NotNull static Bytes allocateDirect(@NotNull byte[] bytes) throws IllegalArgumentException
bytes - the bytes to wrapbytesIllegalArgumentExceptionstatic int indexOf(@NotNull
BytesStore source,
@NotNull
BytesStore target,
int fromIndex)
source - the read bytes being searched.target - the read bytes being searched for.fromIndex - the index to begin searching from,@NotNull default Bytes<Underlying> unchecked(boolean unchecked) throws IllegalStateException
unchecked - if true, minimal bounds checks will be performed.IllegalStateException - if the underlying BytesStore has been releaseddefault boolean unchecked()
default long safeLimit()
safeLimit in interface BytesStore<Bytes<Underlying>,Underlying>default boolean isClear()
BytesStoreisClear in interface BytesStore<Bytes<Underlying>,Underlying>default long realCapacity()
realCapacity in interface BytesStore<Bytes<Underlying>,Underlying>realCapacity in interface RandomDataInputrealCapacity in interface StreamingDataOutput<Bytes<Underlying>>BytesStore<Bytes<Underlying>,Underlying> copy()
copy in interface BytesStore<Bytes<Underlying>,Underlying>@NotNull default String toHexString()
Bytes from the position() to the limit()@NotNull default String toHexString(long maxLength)
Bytes from the position() to the limit()maxLength - limit the number of bytes to be dumped.@NotNull default String toHexString(long offset, long maxLength)
Bytes from the position() to the limit()maxLength - limit the number of bytes to be dumped.boolean isElastic()
default void ensureCapacity(long size)
throws IllegalArgumentException
BufferOverflowExceptionsize - the capacity that you requiredIllegalArgumentException - if the buffer is not elastic and there is not enough space@NotNull default Bytes<Underlying> bytesForRead() throws IllegalStateException
bytesForRead in interface BytesStore<Bytes<Underlying>,Underlying>IllegalStateException - if the underlying BytesStore has been released@Nullable BytesStore bytesStore()
bytesStore in interface BytesStore<Bytes<Underlying>,Underlying>default boolean isEqual(String s)
@NotNull Bytes<Underlying> compact()
default long copyTo(@NotNull
BytesStore store)
copyTo in interface BytesStore<Bytes<Underlying>,Underlying>copyTo in interface StreamingDataInput<Bytes<Underlying>>store - to copy todefault void copyTo(OutputStream out) throws IOException
copyTo in interface BytesStore<Bytes<Underlying>,Underlying>copyTo in interface StreamingDataInput<Bytes<Underlying>>IOExceptiondefault boolean sharedMemory()
default void unwrite(long fromOffset,
int count)
@NotNull default BigDecimal readBigDecimal()
@NotNull default BigInteger readBigInteger()
default long indexOf(@NotNull
Bytes source)
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.default int indexOf(@NotNull
BytesStore source,
int fromIndex)
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 seach from this offset-1 if there is no such occurrence.@Deprecated default long indexOf(@NotNull Bytes source, int fromIndex)
@NotNull Bytes<Underlying> clear()
StreamingCommonclear in interface StreamingCommon<Bytes<Underlying>>default boolean readWrite()
readWrite in interface BytesStore<Bytes<Underlying>,Underlying>default void readWithLength(long length,
@NotNull
BytesOut<Underlying> bytesOut)
throws BufferUnderflowException,
net.openhft.chronicle.core.io.IORuntimeException
BufferUnderflowExceptionnet.openhft.chronicle.core.io.IORuntimeException@NotNull default Reader reader()
@Nullable default Boolean parseBoolean(@NotNull StopCharTester tester)
false: f, false, n, no, 0
true: t, true, y, yes, 1
tester - to detect the end of the text.@NotNull default String parseUtf8(@NotNull StopCharTester stopCharTester)
stopCharTester - to check if the end has been reached.@NotNull @Deprecated default String parseUTF(@NotNull StopCharTester stopCharTester)
default void parseUtf8(@NotNull
Appendable buffer,
@NotNull
StopCharTester stopCharTester)
buffer - to populatestopCharTester - to check if the end has been reached.@Deprecated default void parseUTF(@NotNull Appendable buffer, @NotNull StopCharTester stopCharTester)
default void parseUtf8(@NotNull
Appendable buffer,
@NotNull
StopCharsTester stopCharsTester)
throws BufferUnderflowException,
BufferOverflowException,
net.openhft.chronicle.core.io.IORuntimeException
buffer - to populatestopCharsTester - to check if the end has been reached.BufferUnderflowExceptionBufferOverflowExceptionnet.openhft.chronicle.core.io.IORuntimeException@Deprecated default void parseUTF(@NotNull Appendable buffer, @NotNull StopCharsTester stopCharsTester) throws BufferUnderflowException, BufferOverflowException, net.openhft.chronicle.core.io.IORuntimeException
BufferUnderflowExceptionBufferOverflowExceptionnet.openhft.chronicle.core.io.IORuntimeExceptiondefault void parse8bit(Appendable buffer, @NotNull StopCharTester stopCharTester) throws BufferUnderflowException, BufferOverflowException
buffer - to populatestopCharTester - to check if the end has been reached.BufferUnderflowExceptionBufferOverflowExceptiondefault void parse8bit(Appendable buffer, @NotNull StopCharsTester stopCharsTester) throws BufferUnderflowException, BufferOverflowException
buffer - to populatestopCharsTester - to check if the end has been reached.BufferUnderflowExceptionBufferOverflowExceptiondefault long parseLong()
throws BufferUnderflowException
BufferUnderflowExceptiondefault double parseDouble()
throws BufferUnderflowException
The number of decimal places can be retrieved with lastDecimalPlaces()
BufferUnderflowExceptiondefault long parseLongDecimal()
throws BufferUnderflowException
The number of decimal places can be retrieved with lastDecimalPlaces()
BufferUnderflowExceptionint lastDecimalPlaces()
void lastDecimalPlaces(int lastDecimalPlaces)
lastDecimalPlaces - set the number of decimal places if positive, otherwise 0.default boolean skipTo(@NotNull
StopCharTester tester)
tester - to stop at@NotNull default BigDecimal parseBigDecimal()
Copyright © 2017. All rights reserved.