Constructor and Description |
---|
Tree(com.mongodb.DB db)
Creates a new tree object
|
Modifier and Type | Method and Description |
---|---|
void |
addBranch(java.lang.String name,
long headCID)
Adds a named branch.
|
void |
addCommit(Commit commit)
Adds a commit to the tree
|
static Commit |
deserializeCommit(com.mongodb.DBObject o)
Deserializes a database object to a commit
|
boolean |
existsBranch(long rootCID)
Checks if a branch with the given root CID exists
|
boolean |
existsBranch(java.lang.String name)
Checks if a branch with the given name exists
|
boolean |
existsCommit(long cid)
Checks if a commit with a given CID exists
|
long[] |
getChildren(long cid)
Retrieves the CIDs of a commit's children
|
long |
getParent(long cid)
Retrieves a commit's parent CID
|
boolean |
hasChildren(long cid)
Checks if a given commit has got children
|
boolean |
isEmpty() |
Commit |
resolveBranch(java.lang.String name)
Resolves the head commit of a named branch
|
long |
resolveBranchRootCid(java.lang.String name)
Resolves the CID of a named branch's root
|
Commit |
resolveCommit(long cid)
Resolves a CID to its corresponding commit
|
void |
updateBranchHead(java.lang.String name,
long headCID)
Updates the head of a branch.
|
public Tree(com.mongodb.DB db)
db
- the MongoDB databasepublic boolean isEmpty()
public void addCommit(Commit commit)
commit
- the commit to addpublic void addBranch(java.lang.String name, long headCID)
name
- the branch's nameheadCID
- the CID of the head commit the branch points toVException
- if there already is a branch with the given name or
if the given head CID could not be resolved to an existing commitpublic void updateBranchHead(java.lang.String name, long headCID)
name
- the branch's nameheadCID
- the CID of the new headpublic boolean existsBranch(java.lang.String name)
name
- the branch's namepublic boolean existsBranch(long rootCID)
rootCID
- the root CIDpublic Commit resolveBranch(java.lang.String name)
name
- the name of the branch to resolveVException
- if the commit could not be resolvedpublic long resolveBranchRootCid(java.lang.String name)
name
- the branch's nameVException
- if the branch does not existpublic boolean existsCommit(long cid)
cid
- the commit's ID (CID)public Commit resolveCommit(long cid)
cid
- the CIDVException
- if the commit is unknownpublic static Commit deserializeCommit(com.mongodb.DBObject o)
o
- the objectpublic long getParent(long cid)
VHistory
public long[] getChildren(long cid)
VHistory
getChildren
in interface VHistory
cid
- the commit's CID (or 0 if the CID of the root commit should
be returned)public boolean hasChildren(long cid)
cid
- the commit's CID