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)  PersistCatalog catalog
           
(package private)  Format entityFormat
           
(package private)  PersistKeyAssigner keyAssigner
           
(package private)  boolean rawAccess
           
 
Constructor Summary
PersistEntityBinding(PersistCatalog newCatalog, 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()
           
(package private) static Format getOrCreateFormat(Catalog useCatalog, String clsName, boolean rawAccess)
          Utility method for getting or creating a format as appropriate for bindings and key creators.
 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 useCatalog, 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)  void refresh(PersistCatalog newCatalog)
          See Store.refresh.
(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

volatile PersistCatalog catalog

entityFormat

volatile Format entityFormat

rawAccess

final boolean rawAccess

keyAssigner

PersistKeyAssigner keyAssigner
Constructor Detail

PersistEntityBinding

public PersistEntityBinding(PersistCatalog newCatalog,
                            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 useCatalog,
                         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. - Reader.readPriKey must be called prior to calling Reader.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.

getOrCreateFormat

static Format getOrCreateFormat(Catalog useCatalog,
                                String clsName,
                                boolean rawAccess)
Utility method for getting or creating a format as appropriate for bindings and key creators.


refresh

void refresh(PersistCatalog newCatalog)
See Store.refresh.



Copyright (c) 2004-2010 Oracle. All rights reserved.