Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*-
  * See the file LICENSE for redistribution information.
  *
  * Copyright (c) 2000, 2010 Oracle and/or its affiliates.  All rights reserved.
  *
  */
 
 package com.sleepycat.bind;
 

Author(s):
Mark Hayes
Hidden:
An EntryBinding that treats a record number key entry as a Long key object.

Record numbers are returned as Long objects, although on input any Number object may be used.

public class RecordNumberBinding implements EntryBinding {

    
Creates a byte array binding.
    public RecordNumberBinding() {
    }
    // javadoc is inherited
    public Long entryToObject(DatabaseEntry entry) {
        return Long.valueOf(entryToRecordNumber(entry));
    }
    // javadoc is inherited
    public void objectToEntry(Object objectDatabaseEntry entry) {
        recordNumberToEntry(((Numberobject).longValue(), entry);
    }

    
Utility method for use by bindings to translate a entry buffer to an record number integer.

Parameters:
entry the entry buffer.
Returns:
the record number.
    public static long entryToRecordNumber(DatabaseEntry entry) {
        return DbCompat.getRecordNumber(entry) & 0xFFFFFFFFL;
    }

    
Utility method for use by bindings to translate a record number integer to a entry buffer.

Parameters:
recordNumber the record number.
entry the entry buffer to hold the record number.
    public static void recordNumberToEntry(long recordNumber,
                                           DatabaseEntry entry) {
        entry.setData(new byte[4], 0, 4);
        DbCompat.setRecordNumber(entry, (intrecordNumber);
    }
New to GrepCode? Check out our FAQ X