public interface Bytes<Underlying> extends BytesStore<Bytes<Underlying>,Underlying>, StreamingDataInput<Bytes<Underlying>>, StreamingDataOutput<Bytes<Underlying>>, ByteStringAppender<Bytes<Underlying>>, BytesPrepender<Bytes<Underlying>>
Modifier and Type | Field and Description |
---|---|
static long |
MAX_CAPACITY |
charToString
Modifier and Type | Method and Description |
---|---|
long |
address(long offset)
Obtain the underlying address.
|
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 ByteOrder |
byteOrder() |
default Bytes<Underlying> |
bytesForRead()
Creates a slice of the current Bytes based on its position() and limit().
|
BytesStore |
bytesStore() |
S |
clear()
Set the readPosition= writePosition = start, writeLimit = capacity
|
default boolean |
compareAndSwapDouble(long offset,
double expected,
double value)
Perform a 64-bit double CAS at a given offset.
|
default boolean |
compareAndSwapFloat(long offset,
float expected,
float value)
Perform a 32-bit float CAS at a given offset.
|
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<Underlying>,Underlying> |
copy() |
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 BytesStore |
empty() |
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 <B extends BytesStore<B,Underlying>,Underlying> |
expect(BytesStore<B,Underlying> bytesStore)
A Bytes suitable for writing to for testing purposes.
|
static Bytes<byte[]> |
expect(String text)
A Bytes suitable for writing to for testing purposes.
|
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) |
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 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 Reader |
reader()
Access these bytes as an ISO-8859-1 encoded Reader
|
default long |
readLimit() |
default long |
readPosition()
The read position must be start() <= readPosition() && readPosition() <= readLimit() && readPosition < safeLimit()
|
default long |
readRemaining() |
default long |
realCapacity() |
default long |
safeLimit() |
default boolean |
skipTo(StopCharTester tester)
Skip text until a terminating character is reached.
|
default long |
start() |
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 Bytes<Underlying> |
unchecked(boolean unchecked)
Return a Bytes which is optionally unchecked.
|
static Bytes<byte[]> |
wrapForRead(byte[] byteArray)
Wrap the byte[] ready for reading
|
static Bytes<ByteBuffer> |
wrapForRead(ByteBuffer byteBuffer) |
static Bytes<byte[]> |
wrapForRead(CharSequence text)
Deprecated.
|
static Bytes<byte[]> |
wrapForWrite(byte[] byteArray)
Wrap the byte[] ready for writing
|
static Bytes<ByteBuffer> |
wrapForWrite(ByteBuffer byteBuffer) |
default long |
writeLimit() |
default long |
writePosition()
The read position must be readPosition() <= writePosition() && writePosition() <= writeLimit()
|
default long |
writeRemaining() |
addAndGetByteNotAtomic, addAndGetDoubleNotAtomic, addAndGetFloatNotAtomic, addAndGetIntNotAtomic, addAndGetLongNotAtomic, addAndGetShortNotAtomic, addAndGetUnsignedByteNotAtomic, addAndGetUnsignedIntNotAtomic, addAndGetUnsignedShortNotAtomic, byteCheckSum, bytesForWrite, capacity, charAt, contentEquals, copyTo, copyTo, endsWith, equalBytes, inside, isNative, isPresent, isPresent, length, longCheckSum, nativePointer, startsWith, subSequence, to8bitString, toDebugString, toDebugString, underlyingObject, wrap, wrap, wrap, wrap, zeroOut
addAndGetDouble, addAndGetFloat, addAndGetInt, addAndGetLong, compareUtf8, copyTo, copyTo, createCharToString, findByte, nativeRead, parseLong, printable, read, readBoolean, readByte, readDouble, readFloat, readIncompleteLong, readInt, readLong, readShort, readUnsignedByte, readUnsignedInt, readUnsignedShort, readUtf8, readUtf8Limited, readUtf8Limited, readVolatileByte, readVolatileDouble, readVolatileFloat, readVolatileInt, readVolatileLong, readVolatileShort, subBytes, toByteArray, toTemporaryDirectByteBuffer
append, nativeWrite, write, write, write, write, write, writeBoolean, writeByte, writeByte, writeDouble, writeFloat, writeInt, writeLong, writeOrderedDouble, writeOrderedFloat, writeOrderedInt, writeOrderedLong, writeShort, writeUnsignedByte, writeUnsignedInt, writeUnsignedShort, writeUtf8, writeUtf8Limited, writeVolatileByte, writeVolatileDouble, writeVolatileFloat, writeVolatileInt, writeVolatileLong, writeVolatileShort
chars, codePoints, toString
inputStream, nativeRead, parseHexLong, parseUTF, parseUtf8, parseWithLength, peekUnsignedByte, read, read, read, read, read8bit, read8bit, read8bit, read8bit, readBoolean, readByte, readDouble, readEnum, readFloat, readInt, readLimit, readLong, readPosition, readShort, readSkip, readStopBit, readStopBitDouble, readUnsignedByte, readUnsignedInt, readUnsignedShort, readUtf8, readUtf8, readUTFΔ, readUTFΔ, readVolatileInt, readVolatileLong, readWithLength
append, append, append, append, append, append, append, append8bit, append8bit, appendDateMillis, appendDecimal, appendTimeMillis, writer
appendUtf8, appendUtf8, appendUtf8, appendUtf8, copyFrom, nativeWrite, outputStream, write, write, write, write, write, write, write, write8bit, write8bit, write8bit, write8bit, writeBoolean, writeByte, writeDouble, writeEnum, writeFloat, writeInt, writeLimit, writeLong, writeOrderedInt, writeOrderedLong, writePosition, writeShort, writeSkip, writeStopBit, writeStopBit, writeUnsignedByte, writeUnsignedInt, writeUnsignedShort, writeUtf8, writeUTFΔ
close, refCount, release, release, releaseAll, reserve, tryReserve
closeQuietly, notifyClosing
clearAndPad, prepend, prewrite, prewrite, prewriteByte, prewriteInt, prewriteLong, prewriteShort
static final long MAX_CAPACITY
static Bytes<ByteBuffer> elasticByteBuffer()
static Bytes<ByteBuffer> elasticByteBuffer(int initialCapacity, int maxSize)
static Bytes<ByteBuffer> elasticByteBuffer(int initialCapacity)
static Bytes<ByteBuffer> wrapForRead(ByteBuffer byteBuffer)
byteBuffer
- to readstatic Bytes<ByteBuffer> wrapForWrite(ByteBuffer byteBuffer)
byteBuffer
- to read@NotNull static Bytes<byte[]> expect(@NotNull String text)
text
- expected@NotNull static <B extends BytesStore<B,Underlying>,Underlying> Bytes<Underlying> expect(BytesStore<B,Underlying> bytesStore)
bytesStore
- expectedstatic Bytes<byte[]> wrapForRead(byte[] byteArray)
byteArray
- to wrapstatic Bytes<byte[]> wrapForWrite(byte[] byteArray)
byteArray
- to wrapstatic Bytes<byte[]> from(@NotNull CharSequence text) throws IllegalArgumentException, IllegalStateException
from
in interface BytesStore<Bytes<Underlying>,Underlying>
text
- to convertIllegalArgumentException
IllegalStateException
@Deprecated static Bytes<byte[]> wrapForRead(@NotNull CharSequence text) throws IllegalArgumentException, IllegalStateException
static VanillaBytes<Void> allocateDirect(long capacity) throws IllegalArgumentException
capacity
- minimum to allocateIllegalArgumentException
static NativeBytes<Void> allocateElasticDirect()
static NativeBytes<Void> allocateElasticDirect(long initialCapacity) throws IllegalArgumentException
IllegalArgumentException
static 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 limit
BufferUnderflowException
static 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 limit
BufferUnderflowException
static String toString(@NotNull Bytes buffer, long position, long len) throws BufferUnderflowException, net.openhft.chronicle.core.io.IORuntimeException
buffer
- the buffer to useposition
- the position to create the string fromlen
- the number of characters to show in the stringposition
BufferUnderflowException
net.openhft.chronicle.core.io.IORuntimeException
static BytesStore empty()
static Bytes allocateDirect(@NotNull byte[] bytes) throws IllegalArgumentException
bytes
- the bytes to wrapbytes
IllegalArgumentException
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 long safeLimit()
safeLimit
in interface BytesStore<Bytes<Underlying>,Underlying>
default boolean isClear()
BytesStore
isClear
in interface BytesStore<Bytes<Underlying>,Underlying>
default long realCapacity()
realCapacity
in interface BytesStore<Bytes<Underlying>,Underlying>
realCapacity
in interface RandomDataInput
BytesStore<Bytes<Underlying>,Underlying> copy()
copy
in interface BytesStore<Bytes<Underlying>,Underlying>
@NotNull default String toHexString() throws net.openhft.chronicle.core.io.IORuntimeException
Bytes
from the position() to the limit()net.openhft.chronicle.core.io.IORuntimeException
@NotNull default String toHexString(long maxLength) throws net.openhft.chronicle.core.io.IORuntimeException
Bytes
from the position() to the limit()maxLength
- limit the number of bytes to be dumped.net.openhft.chronicle.core.io.IORuntimeException
@NotNull default String toHexString(long offset, long maxLength) throws net.openhft.chronicle.core.io.IORuntimeException
Bytes
from the position() to the limit()maxLength
- limit the number of bytes to be dumped.net.openhft.chronicle.core.io.IORuntimeException
boolean isElastic()
default void ensureCapacity(long size) throws IllegalArgumentException, net.openhft.chronicle.core.io.IORuntimeException
BufferOverflowException
size
- the capacity that you requiredIllegalArgumentException
- if the buffer is not elastic and there is not enough spaceIORuntimeException
- if an error occured trying to resize the underlying buffer.net.openhft.chronicle.core.io.IORuntimeException
default Bytes<Underlying> bytesForRead() throws IllegalStateException
bytesForRead
in interface BytesStore<Bytes<Underlying>,Underlying>
IllegalStateException
- if the underlying BytesStore has been releasedBytesStore bytesStore()
bytesStore
in interface BytesStore<Bytes<Underlying>,Underlying>
default boolean isEqual(String s)
default Reader reader()
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.@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.BufferUnderflowException
BufferOverflowException
net.openhft.chronicle.core.io.IORuntimeException
@Deprecated default void parseUTF(@NotNull Appendable buffer, @NotNull StopCharsTester stopCharsTester) throws BufferUnderflowException, BufferOverflowException, net.openhft.chronicle.core.io.IORuntimeException
BufferUnderflowException
BufferOverflowException
net.openhft.chronicle.core.io.IORuntimeException
default void parse8bit(Appendable buffer, @NotNull StopCharTester stopCharTester) throws BufferUnderflowException, BufferOverflowException, net.openhft.chronicle.core.io.IORuntimeException
buffer
- to populatestopCharTester
- to check if the end has been reached.BufferUnderflowException
BufferOverflowException
net.openhft.chronicle.core.io.IORuntimeException
default void parse8bit(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.BufferUnderflowException
BufferOverflowException
net.openhft.chronicle.core.io.IORuntimeException
default long parseLong() throws BufferUnderflowException, net.openhft.chronicle.core.io.IORuntimeException
BufferUnderflowException
net.openhft.chronicle.core.io.IORuntimeException
default double parseDouble() throws BufferUnderflowException, net.openhft.chronicle.core.io.IORuntimeException
The number of decimal places can be retrieved with lastDecimalPlaces()
BufferUnderflowException
net.openhft.chronicle.core.io.IORuntimeException
default long parseLongDecimal() throws BufferUnderflowException
The number of decimal places can be retrieved with lastDecimalPlaces()
BufferUnderflowException
int lastDecimalPlaces()
void lastDecimalPlaces(int lastDecimalPlaces)
lastDecimalPlaces
- set the number of decimal places if positive, otherwise 0.default boolean skipTo(@NotNull StopCharTester tester) throws net.openhft.chronicle.core.io.IORuntimeException
tester
- to stop atnet.openhft.chronicle.core.io.IORuntimeException
@NotNull S clear()
default long start()
default long readPosition()
default long writePosition()
default long readRemaining()
default long writeRemaining()
default long readLimit()
default long writeLimit()
long address(long offset) throws UnsupportedOperationException, IllegalArgumentException
offset
- within this buffer. address(start()) is the actual address of the first byte.UnsupportedOperationException
- if the underlying buffer is on the heapIllegalArgumentException
- if the offset is before the start() or the after the capacity()default ByteOrder byteOrder()
boolean compareAndSwapInt(long offset, int expected, int value) throws BufferOverflowException, IllegalArgumentException, net.openhft.chronicle.core.io.IORuntimeException
offset
- to perform CASexpected
- valuevalue
- to setBufferOverflowException
IllegalArgumentException
net.openhft.chronicle.core.io.IORuntimeException
boolean compareAndSwapLong(long offset, long expected, long value) throws BufferOverflowException, IllegalArgumentException, net.openhft.chronicle.core.io.IORuntimeException
offset
- to perform CASexpected
- valuevalue
- to setBufferOverflowException
IllegalArgumentException
net.openhft.chronicle.core.io.IORuntimeException
default boolean compareAndSwapFloat(long offset, float expected, float value) throws BufferOverflowException, IllegalArgumentException, net.openhft.chronicle.core.io.IORuntimeException
offset
- to perform CASexpected
- valuevalue
- to setBufferOverflowException
IllegalArgumentException
net.openhft.chronicle.core.io.IORuntimeException
default boolean compareAndSwapDouble(long offset, double expected, double value) throws BufferOverflowException, IllegalArgumentException, net.openhft.chronicle.core.io.IORuntimeException
offset
- to perform CASexpected
- valuevalue
- to setBufferOverflowException
IllegalArgumentException
net.openhft.chronicle.core.io.IORuntimeException
Copyright © 2016. All rights reserved.