org.garret.perst
Class Version

java.lang.Object
  extended byorg.garret.perst.Persistent
      extended byorg.garret.perst.PersistentResource
          extended byorg.garret.perst.Version
All Implemented Interfaces:
java.lang.Cloneable, java.io.Externalizable, IPersistent, IResource, java.io.Serializable

public class Version
extends PersistentResource
implements java.lang.Cloneable

Base class for version of versioned object. All versions are kept in version history.

See Also:
Serialized Form

Method Summary
 void addLabel(java.lang.String label)
          Add new label to this version
 void addPredecessor(Version predecessor)
          Make specified version predecessor of this version.
 void checkin()
          Check-in new version.
 java.util.Date getDate()
          Get date of version creation
 java.lang.String getId()
          Get identifier of the version
 java.lang.String[] getLabels()
          Get labels associated with this version
 Version[] getPredecessors()
          Get predecessors of this version
 Version[] getSuccessors()
          Get successors of this version
 VersionHistory getVersionHistory()
          Get version history containing this versioned object
 boolean hasLabel(java.lang.String label)
          Check if version has specified label
 boolean isCheckedIn()
          Check if version is checked-in
 boolean isCheckedOut()
          Check if version is checked-out
 Version newVersion()
          Create new version which will be direct successor of this version.
 
Methods inherited from class org.garret.perst.PersistentResource
exclusiveLock, exclusiveLock, reset, sharedLock, sharedLock, unlock
 
Methods inherited from class org.garret.perst.Persistent
assignOid, deallocate, equals, getOid, getStorage, hashCode, invalidate, isDeleted, isModified, isPersistent, isRaw, load, loadAndModify, makePersistent, modify, onLoad, onStore, readExternal, recursiveLoading, store, writeExternal
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

addLabel

public void addLabel(java.lang.String label)
Add new label to this version

Parameters:
label - label to be associated with this version

addPredecessor

public void addPredecessor(Version predecessor)
Make specified version predecessor of this version. This method can be used to perfrom merge of two versions (merging of version data should be done by application itself)

Parameters:
predecessor - version to merged with

checkin

public void checkin()
Check-in new version. This method inserts in version history version created by Version.newVersion or VersionHistory.checkout method


getDate

public java.util.Date getDate()
Get date of version creation

Returns:
date when this version was created

getId

public java.lang.String getId()
Get identifier of the version

Returns:
version identifier automatically assigned by system

getLabels

public java.lang.String[] getLabels()
Get labels associated with this version

Returns:
array of labels assigned to this version

getPredecessors

public Version[] getPredecessors()
Get predecessors of this version

Returns:
array of predecessor versions

getSuccessors

public Version[] getSuccessors()
Get successors of this version

Returns:
array of predecessor versions

getVersionHistory

public VersionHistory getVersionHistory()
Get version history containing this versioned object


hasLabel

public boolean hasLabel(java.lang.String label)
Check if version has specified label

Parameters:
label - version label

isCheckedIn

public boolean isCheckedIn()
Check if version is checked-in

Returns:
true if version belongs to version history

isCheckedOut

public boolean isCheckedOut()
Check if version is checked-out

Returns:
true if version is cjust created and not checked-in yet (and so belongs to version history)

newVersion

public Version newVersion()
Create new version which will be direct successor of this version. This version has to be checked-in in order to be placed in version history.