public class ByteBufferReadBuffer extends AbstractReadBuffer implements ReadBuffer
| Modifier and Type | Class and Description |
|---|---|
class |
ByteBufferReadBuffer.ByteBufferInput
This is a simple implementation of the BufferInput interface on top of a ByteBuffer.
|
AbstractReadBuffer.AbstractBufferInputBase.LoggingWriter, Base.StackFrameReadBuffer.BufferInputNO_BINARY, NO_BYTESLOG_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_USUNENCODED| Constructor and Description |
|---|
ByteBufferReadBuffer(ByteBuffer buf)
Construct a ByteBufferReadBuffer on an NIO ByteBuffer.
|
| Modifier and Type | Method and Description |
|---|---|
byte |
byteAt(int of)
Returns the byte at the specified offset.
|
Object |
clone()
Create a clone of this ReadBuffer object.
|
void |
copyBytes(int ofBegin, int ofEnd, byte[] abDest, int ofDest)
Copies bytes from this ReadBuffer into the destination byte array.
|
ByteBuffer |
getByteBuffer()
Obtain the ByteBuffer that this ReadBuffer is based on.
|
protected ReadBuffer.BufferInput |
instantiateBufferInput()
Factory method: Instantiate a BufferInput object to read data from the ReadBuffer.
|
protected ReadBuffer |
instantiateReadBuffer(int of, int cb)
Factory method: Instantiate a ReadBuffer for a portion of this ReadBuffer.
|
int |
length()
Determine the length of the buffer.
|
Binary |
toBinary(int of, int cb)
Return a Binary object that holds the specified portion of this ReadBuffer.
|
byte[] |
toByteArray(int of, int cb)
Get a portion of the contents of the ReadBuffer as a byte array.
|
ByteBuffer |
toByteBuffer()
Return a read-only ByteBuffer view of this ReadBuffer.
|
ByteBuffer |
toByteBuffer(int of, int cb)
Return a read-only ByteBuffer view of the specified portion of this ReadBuffer.
|
void |
writeTo(ByteBuffer buf)
Write the contents of the Binary object to a ByteBuffer.
|
void |
writeTo(ByteBuffer buf, int of, int cb)
Write the contents of the Binary object to a ByteBuffer.
|
void |
writeTo(DataOutput out)
Write the contents of this ReadBuffer to a DataOutput.
|
void |
writeTo(DataOutput out, int of, int cb)
Write the contents of this ReadBuffer to a DataOutput.
|
void |
writeTo(OutputStream out)
Write the contents of this ReadBuffer to an OutputStream.
|
void |
writeTo(OutputStream out, int of, int cb)
Write the contents of the ReadBuffer to an OutputStream.
|
checkBounds, equals, getBufferInput, getEncodedHash, getReadBuffer, readPackedInt, readUnsignedByte, sizeofPackedInt, subSequence, toBinary, toByteArrayazzert, 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, 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, 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, waitfinalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitequals, getBufferInput, getReadBuffer, subSequence, toBinary, toByteArraypublic ByteBufferReadBuffer(ByteBuffer buf)
buf - the underlying NIO ByteBufferpublic ByteBuffer getByteBuffer()
public void writeTo(OutputStream out) throws IOException
writeTo in interface ReadBufferout - an OutputStream to write toIOException - if an I/O exception occurspublic void writeTo(OutputStream out, int of, int cb) throws IOException
writeTo in interface ReadBufferout - an OutputStream to write toof - the beginning index, inclusivecb - the number of bytes to write to an OutputStreamIOException - if an I/O exception occurspublic void writeTo(DataOutput out) throws IOException
writeTo in interface ReadBufferout - a DataOutput to write toIOException - if an I/O exception occurspublic void writeTo(DataOutput out, int of, int cb) throws IOException
writeTo in interface ReadBufferout - a DataOutput to write toof - the beginning index, inclusivecb - the number of bytes to write to a DataOutputIOException - if an I/O exception occurspublic void writeTo(ByteBuffer buf)
writeTo in interface ReadBufferbuf - a ByteBuffer to write topublic void writeTo(ByteBuffer buf, int of, int cb) throws IOException
writeTo in interface ReadBufferbuf - an ByteBuffer to write toof - the beginning index, inclusivecb - the number of bytes to write to a ByteBufferIOException - if an I/O exception occurspublic int length()
length in interface ReadBufferlength in interface ByteSequencepublic byte byteAt(int of)
0 to length() - 1. The first byte of the sequence is at offset 0, the next at offset 1, and so on, as for array indexing.byteAt in interface ReadBufferbyteAt in interface ByteSequenceof - the offset (index) of the byte
public void copyBytes(int ofBegin,
int ofEnd,
byte[] abDest,
int ofDest)
The first byte to be copied is at offset ofBegin; the last byte to be copied is at offset ofEnd-1 (thus the total number of bytes to be copied is ofEnd - ofBegin). The bytes are copied into the sub-array of abDest starting at offset ofDest and ending at index:
ofDest + (ofEnd - ofBegin) - 1
This method is the ReadBuffer equivalent of String.getChars(int, int, char[], int). It allows the caller to extract a chunk of bytes into the caller's own array.
copyBytes in interface ReadBufferofBegin - offset of the first byte in the ReadBuffer to copyofEnd - offset after the last byte in the ReadBuffer to copyabDest - the destination byte arrayofDest - the offset in the destination byte array to copy the first byte to
public byte[] toByteArray(int of,
int cb)
This method is an equivalent of getReadBuffer(of, cb).toByteArray().
toByteArray in interface ReadBuffertoByteArray in class AbstractReadBufferof - the beginning index, inclusivecb - the number of bytes to include in the resulting byte[]public Binary toBinary(int of, int cb)
This method is an equivalent of getReadBuffer(of, cb).toBinary().
toBinary in interface ReadBuffertoBinary in class AbstractReadBufferof - the beginning index, inclusivecb - the number of bytes to include in the Binary objectpublic ByteBuffer toByteBuffer()
toByteBuffer in interface ReadBufferpublic ByteBuffer toByteBuffer(int of, int cb)
This method is an equivalent of getReadBuffer(of, cb).toByteBuffer().
toByteBuffer in interface ReadBufferof - the beginning index, inclusivecb - the number of bytes to include in the ByteBuffer objectpublic Object clone()
clone in interface ReadBufferclone in class AbstractReadBufferprotected ReadBuffer instantiateReadBuffer(int of, int cb)
instantiateReadBuffer in class AbstractReadBufferof - the beginning index, inclusivecb - the number of bytes to include in the resulting ReadBufferprotected ReadBuffer.BufferInput instantiateBufferInput()
instantiateBufferInput in class AbstractReadBuffer