Package org.lmdbjava
Class ByteArrayProxy
- java.lang.Object
-
- org.lmdbjava.BufferProxy<byte[]>
-
- org.lmdbjava.ByteArrayProxy
-
public final class ByteArrayProxy extends BufferProxy<byte[]>
Byte array proxy.Env.create(org.lmdbjava.BufferProxy)
.
-
-
Field Summary
Fields Modifier and Type Field Description static BufferProxy<byte[]>
PROXY_BA
The byte array proxy.-
Fields inherited from class org.lmdbjava.BufferProxy
MDB_VAL_STRUCT_SIZE, STRUCT_FIELD_OFFSET_DATA, STRUCT_FIELD_OFFSET_SIZE
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected byte[]
allocate()
Allocate a new buffer suitable for passing toBufferProxy.out(java.lang.Object, jnr.ffi.Pointer, long)
.protected int
compare(byte[] o1, byte[] o2)
Compare the two buffers.static int
compareArrays(byte[] o1, byte[] o2)
Lexicographically compare two byte arrays.protected void
deallocate(byte[] buff)
Deallocate a buffer that was previously provided byBufferProxy.allocate()
.protected byte[]
getBytes(byte[] buffer)
Obtain a copy of the bytes contained within the passed buffer.protected void
in(byte[] buffer, int size, jnr.ffi.Pointer ptr, long ptrAddr)
Called when theMDB_val
should be set to reflect the passed buffer.protected void
in(byte[] buffer, jnr.ffi.Pointer ptr, long ptrAddr)
Called when theMDB_val
should be set to reflect the passed buffer.protected byte[]
out(byte[] buffer, jnr.ffi.Pointer ptr, long ptrAddr)
Called when theMDB_val
may have changed and the passed buffer should be modified to reflect the newMDB_val
.
-
-
-
Field Detail
-
PROXY_BA
public static final BufferProxy<byte[]> PROXY_BA
The byte array proxy. Guaranteed to never be null.
-
-
Method Detail
-
compareArrays
public static int compareArrays(byte[] o1, byte[] o2)
Lexicographically compare two byte arrays.- Parameters:
o1
- left operand (required)o2
- right operand (required)- Returns:
- as specified by
Comparable
interface
-
allocate
protected byte[] allocate()
Description copied from class:BufferProxy
Allocate a new buffer suitable for passing toBufferProxy.out(java.lang.Object, jnr.ffi.Pointer, long)
.- Specified by:
allocate
in classBufferProxy<byte[]>
- Returns:
- a buffer for passing to the
out
method
-
compare
protected int compare(byte[] o1, byte[] o2)
Description copied from class:BufferProxy
Compare the two buffers.Implemented as a protected method to discourage use of the buffer proxy in collections etc (given by design it wraps a temporary value only).
- Specified by:
compare
in classBufferProxy<byte[]>
- Parameters:
o1
- left operando2
- right operand- Returns:
- as per
Comparable
-
deallocate
protected void deallocate(byte[] buff)
Description copied from class:BufferProxy
Deallocate a buffer that was previously provided byBufferProxy.allocate()
.- Specified by:
deallocate
in classBufferProxy<byte[]>
- Parameters:
buff
- the buffer to deallocate (required)
-
getBytes
protected byte[] getBytes(byte[] buffer)
Description copied from class:BufferProxy
Obtain a copy of the bytes contained within the passed buffer.- Specified by:
getBytes
in classBufferProxy<byte[]>
- Parameters:
buffer
- a non-null buffer created by this proxy instance- Returns:
- a copy of the bytes this buffer is currently representing
-
in
protected void in(byte[] buffer, jnr.ffi.Pointer ptr, long ptrAddr)
Description copied from class:BufferProxy
Called when theMDB_val
should be set to reflect the passed buffer. This buffer will have been created by end users, notBufferProxy.allocate()
.- Specified by:
in
in classBufferProxy<byte[]>
- Parameters:
buffer
- the buffer to write toMDB_val
ptr
- the pointer to theMDB_val
ptrAddr
- the address of theMDB_val
pointer
-
in
protected void in(byte[] buffer, int size, jnr.ffi.Pointer ptr, long ptrAddr)
Description copied from class:BufferProxy
Called when theMDB_val
should be set to reflect the passed buffer.- Specified by:
in
in classBufferProxy<byte[]>
- Parameters:
buffer
- the buffer to write toMDB_val
size
- the buffer size to write toMDB_val
ptr
- the pointer to theMDB_val
ptrAddr
- the address of theMDB_val
pointer
-
out
protected byte[] out(byte[] buffer, jnr.ffi.Pointer ptr, long ptrAddr)
Description copied from class:BufferProxy
Called when theMDB_val
may have changed and the passed buffer should be modified to reflect the newMDB_val
.- Specified by:
out
in classBufferProxy<byte[]>
- Parameters:
buffer
- the buffer to write toMDB_val
ptr
- the pointer to theMDB_val
ptrAddr
- the address of theMDB_val
pointer- Returns:
- the buffer for
MDB_val
-
-