org.xiruss.repository.server
Class BranchBase

java.lang.Object
  extended by org.xiruss.repository.server.RepositoryObjectBase
      extended by org.xiruss.repository.server.BranchBase
All Implemented Interfaces:
java.lang.Comparable, Branch, RepositoryObject

public class BranchBase
extends RepositoryObjectBase
implements Branch

A linear sequence of snapshots


Field Summary
(package private) static org.apache.log4j.Logger logger
           
(package private)  java.util.Vector snapshotList
           
(package private)  SnapshotMap snapshotsById
           
(package private)  java.util.Set snapshotSet
           
 
Fields inherited from class org.xiruss.repository.server.RepositoryObjectBase
id, name, objectTypeConstant, properties, rep
 
Constructor Summary
BranchBase()
           
 
Method Summary
 void accept(RepositoryVisitor visitor)
           
 void addMutableSnapshot(MutableSnapshot snapshot)
          Adds a mutable snapshot to the branch.
 Snapshot commitSnapshot(MutableSnapshot sandbox)
          Add the snapshot to the branch, committing any created versions to the repository.
 Snapshot getInitialSnapshot()
          Returns the first immutable snapshot on the branch.
 Snapshot getLatestSnapshot()
          Returns the last immutable snapshot on the branch.
 MutableSnapshot getMutableSnapshot(java.lang.String objId)
          Returns a mutable snapshot with the specified ID, if it exists.
 int getMutableSnapshotCount()
          Returns the number of mutable snapshots held by the branch.
 java.util.Iterator getMutableSnapshotIterator()
          Returns an iterator over the mutable sandboxes held by the branch.
 SnapshotMap getMutableSnapshots()
          Returns a map of the mutable snapshots on the branch.
 Repository getRepository()
           
 Snapshot getSnapshot(java.lang.String objId)
          Returns the specified snapshot if it is a snapshot on this branch.
 long getSnapshotCount()
          Returns the number of immutable snapshots on the branch.
 java.util.Iterator getSnapshotIterator()
          Returns an iterator over the immutable snapshots on the branch.
 SnapshotMap getSnapshots()
          Get a map of all the snapshots on the branch, indexed by ID.
 SnapshotMap getSnapshots(long startIndex, long count)
          Get a map of all the snapshots on the branch, indexed by ID.
protected  java.util.Set getSnapshotSet()
           
 void initialize(Repository rep, java.lang.String objId, java.lang.String branchName)
          Initialize the object with the specified object ID and name.
 java.lang.String setName(java.lang.String name)
          Sets the name of object.
protected  void setSnapshotSet(java.util.Set snapshots)
          Use by persistence mechanism.
 
Methods inherited from class org.xiruss.repository.server.RepositoryObjectBase
compareTo, getId, getName, getProperties, getProperty, getPropertyNames, getType, hasProperty, initialize, isNull, setId, setProperties, setProperty, setRepository, setType, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.xiruss.snapcm.api.RepositoryObject
compareTo, getId, getName, getProperties, getProperty, getPropertyNames, getType, hasProperty, isNull, setId, setProperty, toString
 

Field Detail

logger

static org.apache.log4j.Logger logger

snapshotSet

java.util.Set snapshotSet

snapshotList

java.util.Vector snapshotList

snapshotsById

SnapshotMap snapshotsById
Constructor Detail

BranchBase

public BranchBase()
Method Detail

initialize

public void initialize(Repository rep,
                       java.lang.String objId,
                       java.lang.String branchName)
                throws ObjectMutationException
Description copied from interface: RepositoryObject
Initialize the object with the specified object ID and name. This method is for the benefit of repositories that need to construct new objects using no-argument constructors.

Specified by:
initialize in interface RepositoryObject
Overrides:
initialize in class RepositoryObjectBase
Throws:
ObjectMutationException - If object already has an assigned ID, indicating that is has already been constructed.

setSnapshotSet

protected void setSnapshotSet(java.util.Set snapshots)
Use by persistence mechanism.

Parameters:
snapshots -

getSnapshotSet

protected java.util.Set getSnapshotSet()

getSnapshots

public SnapshotMap getSnapshots()
Get a map of all the snapshots on the branch, indexed by ID.

Specified by:
getSnapshots in interface Branch
Returns:

getSnapshots

public SnapshotMap getSnapshots(long startIndex,
                                long count)
Get a map of all the snapshots on the branch, indexed by ID.

Specified by:
getSnapshots in interface Branch
Returns:

getRepository

public Repository getRepository()
Specified by:
getRepository in interface Branch
Specified by:
getRepository in interface RepositoryObject
Overrides:
getRepository in class RepositoryObjectBase
Returns:
Repository that owns this branch.

commitSnapshot

public Snapshot commitSnapshot(MutableSnapshot sandbox)
                        throws VersionCommitException,
                               SnapshotException
Add the snapshot to the branch, committing any created versions to the repository. This is an atomic action.

Specified by:
commitSnapshot in interface Branch
Throws:
SnapshotException
VersionCommitException

getInitialSnapshot

public Snapshot getInitialSnapshot()
Description copied from interface: Branch
Returns the first immutable snapshot on the branch.

Specified by:
getInitialSnapshot in interface Branch
Returns:

setName

public java.lang.String setName(java.lang.String name)
                         throws RepositoryException
Description copied from interface: RepositoryObject
Sets the name of object. Returns the old object name.

Specified by:
setName in interface RepositoryObject
Overrides:
setName in class RepositoryObjectBase
Parameters:
name -
Returns:
Old object name
Throws:
RepositoryException

getLatestSnapshot

public Snapshot getLatestSnapshot()
Description copied from interface: Branch
Returns the last immutable snapshot on the branch.

Specified by:
getLatestSnapshot in interface Branch
Returns:

getSnapshotCount

public long getSnapshotCount()
Description copied from interface: Branch
Returns the number of immutable snapshots on the branch.

Specified by:
getSnapshotCount in interface Branch

accept

public void accept(RepositoryVisitor visitor)
            throws java.lang.Throwable
Specified by:
accept in interface RepositoryObject
Overrides:
accept in class RepositoryObjectBase
Throws:
java.lang.Throwable

getSnapshotIterator

public java.util.Iterator getSnapshotIterator()
Description copied from interface: Branch
Returns an iterator over the immutable snapshots on the branch.

Specified by:
getSnapshotIterator in interface Branch

addMutableSnapshot

public void addMutableSnapshot(MutableSnapshot snapshot)
Description copied from interface: Branch
Adds a mutable snapshot to the branch. Used by the repository. Use Repository.createMutableSnapshot(Branch) to get a new mutable snapshot and add it to a branch.

Specified by:
addMutableSnapshot in interface Branch

getMutableSnapshot

public MutableSnapshot getMutableSnapshot(java.lang.String objId)
Description copied from interface: Branch
Returns a mutable snapshot with the specified ID, if it exists.

Specified by:
getMutableSnapshot in interface Branch
Returns:
Mutable snapshot with the specified ID or null snapshot.

getMutableSnapshotCount

public int getMutableSnapshotCount()
Description copied from interface: Branch
Returns the number of mutable snapshots held by the branch.

Specified by:
getMutableSnapshotCount in interface Branch

getMutableSnapshots

public SnapshotMap getMutableSnapshots()
Description copied from interface: Branch
Returns a map of the mutable snapshots on the branch.

Specified by:
getMutableSnapshots in interface Branch

getMutableSnapshotIterator

public java.util.Iterator getMutableSnapshotIterator()
Description copied from interface: Branch
Returns an iterator over the mutable sandboxes held by the branch.

Specified by:
getMutableSnapshotIterator in interface Branch

getSnapshot

public Snapshot getSnapshot(java.lang.String objId)
Description copied from interface: Branch
Returns the specified snapshot if it is a snapshot on this branch.

Specified by:
getSnapshot in interface Branch
Parameters:
objId - Object ID of the snapshot to get