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:
Reader, RawType, Serializable
Direct Known Subclasses:
SimpleFormat.FBigDec, SimpleFormat.FBigInt, 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.FBigDec
           
static class SimpleFormat.FBigInt
           
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_NUMBER, ID_OBJECT, ID_PREDEFINED, ID_SHORT, ID_SHORT_W, ID_SIMPLE_MAX, ID_SIMPLE_MIN, ID_STRING
 
Constructor Summary
SimpleFormat(Catalog catalog, 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, RecordInput input, Set results)
           
(package private)  boolean evolve(Format newFormat, Evolver evolver)
          Called for an existing format that may not equal the current format for the same class.
(package private)  int getPrimitiveLength()
           
(package private)  Format getWrapperFormat()
          For primitive types only, returns their associated wrapper type.
(package private)  void initialize(Catalog catalog, EntityModel model, int initVersion)
          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, BigInteger, BigDecimal, String or Date.
(package private)  Object newPrimitiveArray(int len, EntityInput input)
           
 Object 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, RecordInput 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
allowEvolveFromProxy, areNestedRefsProhibited, convertRawObject, copySecKey, copySecMultiKey, evolveMetadata, getAccessor, getCatalog, getClassMetadata, getClassName, getComponentType, getDimensions, getEntityFormat, getEntityMetadata, getEnumConstants, getEvolveNeeded, getExistingType, getFields, getId, getLatestVersion, getNewStringFormat, getOldKeyName, getPreviousVersion, getProxiedFormat, getReader, getSequenceKeyFormat, getSuperFormat, getSuperType, getType, getVersion, initCatalog, initializeIfNeeded, initializeReader, isArray, isAssignableTo, isCurrentVersion, isDeleted, isEntity, isEnum, isInitialized, isModelClass, isNew, isPredefined, isPriKeyNullOrZero, isSameClass, migrateFromBeta, newArray, newInstance, nullifySecKey, readPriKey, setDeleted, setEvolveNeeded, setId, setLatestVersion, setProxiedFormat, setReader, setSuperFormat, setUnused, skipContents, skipToSecKey, toString, writeObject, writePriKey
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SimpleFormat

SimpleFormat(Catalog catalog,
             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, BigInteger, BigDecimal, 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,
                EntityModel model,
                int initVersion)
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

public Object 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. 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 interface Reader
Specified by:
readObject in class Format

evolve

boolean evolve(Format newFormat,
               Evolver evolver)
Description copied from class: Format
Called for an existing format that may not equal the current format for the same class.

If this method returns true, then it must have determined one of two things: - that the old and new formats are equal, and it must have called Evolver.useOldFormat; or - that the old format can be evolved to the new format, and it must have called Evolver.useEvolvedFormat.

If this method returns false, then it must have determined that the old format could not be evolved to the new format, and it must have called Evolver.addInvalidMutation, addMissingMutation or addEvolveError.

Specified by:
evolve in class Format

newPrimitiveArray

Object newPrimitiveArray(int len,
                         EntityInput input)
                   throws RefreshException
Throws:
RefreshException

writePrimitiveArray

void writePrimitiveArray(Object o,
                         EntityOutput output)

getPrimitiveLength

int getPrimitiveLength()

readPrimitiveField

void readPrimitiveField(Object o,
                        EntityInput input,
                        Field field)
                  throws IllegalAccessException,
                         RefreshException
Throws:
IllegalAccessException - from subclasses.
RefreshException

writePrimitiveField

void writePrimitiveField(Object o,
                         EntityOutput output,
                         Field field)
                   throws IllegalAccessException
Throws:
IllegalAccessException - from subclasses.

skipPrimitiveArray

void skipPrimitiveArray(int len,
                        RecordInput input)

copySecMultiKeyPrimitiveArray

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


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