com.sleepycat.persist.impl
Class SimpleFormat

java.lang.Object
  extended by com.sleepycat.persist.impl.Format
      extended by com.sleepycat.persist.impl.SimpleFormat
All Implemented Interfaces:
RawType, Serializable
Direct Known Subclasses:
SimpleFormat.FBool, SimpleFormat.FByte, SimpleFormat.FChar, SimpleFormat.FDate, SimpleFormat.FDouble, SimpleFormat.FFloat, SimpleFormat.FInt, SimpleFormat.FLong, SimpleFormat.FShort, SimpleFormat.FString

public abstract class SimpleFormat
extends Format

Format for simple types, including primitives. Additional methods are included to optimize the handling of primitives. Other classes such as PrimitiveArrayFormat and ReflectAccessor take advantage of these methods.

Author:
Mark Hayes
See Also:
Serialized Form

Nested Class Summary
static class SimpleFormat.FBool
           
static class SimpleFormat.FByte
           
static class SimpleFormat.FChar
           
static class SimpleFormat.FDate
           
static class SimpleFormat.FDouble
           
static class SimpleFormat.FFloat
           
static class SimpleFormat.FInt
           
static class SimpleFormat.FLong
           
static class SimpleFormat.FShort
           
static class SimpleFormat.FString
           
 
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
SimpleFormat(Class type, boolean primitive)
           
 
Method Summary
(package private)  void collectRelatedFormats(Catalog catalog, Map<String,Format> newFormats)
          Calls catalog.createFormat for formats that this format depends on, or that should also be persistent.
(package private)  void copySecMultiKeyPrimitiveArray(int len, EntityInput input, Set results)
           
 boolean equals(Object other)
          Used to compare the current version and an old version, to determine whether class evolution is needed.
(package private)  int getPrimitiveLength()
           
(package private)  Format getWrapperFormat()
          For primitive types only, returns their associated wrapper type.
(package private)  void initialize(Catalog catalog)
          Initializes an uninitialized format, initializing its related formats (superclass formats and array component formats) first.
 boolean isPrimitive()
          Returns whether this type is a Java primitive: char, byte, short, int, long, float or double.
 boolean isSimple()
          Returns whether this is a simple type: primitive, primitive wrapper, String or Date.
(package private)  Object newPrimitiveArray(int len, EntityInput input)
           
(package private)  void readObject(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 readPrimitiveField(Object o, EntityInput input, Field field)
           
(package private)  void setWrapperFormat(SimpleFormat wrapperFormat)
           
(package private)  void skipPrimitiveArray(int len, EntityInput input)
           
(package private)  void writePrimitiveArray(Object o, EntityOutput output)
           
(package private)  void writePrimitiveField(Object o, EntityOutput output, Field field)
           
 
Methods inherited from class com.sleepycat.persist.impl.Format
copySecKey, copySecMultiKey, evolveTo, getClassMetadata, getClassName, getComponentType, getDimensions, getEntityFormat, getEntityMetadata, getEnumConstants, getFields, getId, getProxiedFormat, getSuperFormat, getSuperType, getType, getVersion, initializeIfNeeded, isArray, isAssignableTo, isCurrentVersion, isEntity, isEnum, isModelClass, isPredefined, isPriKeyNullOrZero, newArray, newInstance, nullifySecKey, readPriKey, setId, setProxiedFormat, setSuperFormat, skipContents, skipToSecKey, writeObject, writePriKey
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleFormat

SimpleFormat(Class type,
             boolean primitive)
Method Detail

setWrapperFormat

void setWrapperFormat(SimpleFormat wrapperFormat)

getWrapperFormat

Format getWrapperFormat()
Description copied from class: Format
For primitive types only, returns their associated wrapper type.

Overrides:
getWrapperFormat in class Format

isSimple

public boolean isSimple()
Description copied from interface: RawType
Returns whether this is a simple type: primitive, primitive wrapper, String or Date.

If true is returned, RawType.isPrimitive() can be called for more information, and a raw value of this type is represented as a simple type object (not as a RawObject).

If false is returned, this is a complex type, an array type (see RawType.isArray()), or an enum type, and a raw value of this type is represented as a RawObject.

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

isPrimitive

public boolean isPrimitive()
Description copied from interface: RawType
Returns whether this type is a Java primitive: char, byte, short, int, long, float or double.

If true is returned, this is also a simple type. In other words, primitive types are a subset of simple types.

If true is returned, a raw value of this type is represented as a non-null instance of the primitive type's wrapper class. For example, an int raw value is represented as an Integer.

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

collectRelatedFormats

void collectRelatedFormats(Catalog catalog,
                           Map<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

readObject

void readObject(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

equals

public boolean equals(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

newPrimitiveArray

Object newPrimitiveArray(int len,
                         EntityInput input)

writePrimitiveArray

void writePrimitiveArray(Object o,
                         EntityOutput output)

getPrimitiveLength

int getPrimitiveLength()

readPrimitiveField

void readPrimitiveField(Object o,
                        EntityInput input,
                        Field field)
                  throws IllegalAccessException
Throws:
IllegalAccessException

writePrimitiveField

void writePrimitiveField(Object o,
                         EntityOutput output,
                         Field field)
                   throws IllegalAccessException
Throws:
IllegalAccessException

skipPrimitiveArray

void skipPrimitiveArray(int len,
                        EntityInput input)

copySecMultiKeyPrimitiveArray

void copySecMultiKeyPrimitiveArray(int len,
                                   EntityInput input,
                                   Set results)


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