1 8 9 package com.sleepycat.bind.tuple; 10 11 import com.sleepycat.je.DatabaseEntry; 12 13 28 public class BooleanBinding extends TupleBinding { 29 30 private static final int BOOLEAN_SIZE = 1; 31 32 public Object entryToObject(TupleInput input) { 34 35 return input.readBoolean() ? Boolean.TRUE : Boolean.FALSE; 36 } 37 38 public void objectToEntry(Object object, TupleOutput output) { 40 41 output.writeBoolean(((Boolean ) object).booleanValue()); 42 } 43 44 protected TupleOutput getTupleOutput(Object object) { 46 47 return sizedOutput(); 48 } 49 50 57 public static boolean entryToBoolean(DatabaseEntry entry) { 58 59 return entryToInput(entry).readBoolean(); 60 } 61 62 69 public static void booleanToEntry(boolean val, DatabaseEntry entry) { 70 71 outputToEntry(sizedOutput().writeBoolean(val), entry); 72 } 73 74 78 private static TupleOutput sizedOutput() { 79 80 return new TupleOutput(new byte[BOOLEAN_SIZE]); 81 } 82 } 83 | Popular Tags |