1 8 9 package com.sleepycat.bind.tuple; 10 11 import com.sleepycat.je.DatabaseEntry; 12 13 33 public class FloatBinding extends TupleBinding { 34 35 private static final int FLOAT_SIZE = 4; 36 37 public Object entryToObject(TupleInput input) { 39 40 return new Float (input.readFloat()); 41 } 42 43 public void objectToEntry(Object object, TupleOutput output) { 45 46 output.writeFloat(((Number ) object).floatValue()); 47 } 48 49 protected TupleOutput getTupleOutput(Object object) { 51 52 return sizedOutput(); 53 } 54 55 62 public static float entryToFloat(DatabaseEntry entry) { 63 64 return entryToInput(entry).readFloat(); 65 } 66 67 74 public static void floatToEntry(float val, DatabaseEntry entry) { 75 76 outputToEntry(sizedOutput().writeFloat(val), entry); 77 } 78 79 83 static TupleOutput sizedOutput() { 84 85 return new TupleOutput(new byte[FLOAT_SIZE]); 86 } 87 } 88 | Popular Tags |