com.sleepycat.persist.impl
Class CompositeKeyFormat

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

public class CompositeKeyFormat
extends Format

Format for a composite key class. This class is similar to ComplexFormat in that a composite key class and other complex classes have fields, and the Accessor interface is used to access those fields. Composite key classes are different in the following ways: - The superclass must be Object. No inheritance is allowed. - All instance fields must be annotated with @KeyField, which determines their order in the data bytes. - Although fields may be reference types (primitive wrappers or other simple reference types), they are stored as if they were primitives. No object format ID is stored, and the class of the object must be the declared classs of the field; i.e., no polymorphism is allowed for key fields. In other words, a composite key is stored as an ordinary tuple as defined in the com.sleepycat.bind.tuple package. This keeps the key small and gives it a well defined sort order. - If the key class implements Comparable, it is called by the Database btree comparator. It must therefore be available during JE recovery, before the store and catalog have been opened. To support this, this format can be constructed during recovery. A SimpleCatalog singleton instance is used to provide a catalog of simple types that is used by the composite key format. - When interacting with the Accessor, the composite key format treats the Accessor's non-key fields as its key fields. The Accessor's key fields are secondary keys, while the composite format's key fields are the component parts of a single key.

See Also:
Serialized Form

Method Summary
 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).
 java.lang.Object newInstance(EntityInput input, boolean rawAccess)
          Creates a new instance of the target class using its default constructor.
 java.lang.Object 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.
 
Methods inherited from class com.sleepycat.persist.impl.Format
getClassName, getComponentType, getDimensions, getEnumConstants, getPreviousVersion, getSuperType, getVersion, initializeReader, isArray, isEnum, isPrimitive, isSimple, readPriKey, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

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

newInstance

public 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. Is public only in order to implement the Reader interface. Note that this method should only be called directly in raw conversion mode or during conversion of an old format. Normally it should be called via the getReader method and the Reader interface.

Specified by:
newInstance in class Format

readObject

public java.lang.Object 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. Is public only in order to implement the Reader interface. Note that this method should only be called directly in raw conversion mode or during conversion of an old format. Normally it should be called via the getReader method and the Reader interface.

Specified by:
readObject in class Format