org.datanucleus.metadata
Class MetaData

java.lang.Object
  extended by org.datanucleus.metadata.MetaData
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
AbstractClassMetaData, AbstractConstraintMetaData, AbstractElementMetaData, AbstractMemberMetaData, ColumnMetaData, ContainerMetaData, DiscriminatorMetaData, EmbeddedMetaData, EventListenerMetaData, FetchGroupMetaData, FetchPlanMetaData, FileMetaData, IdentityMetaData, ImplementsMetaData, InheritanceMetaData, JoinMetaData, OrderMetaData, PackageMetaData, PersistenceFileMetaData, PersistenceUnitMetaData, PrimaryKeyMetaData, QueryMetaData, QueryResultMetaData, SequenceMetaData, TableGeneratorMetaData, VersionMetaData

public class MetaData
extends java.lang.Object
implements java.io.Serializable

Base class for all MetaData.

MetaData Lifecycle

The states represent the lifecycle of a MetaData object. The lifecycle goes as follows :
  1. MetaData object is created (values passed in from a parsed file, or manually generated)
  2. MetaData object is populated (maybe pass in a class that it represents, creating any additional information that wasn't in the initial data).
  3. MetaData object is initialised (any internal arrays are set up, and additions of data is blocked from this point).
  4. MetaData object is added to with runtime information like actual column names and types in use.

MetaData Extensability

All MetaData elements are extensible with extensions for a "vendor-name". Extensions take the form of a key and a value.

See Also:
Serialized Form

Field Summary
protected  java.util.Collection extensions
          List of extensions for this MetaData element.
protected static Localiser LOCALISER
           
static int METADATA_CREATED_STATE
          State representing the start state of MetaData, representing the initial values passed in.
static int METADATA_INITIALISED_STATE
          State reflecting that MetaData object has been initialised with any internal info required.
static int METADATA_POPULATED_STATE
          State reflecting that MetaData has been populated with real class definition adding any defaulted info.
static int METADATA_USED_STATE
          State reflecting that MetaData object has been modified with usage information (e.g defaulted column names).
protected  int metaDataState
          State of the MetaData.
protected  MetaData parent
          Parent MetaData object, allowing hierarchical MetaData structure.
static java.lang.String VENDOR_NAME
          Vendor name used by JPOX for extensions.
static java.lang.String VENDOR_NAME_OLD
          Vendor name used by JPOX for extensions.
 
Constructor Summary
MetaData(MetaData parent)
          Constructor.
 
Method Summary
 void addExtension(java.lang.String key, java.lang.String value)
          Append new Extension (for JPOX).
 void addExtension(java.lang.String vendor, java.lang.String key, java.lang.String value)
          Append new Extension (for the specified vendor).
 ExtensionMetaData[] getExtensions()
          Accessor for the extensions.
 int getNoOfExtensions()
          Accessor for the number of extensions.
 MetaData getParent()
          Accessor for the parent MetaData object.
 java.lang.String getValueForExtension(java.lang.String key)
          Accessor for the value of a particular extension (for JPOX).
 java.lang.String[] getValuesForExtension(java.lang.String key)
          Accessor for the value of a particular extension (for JPOX), but splitting it into separate parts.
 boolean hasExtension(java.lang.String key)
          Accessor for whether an extension exists (for JPOX).
 void initialise()
          Method to initialise the object.
 boolean isInitialised()
          Accessor for whether the object state is "initialised" (at least).
 boolean isPopulated()
          Accessor for whether the object state is "populated" (at least).
 boolean isUsed()
          Accessor for whether the object state is "used" (has been modified with usage info).
 void removeExtension(java.lang.String key)
          Method to remove a (JPOX) MetaData extension.
 void setInitialised()
          Utility to set the state as initialised.
 void setParent(MetaData md)
          Convenience method to set the parent of this MetaData element.
 void setPopulated()
          Utility to set the state as populated.
 void setUsed()
          Utility to set the state as used.
 java.lang.String toString()
          Accessor for a string representation of the object.
 java.lang.String toString(java.lang.String prefix, java.lang.String indent)
          Returns a string representation of the object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LOCALISER

protected static Localiser LOCALISER

METADATA_CREATED_STATE

public static final int METADATA_CREATED_STATE
State representing the start state of MetaData, representing the initial values passed in.

See Also:
Constant Field Values

METADATA_POPULATED_STATE

public static final int METADATA_POPULATED_STATE
State reflecting that MetaData has been populated with real class definition adding any defaulted info.

See Also:
Constant Field Values

METADATA_INITIALISED_STATE

public static final int METADATA_INITIALISED_STATE
State reflecting that MetaData object has been initialised with any internal info required.

See Also:
Constant Field Values

METADATA_USED_STATE

public static final int METADATA_USED_STATE
State reflecting that MetaData object has been modified with usage information (e.g defaulted column names).

See Also:
Constant Field Values

metaDataState

protected int metaDataState
State of the MetaData.


parent

protected MetaData parent
Parent MetaData object, allowing hierarchical MetaData structure.


VENDOR_NAME

public static final java.lang.String VENDOR_NAME
Vendor name used by JPOX for extensions.

See Also:
Constant Field Values

VENDOR_NAME_OLD

public static final java.lang.String VENDOR_NAME_OLD
Vendor name used by JPOX for extensions.

See Also:
Constant Field Values

extensions

protected java.util.Collection extensions
List of extensions for this MetaData element.

Constructor Detail

MetaData

public MetaData(MetaData parent)
Constructor. Taking the parent MetaData object (if any).

Parameters:
parent - The parent MetaData object.
Method Detail

initialise

public void initialise()
Method to initialise the object. The state changes to "INITIALISED" after this call.


setInitialised

public void setInitialised()
Utility to set the state as initialised.


setPopulated

public void setPopulated()
Utility to set the state as populated.


setUsed

public void setUsed()
Utility to set the state as used.


setParent

public void setParent(MetaData md)
Convenience method to set the parent of this MetaData element. Only valid for calling until the MetaData is populated/initialised and throws a JPOXException thereafter.

Parameters:
md - The parent

addExtension

public void addExtension(java.lang.String vendor,
                         java.lang.String key,
                         java.lang.String value)
Append new Extension (for the specified vendor). Will throw an InvalidMetaDataException if the input is invalid.

Parameters:
vendor - vendor-name tag value
key - key tag value
value - value tag value

addExtension

public void addExtension(java.lang.String key,
                         java.lang.String value)
Append new Extension (for JPOX). Will throw an InvalidMetaDataException if the input is invalid.

Parameters:
key - key tag value
value - value tag value

removeExtension

public void removeExtension(java.lang.String key)
Method to remove a (JPOX) MetaData extension.

Parameters:
key - Key of the tag

getParent

public MetaData getParent()
Accessor for the parent MetaData object.

Returns:
Parent MetaData object.

isPopulated

public boolean isPopulated()
Accessor for whether the object state is "populated" (at least).

Returns:
Whether it is populated.

isInitialised

public boolean isInitialised()
Accessor for whether the object state is "initialised" (at least).

Returns:
Whether it is initialised

isUsed

public boolean isUsed()
Accessor for whether the object state is "used" (has been modified with usage info).

Returns:
Whether it is used.

getNoOfExtensions

public int getNoOfExtensions()
Accessor for the number of extensions.

Returns:
Number of extensions

getExtensions

public ExtensionMetaData[] getExtensions()
Accessor for the extensions.

Returns:
The extensions.

hasExtension

public boolean hasExtension(java.lang.String key)
Accessor for whether an extension exists (for JPOX).

Parameters:
key - The key of the extension
Returns:
Whether the extension exists

getValueForExtension

public java.lang.String getValueForExtension(java.lang.String key)
Accessor for the value of a particular extension (for JPOX).

Parameters:
key - The key of the extension
Returns:
The value of the extension (null if not existing)

getValuesForExtension

public java.lang.String[] getValuesForExtension(java.lang.String key)
Accessor for the value of a particular extension (for JPOX), but splitting it into separate parts. This is for extension tags that have a value as comma separated.

Parameters:
key - The key of the extension
Returns:
The value(s) of the extension (null if not existing)

toString

public java.lang.String toString()
Accessor for a string representation of the object.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of the object.

toString

public java.lang.String toString(java.lang.String prefix,
                                 java.lang.String indent)
Returns a string representation of the object.

Parameters:
prefix - prefix string
indent - indent string
Returns:
a string representation of the object.


Copyright © 2009. All Rights Reserved.