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