com.sleepycat.persist.impl
Class ComplexFormat

java.lang.Object
  extended by com.sleepycat.persist.impl.Format
      extended by com.sleepycat.persist.impl.ComplexFormat
All Implemented Interfaces:
RawType, java.io.Serializable

public class ComplexFormat
extends Format

Format for persistent complex classes that are not not composite key classes. This includes entity classes and subclasses.

Author:
Mark Hayes
See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.sleepycat.persist.impl.Format
ID_BIGDEC, ID_BIGINT, ID_BOOL, ID_BOOL_W, ID_BYTE, ID_BYTE_W, ID_CHAR, ID_CHAR_W, ID_DATE, ID_DOUBLE, ID_DOUBLE_W, ID_FLOAT, ID_FLOAT_W, ID_INT, ID_INT_W, ID_LONG, ID_LONG_W, ID_NULL, ID_OBJECT, ID_PREDEFINED, ID_SHORT, ID_SHORT_W, ID_SIMPLE_MAX, ID_SIMPLE_MIN, ID_STRING
 
Constructor Summary
ComplexFormat(java.lang.Class cls, ClassMetadata clsMeta, EntityMetadata entityMeta)
           
 
Method Summary
(package private)  void collectRelatedFormats(Catalog catalog, java.util.Map<java.lang.String,Format> newFormats)
          Calls catalog.createFormat for formats that this format depends on, or that should also be persistent.
(package private)  void copySecMultiKey(EntityInput input, Format keyFormat, java.util.Set results)
          Called after skipToSecKey() to copy the data bytes of an array or collection (XXX_TO_MANY) key field.
 boolean equals(java.lang.Object other)
          Used to compare the current version and an old version, to determine whether class evolution is needed.
(package private)  ClassMetadata getClassMetadata()
          Returns the original model class metadata used to create this class, or null if this is not a model class.
(package private)  Format getEntityFormat()
          For an entity class or subclass, returns the base entity class; returns null in other cases.
(package private)  EntityMetadata getEntityMetadata()
          Returns the original model entity metadata used to create this class, or null if this is not an entity class.
 java.util.Map<java.lang.String,RawField> getFields()
          Returns a map of field name to raw field for each non-static non-transient field declared in this class, or null if this is not a complex type (in other words, this is a simple type or an array type).
(package private)  java.lang.String getPriKeyField()
           
(package private)  void initialize(Catalog catalog)
          Initializes an uninitialized format, initializing its related formats (superclass formats and array component formats) first.
(package private)  boolean isEntity()
          Returns whether this format class is an entity class.
(package private)  boolean isModelClass()
          Returns whether this class is present in the EntityModel.
(package private)  boolean isPriKeyNullOrZero(java.lang.Object o, boolean rawAccess)
          Returns whether the entity's primary key field is null or zero, as defined for primary keys that are assigned from a sequence.
(package private)  java.lang.Object newArray(int len)
          Creates an array of the format's class of the given length, as if Array.newInstance(getType(), len) were called.
(package private)  java.lang.Object newInstance(EntityInput input, boolean rawAccess)
          Creates a new instance of the target class using its default constructor.
(package private)  boolean nullifySecKey(Catalog catalog, java.lang.Object entity, java.lang.String keyName, java.lang.Object keyElement)
          Nullifies the given key field in the given RawObject -- rawAccess mode is implied.
(package private)  void readObject(java.lang.Object o, EntityInput input, boolean rawAccess)
          Called after newInstance() to read the rest of the data bytes and fill in the object contents.
(package private)  void readPriKey(java.lang.Object o, EntityInput input, boolean rawAccess)
          Reads the primary key from the given input bytes and sets the primary key field in the given object.
(package private)  void skipContents(EntityInput input)
          Skips over the object's contents, as if readObject() were called, but without returning an object.
(package private)  Format skipToSecKey(EntityInput input, java.lang.String keyName)
          When extracting a secondary key, called to skip over all fields up to the given secondary key field.
(package private)  void writeObject(java.lang.Object o, EntityOutput output, boolean rawAccess)
          Writes a given instance of the target class to the output data bytes.
(package private)  void writePriKey(java.lang.Object o, EntityOutput output, boolean rawAccess)
          Gets the primary key field from the given object and writes it to the given output data bytes.
 
Methods inherited from class com.sleepycat.persist.impl.Format
copySecKey, evolveTo, getClassName, getComponentType, getDimensions, getEnumConstants, getId, getProxiedFormat, getSuperFormat, getSuperType, getType, getVersion, getWrapperFormat, initializeIfNeeded, isArray, isAssignableTo, isCurrentVersion, isEnum, isPredefined, isPrimitive, isSimple, setId, setProxiedFormat, setSuperFormat
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ComplexFormat

ComplexFormat(java.lang.Class cls,
              ClassMetadata clsMeta,
              EntityMetadata entityMeta)
Method Detail

getPriKeyField

java.lang.String getPriKeyField()

isEntity

boolean isEntity()
Description copied from class: Format
Returns whether this format class is an entity class.

Overrides:
isEntity in class Format

isModelClass

boolean isModelClass()
Description copied from class: Format
Returns whether this class is present in the EntityModel. Returns false for a simple type, array type, or enum type.

Overrides:
isModelClass in class Format

getClassMetadata

ClassMetadata getClassMetadata()
Description copied from class: Format
Returns the original model class metadata used to create this class, or null if this is not a model class.

Overrides:
getClassMetadata in class Format

getEntityMetadata

EntityMetadata getEntityMetadata()
Description copied from class: Format
Returns the original model entity metadata used to create this class, or null if this is not an entity class.

Overrides:
getEntityMetadata in class Format

getEntityFormat

Format getEntityFormat()
Description copied from class: Format
For an entity class or subclass, returns the base entity class; returns null in other cases.

Overrides:
getEntityFormat in class Format

getFields

public java.util.Map<java.lang.String,RawField> getFields()
Description copied from interface: RawType
Returns a map of field name to raw field for each non-static non-transient field declared in this class, or null if this is not a complex type (in other words, this is a simple type or an array type).

Specified by:
getFields in interface RawType
Overrides:
getFields in class Format

collectRelatedFormats

void collectRelatedFormats(Catalog catalog,
                           java.util.Map<java.lang.String,Format> newFormats)
Description copied from class: Format
Calls catalog.createFormat for formats that this format depends on, or that should also be persistent.

Specified by:
collectRelatedFormats in class Format

initialize

void initialize(Catalog catalog)
Description copied from class: Format
Initializes an uninitialized format, initializing its related formats (superclass formats and array component formats) first.

Specified by:
initialize in class Format

equals

public boolean equals(java.lang.Object other)
Description copied from class: Format
Used to compare the current version and an old version, to determine whether class evolution is needed. Subclasses should always override this method and also call super.equals() as part of their comparison.

Overrides:
equals in class Format

newInstance

java.lang.Object newInstance(EntityInput input,
                             boolean rawAccess)
Description copied from class: Format
Creates a new instance of the target class using its default constructor. Normally this creates an empty object, and readObject() is called next to fill in the contents. This is done in two steps to allow the instance to be registered by EntityInput before reading the contents. This allows the fields in an object or a nested object to refer to the parent object in a graph. Alternatively, this method may read all or the first portion of the data, rather than that being done by readObject(). This is required for simple types and enums, where the object cannot be created without reading the data. In these cases, there is no possibility that the parent object will be referenced by the child object in the graph. It should not be done in other cases, or the graph references may not be maintained faithfully.

Specified by:
newInstance in class Format

newArray

java.lang.Object newArray(int len)
Description copied from class: Format
Creates an array of the format's class of the given length, as if Array.newInstance(getType(), len) were called. Formats implement this method for specific classes, or call the accessor, to avoid the reflection overhead of Array.newInstance.

Specified by:
newArray in class Format

writeObject

void writeObject(java.lang.Object o,
                 EntityOutput output,
                 boolean rawAccess)
Description copied from class: Format
Writes a given instance of the target class to the output data bytes. This is the complement of the newInstance()/readObject() pair.

Specified by:
writeObject in class Format

readObject

void readObject(java.lang.Object o,
                EntityInput input,
                boolean rawAccess)
Description copied from class: Format
Called after newInstance() to read the rest of the data bytes and fill in the object contents. If the object was read completely by newInstance(), this method does nothing.

Specified by:
readObject in class Format

isPriKeyNullOrZero

boolean isPriKeyNullOrZero(java.lang.Object o,
                           boolean rawAccess)
Description copied from class: Format
Returns whether the entity's primary key field is null or zero, as defined for primary keys that are assigned from a sequence.

Overrides:
isPriKeyNullOrZero in class Format

writePriKey

void writePriKey(java.lang.Object o,
                 EntityOutput output,
                 boolean rawAccess)
Description copied from class: Format
Gets the primary key field from the given object and writes it to the given output data bytes. This is a separate operation because the primary key data bytes are stored separately from the rest of the record.

Overrides:
writePriKey in class Format

readPriKey

void readPriKey(java.lang.Object o,
                EntityInput input,
                boolean rawAccess)
Description copied from class: Format
Reads the primary key from the given input bytes and sets the primary key field in the given object. This is complement of writePriKey().

Overrides:
readPriKey in class Format

nullifySecKey

boolean nullifySecKey(Catalog catalog,
                      java.lang.Object entity,
                      java.lang.String keyName,
                      java.lang.Object keyElement)
Description copied from class: Format
Nullifies the given key field in the given RawObject -- rawAccess mode is implied.

Overrides:
nullifySecKey in class Format

skipContents

void skipContents(EntityInput input)
Description copied from class: Format
Skips over the object's contents, as if readObject() were called, but without returning an object. Used for extracting secondary key bytes without having to instantiate the object. For reference types, the format ID is read just before calling this method, so this method is responsible for skipping everything following the format ID.

Specified by:
skipContents in class Format

copySecMultiKey

void copySecMultiKey(EntityInput input,
                     Format keyFormat,
                     java.util.Set results)
Description copied from class: Format
Called after skipToSecKey() to copy the data bytes of an array or collection (XXX_TO_MANY) key field.

Overrides:
copySecMultiKey in class Format

skipToSecKey

Format skipToSecKey(EntityInput input,
                    java.lang.String keyName)
Description copied from class: Format
When extracting a secondary key, called to skip over all fields up to the given secondary key field. Returns the format of the key field found, or null if the field is not present (nullified) in the object.

Overrides:
skipToSecKey in class Format


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