1515 */
1616package org .lmdbjava ;
1717
18- import jnr .ffi .Pointer ;
19-
20- import java .util .Comparator ;
21-
2218import static java .lang .Long .BYTES ;
2319import static org .lmdbjava .DbiFlags .MDB_INTEGERKEY ;
2420import static org .lmdbjava .DbiFlags .MDB_UNSIGNEDKEY ;
2521import static org .lmdbjava .MaskedFlag .isSet ;
2622import static org .lmdbjava .MaskedFlag .mask ;
2723
24+ import java .util .Comparator ;
25+ import jnr .ffi .Pointer ;
26+
2827/**
2928 * The strategy for mapping memory address to a given buffer type.
3029 *
3635 */
3736public abstract class BufferProxy <T > {
3837
39- /**
40- * Size of a <code>MDB_val</code> pointer in bytes.
41- */
38+ /** Size of a <code>MDB_val</code> pointer in bytes. */
4239protected static final int MDB_VAL_STRUCT_SIZE =BYTES *2 ;
4340
44- /**
45- * Offset from a pointer of the <code>MDB_val.mv_data</code> field.
46- */
41+ /** Offset from a pointer of the <code>MDB_val.mv_data</code> field. */
4742protected static final int STRUCT_FIELD_OFFSET_DATA =BYTES ;
4843
49- /**
50- * Offset from a pointer of the <code>MDB_val.mv_size</code> field.
51- */
44+ /** Offset from a pointer of the <code>MDB_val.mv_size</code> field. */
5245protected static final int STRUCT_FIELD_OFFSET_SIZE =0 ;
5346
54- /**
55- * Explicitly-defined default constructor to avoid warnings.
56- */
57- protected BufferProxy () {
58- }
47+ /** Explicitly-defined default constructor to avoid warnings. */
48+ protected BufferProxy () {}
5949
6050/**
6151 * Allocate a new buffer suitable for passing to {@link #out(java.lang.Object, jnr.ffi.Pointer)}.
@@ -92,8 +82,8 @@ protected Comparator<T> getComparator(DbiFlags... flags) {
9282final int intFlag =mask (flags );
9383
9484return isSet (intFlag ,MDB_INTEGERKEY ) ||isSet (intFlag ,MDB_UNSIGNEDKEY )
95- ?getUnsignedComparator ()
96- :getSignedComparator ();
85+ ?getUnsignedComparator ()
86+ :getSignedComparator ();
9787 }
9888
9989/**
@@ -115,7 +105,7 @@ protected Comparator<T> getComparator(DbiFlags... flags) {
115105 * will have been created by end users, not {@link #allocate()}.
116106 *
117107 * @param buffer the buffer to write to <code>MDB_val</code>
118- * @param ptr the pointer to the <code>MDB_val</code>
108+ * @param ptr the pointer to the <code>MDB_val</code>
119109 * @return a transient pointer that must be kept alive, or null if none
120110 */
121111protected abstract Pointer in (T buffer ,Pointer ptr );
@@ -124,8 +114,8 @@ protected Comparator<T> getComparator(DbiFlags... flags) {
124114 * Called when the <code>MDB_val</code> should be set to reflect the passed buffer.
125115 *
126116 * @param buffer the buffer to write to <code>MDB_val</code>
127- * @param size the buffer size to write to <code>MDB_val</code>
128- * @param ptr the pointer to the <code>MDB_val</code>
117+ * @param size the buffer size to write to <code>MDB_val</code>
118+ * @param ptr the pointer to the <code>MDB_val</code>
129119 * @return a transient pointer that must be kept alive, or null if none
130120 */
131121protected abstract Pointer in (T buffer ,int size ,Pointer ptr );
@@ -135,7 +125,7 @@ protected Comparator<T> getComparator(DbiFlags... flags) {
135125 * to reflect the new <code>MDB_val</code>.
136126 *
137127 * @param buffer the buffer to write to <code>MDB_val</code>
138- * @param ptr the pointer to the <code>MDB_val</code>
128+ * @param ptr the pointer to the <code>MDB_val</code>
139129 * @return the buffer for <code>MDB_val</code>
140130 */
141131protected abstract T out (T buffer ,Pointer ptr );
@@ -152,15 +142,16 @@ final KeyVal<T> keyVal() {
152142/**
153143 * Test if a supplied buffer contains the supplied prefix buffer.
154144 *
155- * @param buffer The buffer to test.
145+ * @param buffer The buffer to test.
156146 * @param prefixBuffer The prefix to find.
157147 * @return True if the key contains the prefix;
158148 */
159149abstract boolean containsPrefix (T buffer ,T prefixBuffer );
160150
161151/**
162- * Make a buffer that is one bit greater than the supplied buffer by incrementing the least significant byte that is
163- * not already 255. This is useful in situations where we want to move past a key range before iterating backward.
152+ * Make a buffer that is one bit greater than the supplied buffer by incrementing the least
153+ * significant byte that is not already 255. This is useful in situations where we want to move
154+ * past a key range before iterating backward.
164155 *
165156 * @param buffer The buffer to increment.
166157 * @return The incremented buffer or null if the buffer is already at max value.