public abstract class AbstractFixedByteArrayBuffer extends Object implements IFixedDataRecord
IByteArraySlice.array() and an appropriate constructor. This allows for
use cases where the backing byte[] is extensible. E.g., a fixed slice onto an
extensible ByteArrayBuffer.| Modifier | Constructor and Description |
|---|---|
protected |
AbstractFixedByteArrayBuffer(int off,
int len)
Protected constructor used to create a slice.
|
| Modifier and Type | Method and Description |
|---|---|
ByteBuffer |
asByteBuffer()
Wraps the data in the slice within a
ByteBuffer (does NOT copy
the data). |
void |
get(int srcoff,
byte[] dst)
Absolute bulk get copies
dst.length bytes from the
specified offset into the slice defined by this buffer into the caller's
array. |
void |
get(int srcoff,
byte[] dst,
int dstoff,
int dstlen)
Absolute bulk get copies the specified slice of bytes from this
buffer into the specified slice of the caller's array.
|
boolean |
getBit(long bitIndex)
Get the value of a bit.
|
byte |
getByte(int pos)
Absolute get for reading a byte value.
|
DataInputBuffer |
getDataInput()
Return an input stream that will read from the slice.
|
double |
getDouble(int pos) |
float |
getFloat(int pos) |
InputBitStream |
getInputBitStream()
Return a bit stream that will read from the slice.
|
int |
getInt(int pos) |
long |
getLong(int pos) |
short |
getShort(int pos) |
int |
len()
The length of the slice in the
IByteArraySlice.array(). |
int |
off()
The start of the slice in the
IByteArraySlice.array(). |
void |
put(int pos,
byte[] b)
Absolute bulk put copies all bytes in the caller's array into this
buffer starting at the specified position within the slice defined by
this buffer.
|
void |
put(int dstoff,
byte[] src,
int srcoff,
int srclen)
Absolute bulk put copies the specified slice of bytes from the
caller's array into this buffer starting at the specified position within
the slice defined by this buffer.
|
void |
putByte(int pos,
byte v)
Absolute put method for writing a byte value.
|
void |
putDouble(int pos,
double d) |
void |
putFloat(int pos,
float f) |
void |
putInt(int pos,
int v) |
void |
putLong(int pos,
long v) |
void |
putShort(int pos,
short v) |
protected boolean |
rangeCheck(int aoff,
int alen)
Verify that an operation starting at the specified offset into the slice
and having the specified length is valid against the slice.
|
boolean |
setBit(long bitIndex,
boolean value)
Set the value of a bit.
|
AbstractFixedByteArrayBuffer |
slice(int aoff,
int alen)
Return a slice of the backing buffer.
|
byte[] |
toByteArray()
Return a copy of the data in the slice.
|
static FixedByteArrayBuffer |
wrap(byte[] array)
A slice wrapping the entire array.
|
void |
writeOn(DataOutput out)
Write the slice on the output stream.
|
void |
writeOn(OutputStream os)
Write the slice on the output stream.
|
void |
writeOn(OutputStream os,
int aoff,
int alen)
Write part of the slice on the output stream.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitarrayprotected AbstractFixedByteArrayBuffer(int off,
int len)
off - The offset of the start of the slice.len - The length of the slice.public final int off()
IByteArraySliceIByteArraySlice.array().off in interface IByteArraySlicepublic final int len()
IByteArraySliceIByteArraySlice.array().
Note: IByteArraySlice.len() has different semantics for some
concrete implementations. ByteArrayBuffer.len() always returns
the capacity of the backing byte[] while ByteArrayBuffer.pos()
returns the #of bytes written onto the backing buffer. In contrast,
KeyBuilder.len() is always the #of bytes written onto the backing
buffer.len in interface IByteArraySlicepublic static FixedByteArrayBuffer wrap(byte[] array)
array - The array.protected boolean rangeCheck(int aoff,
int alen)
aoff - The offset into the slice.alen - The #of bytes to be addressed starting from that offset.true.IllegalArgumentException - if the operation is not valid.public final void put(int pos,
byte[] b)
IDataRecordput in interface IDataRecordpos - The starting position within the slice defined by this buffer.b - The source data.public final void put(int dstoff,
byte[] src,
int srcoff,
int srclen)
IDataRecordput in interface IDataRecorddstoff - The offset into the slice to which the data will be copied.src - The source data.srcoff - The offset of the 1st byte in the source data to be copied.srclen - The #of bytes to be copied.public final void get(int srcoff,
byte[] dst)
IDataRecorddst.length bytes from the
specified offset into the slice defined by this buffer into the caller's
array.get in interface IDataRecordsrcoff - The offset into the slice of the first byte to be copied.dst - The array into which the data will be copied.public final void get(int srcoff,
byte[] dst,
int dstoff,
int dstlen)
IDataRecordget in interface IDataRecordsrcoff - The offset into the slice defined by this buffer of the first
byte to be copied.dst - The array into which the data will be copied.dstoff - The offset of the first byte in that array onto which the data
will be copied.dstlen - The #of bytes to be copied.public final void putByte(int pos,
byte v)
IDataRecordputByte in interface IDataRecordpos - The offset into the slice.v - The value.public final byte getByte(int pos)
IDataRecordgetByte in interface IDataRecordpos - The offset into the slice.public final void putShort(int pos,
short v)
putShort in interface IDataRecordpublic final short getShort(int pos)
getShort in interface IDataRecordpublic final void putInt(int pos,
int v)
putInt in interface IDataRecordpublic final int getInt(int pos)
getInt in interface IDataRecordpublic final void putFloat(int pos,
float f)
putFloat in interface IDataRecordpublic final float getFloat(int pos)
getFloat in interface IDataRecordpublic final void putLong(int pos,
long v)
putLong in interface IDataRecordpublic final void putDouble(int pos,
double d)
putDouble in interface IDataRecordpublic final long getLong(int pos)
getLong in interface IDataRecordpublic final double getDouble(int pos)
getDouble in interface IDataRecordpublic final boolean getBit(long bitIndex)
IDataRecordgetBit in interface IDataRecordbitIndex - The index of the bit, counting from the first bit position in
the slice.public final boolean setBit(long bitIndex,
boolean value)
IDataRecordsetBit in interface IDataRecordbitIndex - The index of the bit, counting from the first bit position in
the slice.public final byte[] toByteArray()
IByteArraySlicetoByteArray in interface IByteArraySlicepublic final ByteBuffer asByteBuffer()
IDataRecordByteBuffer (does NOT copy
the data).asByteBuffer in interface IDataRecordByteBuffer encapsulating a reference to the data in the
slice.public AbstractFixedByteArrayBuffer slice(int aoff, int alen)
IDataRecordslice in interface IDataRecordaoff - The starting offset of the slice into this slice.alen - The #of bytes in the slice.public DataInputBuffer getDataInput()
IFixedDataRecordgetDataInput in interface IFixedDataRecordpublic InputBitStream getInputBitStream()
IFixedDataRecord
Note: You DO NOT need to close this stream since it is backed by a
byte[]. In fact, InputBitStream.close() when backed by a byte[]
appears to have relatively high overhead, which is weird.
getInputBitStream in interface IFixedDataRecordpublic final void writeOn(OutputStream os) throws IOException
IFixedDataRecordwriteOn in interface IFixedDataRecordos - The output stream.IOExceptionpublic final void writeOn(DataOutput out) throws IOException
IFixedDataRecordwriteOn in interface IFixedDataRecordIOExceptionpublic final void writeOn(OutputStream os, int aoff, int alen) throws IOException
IFixedDataRecordwriteOn in interface IFixedDataRecordos - The output stream.IOExceptionCopyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.