edu.UCL.xmiddle.tree
Class LatestTree

java.lang.Object
  |
  +--edu.UCL.xmiddle.framework.tree.Tree
        |
        +--edu.UCL.xmiddle.tree.LatestTree

public class LatestTree
extends Tree

LatestTree.java LatestTree is the basic structure under which the xmiddle hosts store their data. It is called "LatestTree" because the Document that this unit encapsulates always stores the latest version of the tree. It is organised as a series of branches, each representing an exported element. Editions are then added to these branches as they are created. Created: Tue Aug 7 17:25:37 2001


Field Summary
 
Fields inherited from class edu.UCL.xmiddle.framework.tree.Tree
appID, branches, document, linktable, policy, primaryID
 
Constructor Summary
LatestTree(java.lang.Integer appID)
           
LatestTree(java.lang.Integer appID, org.w3c.dom.Document doc)
           
 
Method Summary
 void addEdition(java.lang.String path, Branch branch)
          Adds an Edition to the Tree.
 void addEdition(java.lang.String path, Version version, org.w3c.dom.Element data)
          Add an edition to the Tree.
 void addVersion(java.lang.String path, org.w3c.dom.Element data)
           
 org.w3c.dom.Element getEarliestEdition(java.lang.String path)
          Returns the earliest edition of an element.
 Branch getEarliestEditionBranch(java.lang.String path)
          Returns the Branch holding the earliest edition of an named element.
 org.w3c.dom.Element getEditionNumber(java.lang.String path, int number)
          Returns the edition having the given edition number for an named element.
 Branch getEditionNumberBranch(java.lang.String path, int number)
          Returns the Branch holding the given edition number for an named element.
 java.util.Enumeration getEditions(java.lang.String path)
          Return an Enumeration of all editions under the named path.
 org.w3c.dom.Element getLatestEdition(java.lang.String path)
          Returns the latest edition of an element.
 Branch getLatestEditionBranch(java.lang.String path)
          Returns the Branch holding the latest edition of the named element.
 int getLatestEditionNumber(java.lang.String path)
          Returns the latest edition number kept for a version in this tree.
 org.w3c.dom.Element getLatestVersion(java.lang.String path)
          Returns the latest version of the data from the tree.
 boolean hasVersion(java.lang.String path)
          Returns true if this path has an associated version with it.
 boolean lock(org.w3c.dom.Element element, java.lang.Object source)
          Lock an element in the Tree.
 boolean lock(java.lang.String path, java.lang.Object source)
          Lock a named element in the Tree.
 void newBranch(java.lang.Object primaryID, org.w3c.dom.Element element)
          Add a new element branch to the LatestTree.
 void removeAllEditions()
          Removes all editions from every path in this tree.
 void removeAllEditions(org.w3c.dom.Element element)
          Removes all editions under the given Element.
 void removeAllEditions(java.lang.String path)
          Removes all editions under the named path.
 boolean removeEdition(Branch branch)
          FIXME: does nothing.
 void unlock(org.w3c.dom.Element element)
          Unlock an element in the Tree.
 void unlock(java.lang.String path)
          Unlock a named element in the Tree.
 void unlockAll()
          Unlock all elements in the Tree.
 
Methods inherited from class edu.UCL.xmiddle.framework.tree.Tree
getAppID, getDocument, setDocument, setLinkTable, setPrimaryID
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LatestTree

public LatestTree(java.lang.Integer appID)

LatestTree

public LatestTree(java.lang.Integer appID,
                  org.w3c.dom.Document doc)
Method Detail

getLatestVersion

public org.w3c.dom.Element getLatestVersion(java.lang.String path)
Returns the latest version of the data from the tree. This will create a new version, and clone the current latest edition's document.

Specified by:
getLatestVersion in class Tree
Parameters:
path - The path of the element required.

hasVersion

public boolean hasVersion(java.lang.String path)
Returns true if this path has an associated version with it. Ie. it has been modified since last release.

Specified by:
hasVersion in class Tree

getEditions

public java.util.Enumeration getEditions(java.lang.String path)
Return an Enumeration of all editions under the named path. The Enumeration contains Branches.

Specified by:
getEditions in class Tree
Parameters:
path - The path under which to return data on the elements.
Returns:
An Enumeration containing the editions.

getEditionNumber

public org.w3c.dom.Element getEditionNumber(java.lang.String path,
                                            int number)
Returns the edition having the given edition number for an named element. If the edition does not exist, null is returned.

Specified by:
getEditionNumber in class Tree
Parameters:
path - The path of the element.
number - The number of the edition to return.
Returns:
The element, or null.

getEditionNumberBranch

public Branch getEditionNumberBranch(java.lang.String path,
                                     int number)
Returns the Branch holding the given edition number for an named element. If the edition does not exist, null is returned.

Specified by:
getEditionNumberBranch in class Tree
Parameters:
path - The path of the element.
number - The number of the edition to return.
Returns:
The Branch holding the element and its version details, or null.

getEarliestEdition

public org.w3c.dom.Element getEarliestEdition(java.lang.String path)
Returns the earliest edition of an element.

Specified by:
getEarliestEdition in class Tree
Parameters:
path - The path of the element.
Returns:
the earliest Element.

getEarliestEditionBranch

public Branch getEarliestEditionBranch(java.lang.String path)
Returns the Branch holding the earliest edition of an named element.

Specified by:
getEarliestEditionBranch in class Tree
Parameters:
path - The path of the element.
Returns:
the Branch holding the element and its version details.

getLatestEdition

public org.w3c.dom.Element getLatestEdition(java.lang.String path)
Returns the latest edition of an element. If there is no version, it will return the latest data.

Specified by:
getLatestEdition in class Tree
Parameters:
path - The path of the element.
Returns:
The latest Element.

getLatestEditionBranch

public Branch getLatestEditionBranch(java.lang.String path)
Returns the Branch holding the latest edition of the named element. If there is no version, it will return the latest data.

Specified by:
getLatestEditionBranch in class Tree
Parameters:
path - The path of the element.
Returns:
A Branch holding the element and its version details.

getLatestEditionNumber

public int getLatestEditionNumber(java.lang.String path)
Returns the latest edition number kept for a version in this tree. If no such version exists, -1 is returned instead.

Specified by:
getLatestEditionNumber in class Tree
Returns:
The latest number, or -1.

newBranch

public void newBranch(java.lang.Object primaryID,
                      org.w3c.dom.Element element)
Add a new element branch to the LatestTree. Edition 0 is also created.

Specified by:
newBranch in class Tree
Parameters:
primaryID - The primaryID of the creator.
element - The element to add to the tree.

addVersion

public void addVersion(java.lang.String path,
                       org.w3c.dom.Element data)
Specified by:
addVersion in class Tree

addEdition

public void addEdition(java.lang.String path,
                       Version version,
                       org.w3c.dom.Element data)
Add an edition to the Tree.

Specified by:
addEdition in class Tree
Parameters:
path - The path at which to add the edition.
version - The Version code of the edition.
data - The Element data of the edition.

addEdition

public void addEdition(java.lang.String path,
                       Branch branch)
Adds an Edition to the Tree. This will also clear any references to this Branch made in the 'versions' Vector.

Specified by:
addEdition in class Tree
Parameters:
path - The path at which to add the branch.
branch - The Branch to be added.

removeAllEditions

public void removeAllEditions()
Removes all editions from every path in this tree.

Specified by:
removeAllEditions in class Tree

removeAllEditions

public void removeAllEditions(java.lang.String path)
Removes all editions under the named path.

Specified by:
removeAllEditions in class Tree
Parameters:
path - The path from which to clear edition data.

removeAllEditions

public void removeAllEditions(org.w3c.dom.Element element)
Removes all editions under the given Element.

Specified by:
removeAllEditions in class Tree

removeEdition

public boolean removeEdition(Branch branch)
FIXME: does nothing.

Specified by:
removeEdition in class Tree
Parameters:
branch - The Branch from which to remove the edition.
Returns:
A boolean; true if the edition was removed, otherwise false.

lock

public boolean lock(org.w3c.dom.Element element,
                    java.lang.Object source)
Lock an element in the Tree.

Specified by:
lock in class Tree
Parameters:
source - The object which is the source of the lock.
Returns:
a boolean set to true if the lock was obtained, else false.

lock

public boolean lock(java.lang.String path,
                    java.lang.Object source)
Lock a named element in the Tree.

Specified by:
lock in class Tree
Parameters:
path - The path of the element to lock.
source - The object which is the source of the lock.
Returns:
a boolean set to true if the lock was obtained, else false.

unlock

public void unlock(org.w3c.dom.Element element)
Unlock an element in the Tree.

Specified by:
unlock in class Tree

unlock

public void unlock(java.lang.String path)
Unlock a named element in the Tree.

Specified by:
unlock in class Tree

unlockAll

public void unlockAll()
Unlock all elements in the Tree.

Specified by:
unlockAll in class Tree