Main Page | Class Hierarchy | Data Structures | Directories | File List | Data Fields | Related Pages

TestDataBinding.java

00001 /*-
00002  * See the file LICENSE for redistribution information.
00003  *
00004  * Copyright (c) 2002-2005
00005  *      Sleepycat Software.  All rights reserved.
00006  *
00007  * $Id: TestDataBinding.java,v 12.1 2005/01/31 19:27:35 mark Exp $
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 }

Generated on Sun Dec 25 12:14:55 2005 for Berkeley DB 4.4.16 by  doxygen 1.4.2