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<ExtensionMetaData> 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 (DataNucleus) used for extensions.
static java.lang.String VENDOR_NAME_OLD
          Vendor name (JPOX) used for extensions.
 
Constructor Summary
MetaData()
           
MetaData(MetaData parent)
          Constructor.
 
Method Summary
 MetaData addExtension(java.lang.String key, java.lang.String value)
           
 MetaData addExtension(java.lang.String vendor, java.lang.String key, java.lang.String value)
           
 void assertIfInitialised()
           
 ExtensionMetaData[] getExtensions()
           
 int getNoOfExtensions()
           
 MetaData getParent()
           
 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)
           
 void initialise(ClassLoaderResolver clr, MetaDataManager mmgr)
           
 boolean isInitialised()
           
 boolean isPopulated()
           
 boolean isUsed()
           
 ExtensionMetaData newExtensionMetaData(java.lang.String vendor, java.lang.String key, java.lang.String value)
          Method to create a new ExtensionMetaData, add it, and return it.
 MetaData removeExtension(java.lang.String key)
           
 void setParent(MetaData md)
           
 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 (DataNucleus) used for extensions.

See Also:
Constant Field Values

VENDOR_NAME_OLD

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

See Also:
Constant Field Values

extensions

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

Constructor Detail

MetaData

public MetaData()

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(ClassLoaderResolver clr,
                       MetaDataManager mmgr)

setParent

public void setParent(MetaData md)

addExtension

public MetaData addExtension(java.lang.String vendor,
                             java.lang.String key,
                             java.lang.String value)

addExtension

public MetaData addExtension(java.lang.String key,
                             java.lang.String value)

newExtensionMetaData

public ExtensionMetaData newExtensionMetaData(java.lang.String vendor,
                                              java.lang.String key,
                                              java.lang.String value)
Method to create a new ExtensionMetaData, add it, and return it.

Parameters:
vendor - The vendor name
key - Key of the extension
value - Value
Returns:
The extension

removeExtension

public MetaData removeExtension(java.lang.String key)

getParent

public MetaData getParent()

isPopulated

public boolean isPopulated()

isInitialised

public boolean isInitialised()

isUsed

public boolean isUsed()

getNoOfExtensions

public int getNoOfExtensions()

assertIfInitialised

public void assertIfInitialised()

getExtensions

public ExtensionMetaData[] getExtensions()

hasExtension

public boolean hasExtension(java.lang.String key)

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 © 2010. All Rights Reserved.