org.datanucleus.metadata
Class VersionMetaData

java.lang.Object
  extended by org.datanucleus.metadata.MetaData
      extended by org.datanucleus.metadata.VersionMetaData
All Implemented Interfaces:
java.io.Serializable

public class VersionMetaData
extends MetaData

Three common strategies for versioning instances are supported by standard metadata. These include state-comparison, timestamp, and version-number.

There are two forms of version storage.

See Also:
Serialized Form

Field Summary
protected  ColumnMetaData[] columnMetaData
          Contains the metadata for column.
protected  java.util.List columns
          ColumnMetaData for the version column.
protected  java.lang.String fieldName
          Name of the field that contains the version (if not generating a surrogate column).
protected  IndexedValue indexed
          Indexed value.
protected  IndexMetaData indexMetaData
          IndexMetaData for the version column.
 
Fields inherited from class org.datanucleus.metadata.MetaData
extensions, LOCALISER, METADATA_CREATED_STATE, METADATA_INITIALISED_STATE, METADATA_POPULATED_STATE, METADATA_USED_STATE, metaDataState, parent, VENDOR_NAME, VENDOR_NAME_OLD
 
Constructor Summary
VersionMetaData(java.lang.String versionStrategy, java.lang.String fieldName)
          Constructor for a version stored in a field (JPA).
VersionMetaData(java.lang.String versionStrategy, java.lang.String columnName, java.lang.String indexed)
          Constructor for a surrogate version (JDO).
 
Method Summary
 void addColumn(ColumnMetaData colmd)
          Add a new ColumnMetaData element
 ColumnMetaData[] getColumnMetaData()
          Acessor for the columns
 java.lang.String getFieldName()
          Accessor for the name of the field/property that stores the version.
 IndexMetaData getIndexMetaData()
          Accessor for indexMetaData
 java.lang.Object getNextVersion(java.lang.Object currentVersion)
          Convenience method to provide the next version, using the version strategy given the supplied current version.
 VersionStrategy getVersionStrategy()
          Accessor for versionStrategy
 void initialise()
          Initialisation method.
 void setIndexMetaData(IndexMetaData indexMetaData)
          Mutator for the index MetaData
 java.lang.String toString(java.lang.String prefix, java.lang.String indent)
          Returns a string representation of the object using a prefix This can be used as part of a facility to output a MetaData file.
 
Methods inherited from class org.datanucleus.metadata.MetaData
addExtension, addExtension, getExtensions, getNoOfExtensions, getParent, getValueForExtension, getValuesForExtension, hasExtension, isInitialised, isPopulated, isUsed, removeExtension, setInitialised, setParent, setPopulated, setUsed, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

columns

protected final java.util.List columns
ColumnMetaData for the version column.


indexMetaData

protected IndexMetaData indexMetaData
IndexMetaData for the version column.


indexed

protected IndexedValue indexed
Indexed value.


fieldName

protected java.lang.String fieldName
Name of the field that contains the version (if not generating a surrogate column).


columnMetaData

protected ColumnMetaData[] columnMetaData
Contains the metadata for column.

Constructor Detail

VersionMetaData

public VersionMetaData(java.lang.String versionStrategy,
                       java.lang.String columnName,
                       java.lang.String indexed)
Constructor for a surrogate version (JDO).

Parameters:
versionStrategy - Strategy for versioning
columnName - Column name
indexed - The indexed tag

VersionMetaData

public VersionMetaData(java.lang.String versionStrategy,
                       java.lang.String fieldName)
Constructor for a version stored in a field (JPA).

Parameters:
versionStrategy - Strategy for versioning
fieldName - name of the field/property which stores the version
Method Detail

initialise

public void initialise()
Initialisation method. This should be called AFTER using the populate method if you are going to use populate. It creates the internal convenience arrays etc needed for normal operation.

Overrides:
initialise in class MetaData

getColumnMetaData

public final ColumnMetaData[] getColumnMetaData()
Acessor for the columns

Returns:
Returns the columnMetaData.

getVersionStrategy

public final VersionStrategy getVersionStrategy()
Accessor for versionStrategy

Returns:
Returns the versionStrategy.

getIndexMetaData

public final IndexMetaData getIndexMetaData()
Accessor for indexMetaData

Returns:
Returns the indexMetaData.

getFieldName

public final java.lang.String getFieldName()
Accessor for the name of the field/property that stores the version.

Returns:
Name of the field/property storing the version.

addColumn

public void addColumn(ColumnMetaData colmd)
Add a new ColumnMetaData element

Parameters:
colmd - The ColumnMetaData to add

setIndexMetaData

public final void setIndexMetaData(IndexMetaData indexMetaData)
Mutator for the index MetaData

Parameters:
indexMetaData - The indexMetaData to set.

toString

public java.lang.String toString(java.lang.String prefix,
                                 java.lang.String indent)
Returns a string representation of the object using a prefix This can be used as part of a facility to output a MetaData file.

Overrides:
toString in class MetaData
Parameters:
prefix - prefix string
indent - indent string
Returns:
a string representation of the object.

getNextVersion

public java.lang.Object getNextVersion(java.lang.Object currentVersion)
Convenience method to provide the next version, using the version strategy given the supplied current version.

Parameters:
currentVersion - The current version
Returns:
The next version
Throws:
NucleusUserException - Thrown if the strategy is not supported.


Copyright © 2009. All Rights Reserved.