public class ByteBufferAccessor extends java.lang.Object implements ValueAccessor<java.nio.ByteBuffer>
Buffer.position()
as index 0,
and Buffer.remaining()
as the length.ValueAccessor.ObjectFactory<V>
Modifier and Type | Field and Description |
---|---|
static ValueAccessor<java.nio.ByteBuffer> |
instance |
Modifier and Type | Method and Description |
---|---|
java.nio.ByteBuffer |
allocate(int size)
Allocate and return a instance of bytes on the heap.
|
<V2> int |
compare(java.nio.ByteBuffer left,
V2 right,
ValueAccessor<V2> accessorR)
lexicographically compare to
|
int |
compareByteArrayTo(byte[] left,
java.nio.ByteBuffer right)
compare a byte array on the left with a on the right}
|
int |
compareByteBufferTo(java.nio.ByteBuffer left,
java.nio.ByteBuffer right)
compare a byte buffer on the left with a on the right}
|
<V2> java.nio.ByteBuffer |
convert(V2 src,
ValueAccessor<V2> accessor)
Convert the data in to
and the returned value may share a common byte array instance, so caller should
assume that modifying the returned value will also modify the contents of
|
int |
copyByteArrayTo(byte[] src,
int srcOffset,
java.nio.ByteBuffer dst,
int dstOffset,
int size)
copies a byte array into this accessors value.
|
int |
copyByteBufferTo(java.nio.ByteBuffer src,
int srcOffset,
java.nio.ByteBuffer dst,
int dstOffset,
int size)
copies a byte buffer into this accessors value.
|
<V2> int |
copyTo(java.nio.ByteBuffer src,
int srcOffset,
V2 dst,
ValueAccessor<V2> dstAccessor,
int dstOffset,
int size)
copy the bytes from the value, starting at the offset into
the value, starting at the offset , using the accessor
|
java.nio.ByteBuffer[] |
createArray(int length)
allocate an instance of the accessors backing type
|
void |
digest(java.nio.ByteBuffer value,
int offset,
int size,
Digest digest)
updates with bytes from the contents of starting
at offset
|
java.nio.ByteBuffer |
empty()
return a value with a length of 0
|
ValueAccessor.ObjectFactory<java.nio.ByteBuffer> |
factory()
returns the
ValueAccessor.ObjectFactory for the backing type |
byte |
getByte(java.nio.ByteBuffer value,
int offset)
returns a byte from offset
|
int |
getInt(java.nio.ByteBuffer value,
int offset)
returns an int from offset
|
long |
getLong(java.nio.ByteBuffer value,
int offset)
returns a long from offset
|
short |
getShort(java.nio.ByteBuffer value,
int offset)
returns a short from offset
|
int |
getUnsignedShort(java.nio.ByteBuffer value,
int offset)
returns an unsigned short from offset
|
int |
putByte(java.nio.ByteBuffer dst,
int offset,
byte value)
writes the byte value to at offset
|
int |
putInt(java.nio.ByteBuffer dst,
int offset,
int value)
writes the int value to at offset
|
int |
putLong(java.nio.ByteBuffer dst,
int offset,
long value)
writes the long value to at offset
|
int |
putShort(java.nio.ByteBuffer dst,
int offset,
short value)
writes the short value to at offset
|
java.nio.ByteBuffer |
read(DataInputPlus in,
int length)
Reads a value of bytes from
|
int |
size(java.nio.ByteBuffer value) |
java.nio.ByteBuffer |
slice(java.nio.ByteBuffer input,
int offset,
int length)
Returns a value with the contents of from to .
|
byte[] |
toArray(java.nio.ByteBuffer value)
returns a byte[] with the contents of
Depending on the accessor implementation, this method may:
* allocate a new byte[] object and copy data into it
* return the value, if the backing type is byte[]
|
byte[] |
toArray(java.nio.ByteBuffer value,
int offset,
int length)
returns a byte[] with bytes copied from the contents of
starting at offset .
|
java.nio.ByteBuffer |
toBuffer(java.nio.ByteBuffer value)
returns a ByteBuffer with the contents of
Depending on the accessor implementation, this method may:
* allocate a new ByteBuffer and copy data into it
* return the value, if the backing type is a bytebuffer
|
byte |
toByte(java.nio.ByteBuffer value)
returns a byte from offset 0
|
double |
toDouble(java.nio.ByteBuffer value)
returns a double from offset 0
|
float |
toFloat(java.nio.ByteBuffer value)
returns a float from offset 0
|
java.lang.String |
toHex(java.nio.ByteBuffer value) |
int |
toInt(java.nio.ByteBuffer value)
returns an int from offset 0
|
long |
toLong(java.nio.ByteBuffer value)
returns a long from offset 0
|
short |
toShort(java.nio.ByteBuffer value)
returns a short from offset 0
|
java.lang.String |
toString(java.nio.ByteBuffer value,
java.nio.charset.Charset charset) |
java.util.UUID |
toUUID(java.nio.ByteBuffer value)
returns a UUID from offset 0
|
java.nio.ByteBuffer |
valueOf(boolean v)
return a value with the bytes from
|
java.nio.ByteBuffer |
valueOf(byte v)
return a value with the bytes from
|
java.nio.ByteBuffer |
valueOf(byte[] bytes)
return a value containing the
Caller should assume that modifying the returned value
will also modify the contents of
|
java.nio.ByteBuffer |
valueOf(java.nio.ByteBuffer bytes)
return a value containing the
and the returned value may share a common byte array instance, so caller should
assume that modifying the returned value will also modify the contents of
|
java.nio.ByteBuffer |
valueOf(double v)
return a value with the bytes from
|
java.nio.ByteBuffer |
valueOf(float v)
return a value with the bytes from
|
java.nio.ByteBuffer |
valueOf(int v)
return a value with the bytes from
|
java.nio.ByteBuffer |
valueOf(long v)
return a value with the bytes from
|
java.nio.ByteBuffer |
valueOf(short v)
return a value with the bytes from
|
java.nio.ByteBuffer |
valueOf(java.lang.String v,
java.nio.charset.Charset charset)
return a value containing the bytes for the given string and charset
|
java.nio.ByteBuffer |
valueOf(java.util.UUID v)
return a value with the bytes from
|
void |
write(java.nio.ByteBuffer value,
java.nio.ByteBuffer out)
Write the contents of the given value into the ByteBuffer
|
void |
write(java.nio.ByteBuffer value,
DataOutputPlus out)
Write the contents of the given value into the a DataOutputPlus
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
compare, digest, equals, getBoolean, hashCode, isEmpty, isEmptyFromOffset, sizeFromOffset, sizeWithShortLength, sizeWithVIntLength, sliceWithShortLength, toString, writeWithVIntLength
public static final ValueAccessor<java.nio.ByteBuffer> instance
public int size(java.nio.ByteBuffer value)
size
in interface ValueAccessor<java.nio.ByteBuffer>
public java.nio.ByteBuffer[] createArray(int length)
ValueAccessor
createArray
in interface ValueAccessor<java.nio.ByteBuffer>
length
- size of backing typ to allocatepublic void write(java.nio.ByteBuffer value, DataOutputPlus out) throws java.io.IOException
ValueAccessor
write
in interface ValueAccessor<java.nio.ByteBuffer>
java.io.IOException
public void write(java.nio.ByteBuffer value, java.nio.ByteBuffer out)
ValueAccessor
write
in interface ValueAccessor<java.nio.ByteBuffer>
public <V2> int copyTo(java.nio.ByteBuffer src, int srcOffset, V2 dst, ValueAccessor<V2> dstAccessor, int dstOffset, int size)
ValueAccessor
copyTo
in interface ValueAccessor<java.nio.ByteBuffer>
V2
- the destination value typepublic int copyByteArrayTo(byte[] src, int srcOffset, java.nio.ByteBuffer dst, int dstOffset, int size)
ValueAccessor
copyByteArrayTo
in interface ValueAccessor<java.nio.ByteBuffer>
public int copyByteBufferTo(java.nio.ByteBuffer src, int srcOffset, java.nio.ByteBuffer dst, int dstOffset, int size)
ValueAccessor
copyByteBufferTo
in interface ValueAccessor<java.nio.ByteBuffer>
public void digest(java.nio.ByteBuffer value, int offset, int size, Digest digest)
ValueAccessor
digest
in interface ValueAccessor<java.nio.ByteBuffer>
public java.nio.ByteBuffer read(DataInputPlus in, int length) throws java.io.IOException
ValueAccessor
read
in interface ValueAccessor<java.nio.ByteBuffer>
java.io.IOException
public java.nio.ByteBuffer slice(java.nio.ByteBuffer input, int offset, int length)
ValueAccessor
slice
in interface ValueAccessor<java.nio.ByteBuffer>
public <V2> int compare(java.nio.ByteBuffer left, V2 right, ValueAccessor<V2> accessorR)
ValueAccessor
compare
in interface ValueAccessor<java.nio.ByteBuffer>
V2
- backing type ofpublic int compareByteArrayTo(byte[] left, java.nio.ByteBuffer right)
ValueAccessor
compareByteArrayTo
in interface ValueAccessor<java.nio.ByteBuffer>
public int compareByteBufferTo(java.nio.ByteBuffer left, java.nio.ByteBuffer right)
ValueAccessor
compareByteBufferTo
in interface ValueAccessor<java.nio.ByteBuffer>
public java.nio.ByteBuffer toBuffer(java.nio.ByteBuffer value)
ValueAccessor
toBuffer
in interface ValueAccessor<java.nio.ByteBuffer>
public byte[] toArray(java.nio.ByteBuffer value)
ValueAccessor
toArray
in interface ValueAccessor<java.nio.ByteBuffer>
public byte[] toArray(java.nio.ByteBuffer value, int offset, int length)
ValueAccessor
toArray
in interface ValueAccessor<java.nio.ByteBuffer>
public java.lang.String toString(java.nio.ByteBuffer value, java.nio.charset.Charset charset) throws java.nio.charset.CharacterCodingException
toString
in interface ValueAccessor<java.nio.ByteBuffer>
java.nio.charset.CharacterCodingException
public java.nio.ByteBuffer valueOf(java.util.UUID v)
ValueAccessor
valueOf
in interface ValueAccessor<java.nio.ByteBuffer>
public java.lang.String toHex(java.nio.ByteBuffer value)
toHex
in interface ValueAccessor<java.nio.ByteBuffer>
public byte toByte(java.nio.ByteBuffer value)
ValueAccessor
toByte
in interface ValueAccessor<java.nio.ByteBuffer>
public byte getByte(java.nio.ByteBuffer value, int offset)
ValueAccessor
getByte
in interface ValueAccessor<java.nio.ByteBuffer>
public short toShort(java.nio.ByteBuffer value)
ValueAccessor
toShort
in interface ValueAccessor<java.nio.ByteBuffer>
public short getShort(java.nio.ByteBuffer value, int offset)
ValueAccessor
getShort
in interface ValueAccessor<java.nio.ByteBuffer>
public int getUnsignedShort(java.nio.ByteBuffer value, int offset)
ValueAccessor
getUnsignedShort
in interface ValueAccessor<java.nio.ByteBuffer>
public int toInt(java.nio.ByteBuffer value)
ValueAccessor
toInt
in interface ValueAccessor<java.nio.ByteBuffer>
public int getInt(java.nio.ByteBuffer value, int offset)
ValueAccessor
getInt
in interface ValueAccessor<java.nio.ByteBuffer>
public long toLong(java.nio.ByteBuffer value)
ValueAccessor
toLong
in interface ValueAccessor<java.nio.ByteBuffer>
public long getLong(java.nio.ByteBuffer value, int offset)
ValueAccessor
getLong
in interface ValueAccessor<java.nio.ByteBuffer>
public float toFloat(java.nio.ByteBuffer value)
ValueAccessor
toFloat
in interface ValueAccessor<java.nio.ByteBuffer>
public double toDouble(java.nio.ByteBuffer value)
ValueAccessor
toDouble
in interface ValueAccessor<java.nio.ByteBuffer>
public java.util.UUID toUUID(java.nio.ByteBuffer value)
ValueAccessor
toUUID
in interface ValueAccessor<java.nio.ByteBuffer>
public int putByte(java.nio.ByteBuffer dst, int offset, byte value)
ValueAccessor
putByte
in interface ValueAccessor<java.nio.ByteBuffer>
public int putShort(java.nio.ByteBuffer dst, int offset, short value)
ValueAccessor
putShort
in interface ValueAccessor<java.nio.ByteBuffer>
public int putInt(java.nio.ByteBuffer dst, int offset, int value)
ValueAccessor
putInt
in interface ValueAccessor<java.nio.ByteBuffer>
public int putLong(java.nio.ByteBuffer dst, int offset, long value)
ValueAccessor
putLong
in interface ValueAccessor<java.nio.ByteBuffer>
public java.nio.ByteBuffer empty()
ValueAccessor
empty
in interface ValueAccessor<java.nio.ByteBuffer>
public java.nio.ByteBuffer valueOf(byte[] bytes)
ValueAccessor
valueOf
in interface ValueAccessor<java.nio.ByteBuffer>
public java.nio.ByteBuffer valueOf(java.nio.ByteBuffer bytes)
ValueAccessor
valueOf
in interface ValueAccessor<java.nio.ByteBuffer>
public java.nio.ByteBuffer valueOf(java.lang.String v, java.nio.charset.Charset charset)
ValueAccessor
valueOf
in interface ValueAccessor<java.nio.ByteBuffer>
public java.nio.ByteBuffer valueOf(boolean v)
ValueAccessor
valueOf
in interface ValueAccessor<java.nio.ByteBuffer>
public java.nio.ByteBuffer valueOf(byte v)
ValueAccessor
valueOf
in interface ValueAccessor<java.nio.ByteBuffer>
public java.nio.ByteBuffer valueOf(short v)
ValueAccessor
valueOf
in interface ValueAccessor<java.nio.ByteBuffer>
public java.nio.ByteBuffer valueOf(int v)
ValueAccessor
valueOf
in interface ValueAccessor<java.nio.ByteBuffer>
public java.nio.ByteBuffer valueOf(long v)
ValueAccessor
valueOf
in interface ValueAccessor<java.nio.ByteBuffer>
public java.nio.ByteBuffer valueOf(float v)
ValueAccessor
valueOf
in interface ValueAccessor<java.nio.ByteBuffer>
public java.nio.ByteBuffer valueOf(double v)
ValueAccessor
valueOf
in interface ValueAccessor<java.nio.ByteBuffer>
public <V2> java.nio.ByteBuffer convert(V2 src, ValueAccessor<V2> accessor)
ValueAccessor
convert
in interface ValueAccessor<java.nio.ByteBuffer>
public java.nio.ByteBuffer allocate(int size)
ValueAccessor
allocate
in interface ValueAccessor<java.nio.ByteBuffer>
public ValueAccessor.ObjectFactory<java.nio.ByteBuffer> factory()
ValueAccessor
ValueAccessor.ObjectFactory
for the backing type factory
in interface ValueAccessor<java.nio.ByteBuffer>
Copyright © 2009- The Apache Software Foundation