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

RecordNumberBinding.java

00001 /*-
00002  * See the file LICENSE for redistribution information.
00003  *
00004  * Copyright (c) 2000-2005
00005  *      Sleepycat Software.  All rights reserved.
00006  *
00007  * $Id: RecordNumberBinding.java,v 12.1 2005/01/31 19:27:29 mark Exp $
00008  */
00009 
00010 package com.sleepycat.bind;
00011 
00012 import com.sleepycat.compat.DbCompat;
00013 import com.sleepycat.db.DatabaseEntry;
00014 
00024 public class RecordNumberBinding implements EntryBinding {
00025 
00029     public RecordNumberBinding() {
00030     }
00031 
00032     // javadoc is inherited
00033     public Object entryToObject(DatabaseEntry entry) {
00034 
00035         return new Long(entryToRecordNumber(entry));
00036     }
00037 
00038     // javadoc is inherited
00039     public void objectToEntry(Object object, DatabaseEntry entry) {
00040 
00041         recordNumberToEntry(((Number) object).longValue(), entry);
00042     }
00043 
00052     public static long entryToRecordNumber(DatabaseEntry entry) {
00053 
00054         return DbCompat.getRecordNumber(entry) & 0xFFFFFFFFL;
00055     }
00056 
00065     public static void recordNumberToEntry(long recordNumber,
00066                                            DatabaseEntry entry) {
00067         entry.setData(new byte[4], 0, 4);
00068         DbCompat.setRecordNumber(entry, (int) recordNumber);
00069     }
00070 }

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