1 9 10 package com.sleepycat.bind.tuple; 11 12 import java.math.BigInteger ; 13 14 import com.sleepycat.je.DatabaseEntry; 15 16 19 public class BigIntegerBinding extends TupleBinding { 20 21 public Object entryToObject(TupleInput input) { 23 24 return input.readBigInteger(); 25 } 26 27 public void objectToEntry(Object object, TupleOutput output) { 29 30 output.writeBigInteger((BigInteger ) object); 31 } 32 33 protected TupleOutput getTupleOutput(Object object) { 35 36 return sizedOutput((BigInteger ) object); 37 } 38 39 46 public static BigInteger entryToBigInteger(DatabaseEntry entry) { 47 48 return entryToInput(entry).readBigInteger(); 49 } 50 51 58 public static void bigIntegerToEntry(BigInteger val, DatabaseEntry entry) { 59 60 outputToEntry(sizedOutput(val).writeBigInteger(val), entry); 61 } 62 63 67 private static TupleOutput sizedOutput(BigInteger val) { 68 69 int len = TupleOutput.getBigIntegerByteLength(val); 70 return new TupleOutput(new byte[len]); 71 } 72 } 73 | Popular Tags |