public abstract class Format extends java.lang.Object implements Reader, RawType, java.io.Serializable
Modifier and Type | Field and Description |
---|---|
(package private) static int |
ID_BIGDEC
BigDecimal
|
(package private) static int |
ID_BIGINT
BigInteger
|
(package private) static int |
ID_BOOL
Boolean
|
(package private) static int |
ID_BOOL_W |
(package private) static int |
ID_BYTE
Byte
|
(package private) static int |
ID_BYTE_W |
(package private) static int |
ID_CHAR
Character
|
(package private) static int |
ID_CHAR_W |
(package private) static int |
ID_DATE
Date
|
(package private) static int |
ID_DOUBLE
Double
|
(package private) static int |
ID_DOUBLE_W |
(package private) static int |
ID_FLOAT
Float
|
(package private) static int |
ID_FLOAT_W |
(package private) static int |
ID_INT
Integer
|
(package private) static int |
ID_INT_W |
(package private) static int |
ID_LONG
Long
|
(package private) static int |
ID_LONG_W |
(package private) static int |
ID_NULL
Null reference.
|
(package private) static int |
ID_NUMBER
Number
|
(package private) static int |
ID_OBJECT
Object
|
(package private) static int |
ID_PREDEFINED
Last predefined ID, after which dynamic IDs are assigned.
|
(package private) static int |
ID_SHORT
Short
|
(package private) static int |
ID_SHORT_W |
(package private) static int |
ID_SIMPLE_MAX
Last simple type.
|
(package private) static int |
ID_SIMPLE_MIN
First simple type.
|
(package private) static int |
ID_STRING
String
|
Constructor and Description |
---|
Format(Catalog catalog,
java.lang.Class type)
Creates a new format for a given class.
|
Format(Catalog catalog,
java.lang.String className)
Creates a format for class evolution when no class may be present.
|
Modifier and Type | Method and Description |
---|---|
boolean |
allowEvolveFromProxy()
Currently, only FBigDec will return true.
|
(package private) boolean |
areNestedRefsProhibited()
Certain formats (ProxiedFormat for example) prohibit nested fields that
reference the parent object.
|
(package private) abstract 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) java.lang.Object |
convertRawObject(Catalog catalog,
boolean rawAccess,
RawObject rawObject,
IdentityHashMap converted)
Converts a RawObject to a current class object and adds the converted
pair to the converted map.
|
(package private) void |
copySecKey(RecordInput input,
RecordOutput output)
Called after skipToSecKey() to copy the data bytes of a singular
(XXX_TO_ONE) key field.
|
(package private) void |
copySecMultiKey(RecordInput 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.
|
(package private) abstract boolean |
evolve(Format newFormat,
Evolver evolver)
Called for an existing format that may not equal the current format for
the same class.
|
(package private) boolean |
evolveMetadata(Format newFormat,
Converter converter,
Evolver evolver)
Called when a Converter handles evolution of a class, but we may still
need to evolve the metadata.
|
Accessor |
getAccessor(boolean rawAccess) |
(package private) Catalog |
getCatalog() |
ClassMetadata |
getClassMetadata()
Returns the original model class metadata used to create this class, or
null if this is not a model class.
|
java.lang.String |
getClassName()
Returns the class name for this type in the format specified by
Class.getName() . |
Format |
getComponentType()
Returns the array component type, or null if this is not an array type.
|
int |
getDimensions()
Returns the number of array dimensions, or zero if this is not an array
type.
|
(package private) ComplexFormat |
getEntityFormat()
For an entity class or subclass, returns the base entity class; returns
null in other cases.
|
EntityMetadata |
getEntityMetadata()
Returns the original model entity metadata used to create this class, or
null if this is not an entity class.
|
java.util.List<java.lang.String> |
getEnumConstants()
Returns an unmodifiable list of the names of the enum instances, or null
if this is not an enum type.
|
(package private) boolean |
getEvolveNeeded()
Overridden by ComplexFormat.
|
(package private) java.lang.Class |
getExistingType()
Called to get the type when it is known to exist for an uninitialized
format.
|
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).
|
int |
getId()
Returns the format ID.
|
(package private) Format |
getLatestVersion()
If this is the latest/evolved format, returns this; otherwise, returns
the current version of this format.
|
(package private) boolean |
getNewStringFormat()
For an entity format, returns whether the entity was written using the
new String format.
|
java.lang.String |
getOldKeyName(java.lang.String keyName)
For an entity class or subclass, returns the old key name for the given
key name that has been renamed, or returns the given key name if it has
not been renamed.
|
Format |
getPreviousVersion()
Returns the previous version of this format in the linked list of
versions, or null if this is the only version.
|
(package private) Format |
getProxiedFormat()
Returns the format that is proxied by this format.
|
(package private) Reader |
getReader()
Returns the object for reading objects of the latest format.
|
(package private) Format |
getSequenceKeyFormat()
Validates and returns the simple integer key format for a sequence key
associated with this format.
|
(package private) Format |
getSuperFormat()
Returns the format of the superclass.
|
Format |
getSuperType()
Returns the type of the superclass, or null if the superclass is Object
or this is not a complex type (in other words, this is a simple type or
an array type).
|
(package private) java.lang.Class |
getType()
Returns the class that this format represents.
|
int |
getVersion()
Returns the class version for this type.
|
(package private) Format |
getWrapperFormat()
For primitive types only, returns their associated wrapper type.
|
(package private) void |
initCatalog(Catalog catalog)
Initialize transient catalog field after deserialization.
|
(package private) abstract void |
initialize(Catalog catalog,
EntityModel model,
int initVersion)
Initializes an uninitialized format, initializing its related formats
(superclass formats and array component formats) first.
|
(package private) void |
initializeIfNeeded(Catalog catalog,
EntityModel model)
Called by the Catalog to initialize a format, and may also be called
during initialize() for a related format to ensure that the related
format is initialized.
|
void |
initializeReader(Catalog catalog,
EntityModel model,
int initVersion,
Format oldFormat)
Called to initialize a separate Reader implementation.
|
boolean |
isArray()
Returns whether this is an array type.
|
(package private) boolean |
isAssignableTo(Format format)
Called by EntityOutput in rawAccess mode to determine whether an object
type is allowed to be assigned to a given field type.
|
(package private) boolean |
isCurrentVersion()
Returns whether this format is the current format for its class.
|
boolean |
isDeleted()
Returns whether the class for this format was deleted.
|
(package private) boolean |
isEntity()
Returns whether this format class is an entity class.
|
boolean |
isEnum()
Returns whether this is an enum type.
|
(package private) boolean |
isInitialized() |
(package private) boolean |
isModelClass()
Returns whether this class is present in the EntityModel.
|
(package private) boolean |
isNew() |
(package private) static boolean |
isPredefined(Format format) |
(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.
|
boolean |
isPrimitive()
Returns whether this type is a Java primitive: char, byte, short, int,
long, float or double.
|
(package private) boolean |
isSameClass(Format other)
Returns whether this format has the same class as the given format,
irrespective of version changes and renaming.
|
boolean |
isSimple()
Returns whether this is a
simple type:
primitive, primitive wrapper, BigInteger, BigDecimal, String or Date.
|
(package private) void |
migrateFromBeta(java.util.Map<java.lang.String,Format> formatMap)
Special handling for JE 3.0.12 beta formats.
|
(package private) abstract 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.
|
abstract 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.
|
abstract 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.
|
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 |
setDeleted(boolean deleted)
Called by the Evolver when applying a Deleter mutation.
|
(package private) void |
setEvolveNeeded(boolean needed)
Called by the Evolver with true when an entity format or any of its
nested format were changed.
|
(package private) void |
setId(int id)
Called by the Catalog to set the format ID when a new format is added to
the format list, before calling initializeIfNeeded().
|
(package private) void |
setLatestVersion(Format newFormat)
Called by Evolver to set the latest format when this old format is
evolved.
|
(package private) void |
setProxiedFormat(Format proxiedFormat)
Called by ProxiedFormat to set the proxied format.
|
(package private) void |
setReader(Reader reader)
Changes the reader during format evolution.
|
(package private) void |
setSuperFormat(Format superFormat)
Called to set the format of the superclass during initialize().
|
(package private) void |
setUnused(boolean unused)
Called by the Evolver for a format that is never referenced.
|
(package private) abstract void |
skipContents(RecordInput input)
Skips over the object's contents, as if readObject() were called, but
without returning an object.
|
(package private) Format |
skipToSecKey(RecordInput input,
java.lang.String keyName)
When extracting a secondary key, called to skip over all fields up to
the given secondary key field.
|
java.lang.String |
toString()
Returns an XML representation of the raw type.
|
(package private) abstract 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.
|
static final int ID_NULL
static final int ID_OBJECT
static final int ID_BOOL
static final int ID_BOOL_W
static final int ID_BYTE
static final int ID_BYTE_W
static final int ID_SHORT
static final int ID_SHORT_W
static final int ID_INT
static final int ID_INT_W
static final int ID_LONG
static final int ID_LONG_W
static final int ID_FLOAT
static final int ID_FLOAT_W
static final int ID_DOUBLE
static final int ID_DOUBLE_W
static final int ID_CHAR
static final int ID_CHAR_W
static final int ID_STRING
static final int ID_BIGINT
static final int ID_BIGDEC
static final int ID_DATE
static final int ID_NUMBER
static final int ID_SIMPLE_MIN
static final int ID_SIMPLE_MAX
static final int ID_PREDEFINED
Format(Catalog catalog, java.lang.Class type)
Format(Catalog catalog, java.lang.String className)
static boolean isPredefined(Format format)
void migrateFromBeta(java.util.Map<java.lang.String,Format> formatMap)
void initCatalog(Catalog catalog)
final boolean isNew()
final Catalog getCatalog()
final void setId(int id)
final java.lang.Class getType()
final java.lang.Class getExistingType()
final Reader getReader()
final void setReader(Reader reader)
final Format getSuperFormat()
final void setSuperFormat(Format superFormat)
final Format getProxiedFormat()
final void setProxiedFormat(Format proxiedFormat)
final Format getLatestVersion()
public final Format getPreviousVersion()
final void setLatestVersion(Format newFormat)
public final boolean isDeleted()
final void setDeleted(boolean deleted)
final void setUnused(boolean unused)
void setEvolveNeeded(boolean needed)
boolean getEvolveNeeded()
boolean getNewStringFormat()
final boolean isInitialized()
final void initializeIfNeeded(Catalog catalog, EntityModel model)
public void initializeReader(Catalog catalog, EntityModel model, int initVersion, Format oldFormat)
initializeReader
in interface Reader
boolean areNestedRefsProhibited()
public java.lang.String getClassName()
RawType
Class.getName()
.
If this class currently exists (has not been removed or renamed) then
the class name may be passed to Class.forName(java.lang.String)
to get the current
Class
object. However, if this raw type is not the current
version of the class, this type information may differ from that of the
current Class
.
getClassName
in interface RawType
public int getVersion()
RawType
getVersion
in interface RawType
Entity.version()
,
Persistent.version()
public Format getSuperType()
RawType
getSuperType
in interface RawType
public boolean isSimple()
RawType
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
.
public boolean isPrimitive()
RawType
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
.
isPrimitive
in interface RawType
public boolean isEnum()
RawType
If true is returned, a value of this type is a RawObject
and
the enum constant String is available via RawObject.getEnum()
.
If false is returned, then this is a complex type, an array type (see
RawType.isArray()
), or a simple type (see RawType.isSimple()
).
public java.util.List<java.lang.String> getEnumConstants()
RawType
getEnumConstants
in interface RawType
public boolean isArray()
RawType
RawObject
instances.
If true is returned, the array component type is returned by RawType.getComponentType()
and the number of array dimensions is returned by
RawType.getDimensions()
.
If false is returned, then this is a complex type, an enum type (see
RawType.isEnum()
), or a simple type (see RawType.isSimple()
).
public int getDimensions()
RawType
getDimensions
in interface RawType
public Format getComponentType()
RawType
getComponentType
in interface RawType
public java.util.Map<java.lang.String,RawField> getFields()
RawType
public ClassMetadata getClassMetadata()
RawType
getClassMetadata
in interface RawType
public EntityMetadata getEntityMetadata()
RawType
getEntityMetadata
in interface RawType
boolean isAssignableTo(Format format)
Format getWrapperFormat()
boolean isEntity()
boolean isModelClass()
ComplexFormat getEntityFormat()
abstract boolean evolve(Format newFormat, Evolver evolver)
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.
boolean evolveMetadata(Format newFormat, Converter converter, Evolver evolver)
final boolean isCurrentVersion()
final boolean isSameClass(Format other)
abstract void initialize(Catalog catalog, EntityModel model, int initVersion)
abstract void collectRelatedFormats(Catalog catalog, java.util.Map<java.lang.String,Format> newFormats)
abstract java.lang.Object newArray(int len)
public abstract java.lang.Object newInstance(EntityInput input, boolean rawAccess) throws RefreshException
newInstance
in interface Reader
RefreshException
public abstract java.lang.Object readObject(java.lang.Object o, EntityInput input, boolean rawAccess) throws RefreshException
readObject
in interface Reader
RefreshException
abstract void writeObject(java.lang.Object o, EntityOutput output, boolean rawAccess) throws RefreshException
RefreshException
abstract void skipContents(RecordInput input) throws RefreshException
RefreshException
Format skipToSecKey(RecordInput input, java.lang.String keyName) throws RefreshException
RefreshException
void copySecKey(RecordInput input, RecordOutput output)
void copySecMultiKey(RecordInput input, Format keyFormat, java.util.Set results) throws RefreshException
RefreshException
boolean nullifySecKey(Catalog catalog, java.lang.Object entity, java.lang.String keyName, java.lang.Object keyElement)
boolean isPriKeyNullOrZero(java.lang.Object o, boolean rawAccess)
void writePriKey(java.lang.Object o, EntityOutput output, boolean rawAccess) throws RefreshException
RefreshException
public void readPriKey(java.lang.Object o, EntityInput input, boolean rawAccess) throws RefreshException
readPriKey
in interface Reader
RefreshException
public java.lang.String getOldKeyName(java.lang.String keyName)
Format getSequenceKeyFormat()
java.lang.Object convertRawObject(Catalog catalog, boolean rawAccess, RawObject rawObject, IdentityHashMap converted) throws RefreshException
RefreshException
public boolean allowEvolveFromProxy()
public Accessor getAccessor(boolean rawAccess)
getAccessor
in interface Reader
Copyright (c) 2004-2012 Oracle. All rights reserved.