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, wait
array
protected AbstractFixedByteArrayBuffer(int off, int len)
off
- The offset of the start of the slice.len
- The length of the slice.public final int off()
IByteArraySlice
IByteArraySlice.array()
.off
in interface IByteArraySlice
public final int len()
IByteArraySlice
IByteArraySlice.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 IByteArraySlice
public 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)
IDataRecord
put
in interface IDataRecord
pos
- 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)
IDataRecord
put
in interface IDataRecord
dstoff
- 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)
IDataRecord
dst.length
bytes from the
specified offset into the slice defined by this buffer into the caller's
array.get
in interface IDataRecord
srcoff
- 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)
IDataRecord
get
in interface IDataRecord
srcoff
- 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)
IDataRecord
putByte
in interface IDataRecord
pos
- The offset into the slice.v
- The value.public final byte getByte(int pos)
IDataRecord
getByte
in interface IDataRecord
pos
- The offset into the slice.public final void putShort(int pos, short v)
putShort
in interface IDataRecord
public final short getShort(int pos)
getShort
in interface IDataRecord
public final void putInt(int pos, int v)
putInt
in interface IDataRecord
public final int getInt(int pos)
getInt
in interface IDataRecord
public final void putFloat(int pos, float f)
putFloat
in interface IDataRecord
public final float getFloat(int pos)
getFloat
in interface IDataRecord
public final void putLong(int pos, long v)
putLong
in interface IDataRecord
public final void putDouble(int pos, double d)
putDouble
in interface IDataRecord
public final long getLong(int pos)
getLong
in interface IDataRecord
public final double getDouble(int pos)
getDouble
in interface IDataRecord
public final boolean getBit(long bitIndex)
IDataRecord
getBit
in interface IDataRecord
bitIndex
- The index of the bit, counting from the first bit position in
the slice.public final boolean setBit(long bitIndex, boolean value)
IDataRecord
setBit
in interface IDataRecord
bitIndex
- The index of the bit, counting from the first bit position in
the slice.public final byte[] toByteArray()
IByteArraySlice
toByteArray
in interface IByteArraySlice
public final ByteBuffer asByteBuffer()
IDataRecord
ByteBuffer
(does NOT copy
the data).asByteBuffer
in interface IDataRecord
ByteBuffer
encapsulating a reference to the data in the
slice.public AbstractFixedByteArrayBuffer slice(int aoff, int alen)
IDataRecord
slice
in interface IDataRecord
aoff
- The starting offset of the slice into this slice.alen
- The #of bytes in the slice.public DataInputBuffer getDataInput()
IFixedDataRecord
getDataInput
in interface IFixedDataRecord
public 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 IFixedDataRecord
public final void writeOn(OutputStream os) throws IOException
IFixedDataRecord
writeOn
in interface IFixedDataRecord
os
- The output stream.IOException
public final void writeOn(DataOutput out) throws IOException
IFixedDataRecord
writeOn
in interface IFixedDataRecord
IOException
public final void writeOn(OutputStream os, int aoff, int alen) throws IOException
IFixedDataRecord
writeOn
in interface IFixedDataRecord
os
- The output stream.IOException
Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.