com.sleepycat.persist.impl
Class PersistEntityBinding

java.lang.Object
  extended by com.sleepycat.persist.impl.PersistEntityBinding
All Implemented Interfaces:
EntityBinding

public class PersistEntityBinding
extends Object
implements EntityBinding

A persistence entity binding for a given entity class.

Author:
Mark Hayes

Field Summary
(package private)  Catalog catalog
           
(package private)  Format entityFormat
           
(package private)  PersistKeyAssigner keyAssigner
           
(package private)  boolean rawAccess
           
 
Constructor Summary
PersistEntityBinding(Catalog catalog, String entityClassName, boolean rawAccess)
          Creates a key binding for a given entity class.
 
Method Summary
 Object entryToObject(DatabaseEntry key, DatabaseEntry data)
          Converts key and data entry buffers into an entity Object.
 PersistKeyAssigner getKeyAssigner()
           
 void objectToData(Object entity, DatabaseEntry data)
          Extracts the data entry from an entity Object.
 void objectToKey(Object entity, DatabaseEntry key)
          Extracts the key entry from an entity Object.
(package private) static Object readEntity(Catalog catalog, DatabaseEntry key, DatabaseEntry data, boolean rawAccess)
          Creates the instance, reads the entity key first to track visited entities correctly, then reads the data and returns the entity.
(package private) static void writeEntity(Format format, Catalog catalog, Object entity, DatabaseEntry data, boolean rawAccess)
          Writes the formatId and object, and returns the bytes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

catalog

Catalog catalog

entityFormat

Format entityFormat

rawAccess

boolean rawAccess

keyAssigner

PersistKeyAssigner keyAssigner
Constructor Detail

PersistEntityBinding

public PersistEntityBinding(Catalog catalog,
                            String entityClassName,
                            boolean rawAccess)
Creates a key binding for a given entity class.

Method Detail

getKeyAssigner

public PersistKeyAssigner getKeyAssigner()

entryToObject

public Object entryToObject(DatabaseEntry key,
                            DatabaseEntry data)
Description copied from interface: EntityBinding
Converts key and data entry buffers into an entity Object.

Specified by:
entryToObject in interface EntityBinding
Parameters:
key - is the source key entry.
data - is the source data entry.
Returns:
the resulting Object.

readEntity

static Object readEntity(Catalog catalog,
                         DatabaseEntry key,
                         DatabaseEntry data,
                         boolean rawAccess)
Creates the instance, reads the entity key first to track visited entities correctly, then reads the data and returns the entity. This is a special case of EntityInput.readObject for a top level entity. Special treatments are: - The formatId must be >= 0; since this is the top level instance, it cannot refer to a visited object nor be a null reference. - The resulting entity is not added to the visited object set; entities cannot be referenced by another (or the same) entity. - Format.readPriKey must be called prior to calling Format.readObject.


objectToData

public void objectToData(Object entity,
                         DatabaseEntry data)
Description copied from interface: EntityBinding
Extracts the data entry from an entity Object.

Specified by:
objectToData in interface EntityBinding
Parameters:
entity - is the source Object.
data - is the destination entry buffer.

writeEntity

static void writeEntity(Format format,
                        Catalog catalog,
                        Object entity,
                        DatabaseEntry data,
                        boolean rawAccess)
Writes the formatId and object, and returns the bytes. This is a special case of EntityOutput.writeObject for a top level entity. Special treatments are: - The entity may not be null. - The entity is not added to the visited object set nor checked for existence in the visited object set; entities cannot be referenced by another (or the same) entity.


objectToKey

public void objectToKey(Object entity,
                        DatabaseEntry key)
Description copied from interface: EntityBinding
Extracts the key entry from an entity Object.

Specified by:
objectToKey in interface EntityBinding
Parameters:
entity - is the source Object.
key - is the destination entry buffer.


Copyright 2004-2006 Sleepycat, Inc. All Rights Reserved.