00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 package com.sleepycat.collections.test;
00011
00012 import com.sleepycat.bind.EntryBinding;
00013 import com.sleepycat.db.DatabaseEntry;
00014
00018 class TestDataBinding implements EntryBinding {
00019
00020 public Object entryToObject(DatabaseEntry data) {
00021
00022 if (data.getSize() != 1) {
00023 throw new IllegalStateException("size=" + data.getSize());
00024 }
00025 byte val = data.getData()[data.getOffset()];
00026 return new Long(val);
00027 }
00028
00029 public void objectToEntry(Object object, DatabaseEntry data) {
00030
00031 byte val = ((Number) object).byteValue();
00032 data.setData(new byte[] { val }, 0, 1);
00033 }
00034 }