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<ColumnMetaData> 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()
          Default constructor.
 
Method Summary
 void addColumn(ColumnMetaData colmd)
           
 ColumnMetaData[] getColumnMetaData()
           
 java.lang.String getColumnName()
           
 java.lang.String getFieldName()
           
 IndexedValue getIndexed()
           
 IndexMetaData getIndexMetaData()
           
 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()
           
 void initialise(ClassLoaderResolver clr, MetaDataManager mmgr)
          Initialisation method.
 ColumnMetaData newColumnMetaData()
          Method to create a new ColumnMetaData, add it, and return it.
 IndexMetaData newIndexMetaData()
          Method to create a new Index metadata, add it, and return it.
 VersionMetaData setColumnName(java.lang.String columnName)
           
 VersionMetaData setFieldName(java.lang.String fieldName)
           
 VersionMetaData setIndexed(IndexedValue indexed)
           
 void setIndexMetaData(IndexMetaData indexMetaData)
           
 VersionMetaData setStrategy(java.lang.String strategy)
           
 VersionMetaData setStrategy(VersionStrategy strategy)
           
 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, assertIfInitialised, getExtensions, getNoOfExtensions, getParent, getValueForExtension, getValuesForExtension, hasExtension, isInitialised, isPopulated, isUsed, newExtensionMetaData, removeExtension, setParent, 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<ColumnMetaData> 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()
Default constructor. Set the fields using setters, before populate().

Method Detail

initialise

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

addColumn

public void addColumn(ColumnMetaData colmd)

newColumnMetaData

public ColumnMetaData newColumnMetaData()
Method to create a new ColumnMetaData, add it, and return it.

Returns:
The Column metadata

getVersionStrategy

public final VersionStrategy getVersionStrategy()

setStrategy

public VersionMetaData setStrategy(VersionStrategy strategy)

setStrategy

public VersionMetaData setStrategy(java.lang.String strategy)

getIndexMetaData

public final IndexMetaData getIndexMetaData()

setIndexMetaData

public final void setIndexMetaData(IndexMetaData indexMetaData)

newIndexMetaData

public IndexMetaData newIndexMetaData()
Method to create a new Index metadata, add it, and return it.

Returns:
The Index metadata

getColumnName

public java.lang.String getColumnName()

setColumnName

public VersionMetaData setColumnName(java.lang.String columnName)

getIndexed

public IndexedValue getIndexed()

setIndexed

public VersionMetaData setIndexed(IndexedValue indexed)

getFieldName

public final java.lang.String getFieldName()

setFieldName

public VersionMetaData setFieldName(java.lang.String fieldName)

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