public abstract class AbstractReadBuffer extends Base implements ReadBuffer, HashEncoded
Modifier and Type | Class and Description |
---|---|
class |
AbstractReadBuffer.AbstractBufferInput
This is an implementation of the BufferInput interface that delegates
its work back to its ReadBuffer.
|
Base.LoggingWriter, Base.StackFrame
ReadBuffer.BufferInput
Modifier and Type | Field and Description |
---|---|
static Binary |
NO_BINARY
An empty Binary object.
|
static byte[] |
NO_BYTES
An empty byte array (by definition immutable).
|
LOG_ALWAYS, LOG_DEBUG, LOG_ERR, LOG_INFO, LOG_MAX, LOG_MIN, LOG_QUIET, LOG_WARN, POWER_0, POWER_G, POWER_K, POWER_M, POWER_T, UNIT_D, UNIT_H, UNIT_M, UNIT_MS, UNIT_NS, UNIT_S, UNIT_US
UNENCODED
Constructor and Description |
---|
AbstractReadBuffer() |
Modifier and Type | Method and Description |
---|---|
protected void |
checkBounds(int of,
int cb)
Check if the specified read is within bounds.
|
Object |
clone()
Create a clone of this ReadBuffer object.
|
boolean |
equals(Object o)
Compare two ReadBuffer objects for equality.
|
ReadBuffer.BufferInput |
getBufferInput()
Get a BufferInput object to read data from this buffer.
|
int |
getEncodedHash()
Return the encoded hash value or
HashEncoded.UNENCODED if absent. |
ReadBuffer |
getReadBuffer(int of,
int cb)
Obtain a ReadBuffer for a portion of this ReadBuffer.
|
protected abstract ReadBuffer.BufferInput |
instantiateBufferInput()
Factory method: Instantiate a BufferInput object to read data from the
ReadBuffer.
|
protected abstract ReadBuffer |
instantiateReadBuffer(int of,
int cb)
Factory method: Instantiate a ReadBuffer for a portion of this
ReadBuffer.
|
static int |
readPackedInt(ByteSequence bin,
int of)
Read an int value using a variable-length storage format as described
by
WriteBuffer.BufferOutput.writePackedInt(int) from the given
ByteSequence and offset. |
static int |
readUnsignedByte(ByteSequence bin,
int of)
Read an unsigned byte value from the given
ByteSequence and
offset. |
static int |
sizeofPackedInt(int n)
Return the number of bytes that would be required to store the given int
using the variable-length storage format as described by
WriteBuffer.BufferOutput.writePackedInt(int) . |
ByteSequence |
subSequence(int ofStart,
int ofEnd)
Returns a new
ByteSequence that is a subsequence of this
sequence. |
Binary |
toBinary()
Return a new Binary object that holds the complete contents of this
ReadBuffer.
|
Binary |
toBinary(int of,
int cb)
Return a Binary object that holds the specified portion of this
ReadBuffer.
|
byte[] |
toByteArray()
Get the contents of the ReadBuffer as a byte array.
|
byte[] |
toByteArray(int of,
int cb)
Get a portion of the contents of the ReadBuffer as a byte array.
|
azzert, azzert, azzert, azzertFailed, breakLines, breakLines, capitalize, checkNotEmpty, checkNotNull, checkRange, computeSafeWaitTime, decimalValue, dup, dup, ensureBigDecimal, ensureClassLoader, ensureRuntimeException, ensureRuntimeException, equals, equalsDeep, err, err, err, err, err, escape, formatDateTime, getCallerStackFrame, getCommonMonitor, getCommonMonitor, getCommonMonitor, getContextClassLoader, getContextClassLoader, getDeepMessage, getErr, getLastSafeTimeMillis, getLog, getMaxDecDigits, getMaxHexDigits, getOriginalException, getOut, getProcessRandom, getRandom, getRandomBinary, getRandomBinary, getRandomString, getSafeTimeMillis, getStackFrame, getStackFrames, getStackTrace, getStackTrace, getThreadFactory, getTimeZone, getUpTimeMillis, hashCode, hexValue, indentString, indentString, isDecimal, isHex, isLogEcho, isOctal, log, log, log, log, log, makeInteger, makeLong, makeThread, mod, mod, octalValue, out, out, out, out, out, pad, parseBandwidth, parseBandwidth, parseDelimitedString, parseHex, parseHex, parseMemorySize, parseMemorySize, parsePercentage, parseTime, parseTime, parseTimeNanos, parseTimeNanos, printStackTrace, randomize, randomize, randomize, randomize, read, read, read, read, read, read, read, replace, setErr, setLog, setLogEcho, setOut, sleep, toBandwidthString, toBandwidthString, toCharEscape, toCrc, toCrc, toCrc, toCrc, toCrc, toDecString, toDelimitedString, toDelimitedString, toDelimitedString, toDelimitedString, toHex, toHex, toHexDump, toHexEscape, toHexEscape, toHexEscape, toHexEscape, toHexString, toMemorySizeString, toMemorySizeString, toQuotedCharEscape, toQuotedStringEscape, toSqlString, toString, toString, toStringEscape, toUnicodeEscape, trace, trace, trace, trace, trace, trace, trace, trace, trace, truncateString, truncateString, wait
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
byteAt, copyBytes, length, toByteBuffer, toByteBuffer, writeTo, writeTo, writeTo, writeTo, writeTo, writeTo
public static final byte[] NO_BYTES
public static final Binary NO_BINARY
public ReadBuffer.BufferInput getBufferInput()
getBufferInput
in interface ReadBuffer
public ReadBuffer getReadBuffer(int of, int cb)
getReadBuffer
in interface ReadBuffer
of
- the beginning index, inclusivecb
- the number of bytes to include in the resulting ReadBufferpublic byte[] toByteArray()
This is the equivalent of toByteArray(0, length())
.
toByteArray
in interface ReadBuffer
public byte[] toByteArray(int of, int cb)
This method is an equivalent of
getReadBuffer(of, cb).toByteArray()
.
toByteArray
in interface ReadBuffer
of
- the beginning index, inclusivecb
- the number of bytes to include in the resulting byte[]public Binary toBinary()
This is the equivalent of toBinary(0, length())
.
toBinary
in interface ReadBuffer
toBinary
in interface ByteSequence
public Binary toBinary(int of, int cb)
This method is an equivalent of
getReadBuffer(of, cb).toBinary()
.
toBinary
in interface ReadBuffer
of
- the beginning index, inclusivecb
- the number of bytes to include in the Binary objectpublic ByteSequence subSequence(int ofStart, int ofEnd)
ByteSequence
that is a subsequence of this
sequence. The subsequence starts with the byte
value at the
specified index and ends with the byte
value at index
ofEnd - 1. The length (in byte
s) of the returned
sequence is ofEnd - ofStart, so if ofStart == ofEnd
then an empty sequence is returned.subSequence
in interface ReadBuffer
subSequence
in interface ByteSequence
ofStart
- the start index, inclusiveofEnd
- the end index, exclusivepublic int getEncodedHash()
HashEncoded.UNENCODED
if absent.getEncodedHash
in interface HashEncoded
HashEncoded.UNENCODED
if absentpublic boolean equals(Object o)
equals
in interface ReadBuffer
equals
in class Object
o
- a ReadBuffer objectpublic Object clone()
clone
in interface ReadBuffer
clone
in class Object
protected abstract ReadBuffer instantiateReadBuffer(int of, int cb)
of
- the beginning index, inclusivecb
- the number of bytes to include in the resulting ReadBufferprotected abstract ReadBuffer.BufferInput instantiateBufferInput()
protected void checkBounds(int of, int cb)
of
- the absolute offset of the read operationcb
- the length in bytes of the read operationIndexOutOfBoundsException
- if the specified read is not within
boundspublic static int readUnsignedByte(ByteSequence bin, int of)
ByteSequence
and
offset.
This method is the counterpart for the
DataOutput.writeByte(int)
method when it is used with
unsigned 8-bit values.
bin
- the byte sequenceof
- the offsetint
value in the range 0x00 to 0xFFpublic static int readPackedInt(ByteSequence bin, int of)
WriteBuffer.BufferOutput.writePackedInt(int)
from the given
ByteSequence
and offset.bin
- the byte sequenceof
- the offsetpublic static int sizeofPackedInt(int n)
WriteBuffer.BufferOutput.writePackedInt(int)
.n
- the integer that will be stored as a packed int