BigIntegerBinding.java [plain text]
package com.sleepycat.bind.tuple;
import java.math.BigInteger;
import com.sleepycat.db.DatabaseEntry;
public class BigIntegerBinding extends TupleBinding {
public Object entryToObject(TupleInput input) {
return input.readBigInteger();
}
public void objectToEntry(Object object, TupleOutput output) {
output.writeBigInteger((BigInteger) object);
}
protected TupleOutput getTupleOutput(Object object) {
return sizedOutput((BigInteger) object);
}
public static BigInteger entryToBigInteger(DatabaseEntry entry) {
return entryToInput(entry).readBigInteger();
}
public static void bigIntegerToEntry(BigInteger val, DatabaseEntry entry) {
outputToEntry(sizedOutput(val).writeBigInteger(val), entry);
}
private static TupleOutput sizedOutput(BigInteger val) {
int len = TupleOutput.getBigIntegerByteLength(val);
return new TupleOutput(new byte[len]);
}
}