com.metamatrix.common.tree.basic
Class BasicTreeView

java.lang.Object
  extended by com.metamatrix.common.tree.basic.BasicTreeView
All Implemented Interfaces:
PropertiedObjectView, UserTransactionFactory, TreeView

public class BasicTreeView
extends java.lang.Object
implements TreeView


Constructor Summary
BasicTreeView(TreeNode root, TreeNodeSource source)
           
 
Method Summary
 boolean allowsChild(TreeNode parent, TreeNode potentialChild)
          Determine whether the specified parent TreeNode may contain the specified child node.
 boolean allowsChildren(TreeNode node)
          Determine whether the specified TreeNode may contain children.
protected  BasicTreeNode assertBasicTreeNode(TreeNode node)
           
static java.lang.String collectionToString(java.util.Collection objs)
           
 UserTransaction createReadTransaction()
          Create a new instance of a UserTransaction that may be used to read information.
 UserTransaction createWriteTransaction()
          Create a new instance of a UserTransaction that may be used to write and/or update information.
 UserTransaction createWriteTransaction(java.lang.Object source)
          Create a new instance of a UserTransaction that may be used to write and/or update information.
 java.util.List getChildren(TreeNode parent)
          Obtain the set of entries that are considered the children of the specified TreeNode.
 java.util.Comparator getComparator()
          Return the comparator used to order for children returned from this view.
 TreeNodeFilter getFilter()
          Return the filter that is being used by this view.
 TreeNode getHome()
          Obtain the TreeNode that represents the home for the view.
 int getIndexOfChild(TreeNode child)
           
 java.util.Set getMarked()
          Return the set of marked nodes for this view.
 TreeNode getParent(TreeNode node)
          Determine the parent TreeNode for the specified node, or null if the specified node is a root.
 java.lang.String getPath(TreeNode node)
          Obtain the abstract path for this TreeNode.
 PropertiedObjectEditor getPropertiedObjectEditor()
          Return the propertied object editor for this view.
 java.util.List getPropertyDefinitions()
          Get the definitions of the properties for the TreeNode instances returned from this view.
protected  TreeNode getRoot()
          Returns the single root of this TreeView.
 java.util.List getRoots()
          Returns the single root of this TreeNode system.
 java.lang.String getSeparator()
          Obtain the character (as a String) that is used to separate names in a path sequence for the abstract path.
 char getSeparatorChar()
          Obtain the character that is used to separate names in a path sequence for the abstract path.
 TreeNodeEditor getTreeNodeEditor()
          Return the tree node editor for this view.
protected  TreeNodeSource getTreeNodeSource()
          Returns the TreeNodeSource associated with this TreeView.
 boolean isAncestorOf(TreeNode ancestor, TreeNode descendent)
          Determine whether the specified node is a descendent of the given ancestor node.
 boolean isHidden(TreeNode node)
          Determine whether the specified TreeNode is hidden.
 boolean isMarked(TreeNode node)
          Return the marked state of the specified node.
 boolean isParentOf(TreeNode parent, TreeNode child)
          Determine whether the specified node is a child of the given parent node.
 boolean isRoot(TreeNode node)
          Determine whether the specified TreeNode is a root of the underlying system.
 java.util.Iterator iterator()
          Obtain an iterator for this whole view, which navigates the view's nodes using pre-order rules (i.e., it visits a node before its children).
 java.util.Iterator iterator(TreeNode startingPoint)
          Obtain an iterator for the view starting at the specified node.
 java.util.Collection lookup(java.lang.String path)
          Lookup the BasicTreeNode Object(s) referenced by the relative path in this view.
 void print(java.io.PrintStream stream)
           
 void print(java.io.PrintStream stream, boolean showMarked)
           
 void setComparator(java.util.Comparator comparator)
          Set the comparator that should be used to order the children.
 void setFilter(TreeNodeFilter filter)
          Set the filter that limits the set of TreeNode instances returned from this view.
 void setMarked(TreeNode node, boolean markedState)
          Set the marked state of the specified entry.
protected  boolean setRoot(TreeNode root)
          Set the single root used for this TreeView.
 void setSeparator(java.lang.String delimiter)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicTreeView

public BasicTreeView(TreeNode root,
                     TreeNodeSource source)
Method Detail

assertBasicTreeNode

protected BasicTreeNode assertBasicTreeNode(TreeNode node)

setFilter

public void setFilter(TreeNodeFilter filter)
Set the filter that limits the set of TreeNode instances returned from this view.

Specified by:
setFilter in interface TreeView
Parameters:
filter - the filter, or null if the default "pass-through" filter should be used.

getFilter

public TreeNodeFilter getFilter()
Return the filter that is being used by this view.

Specified by:
getFilter in interface TreeView
Returns:
the current filter; never null

setComparator

public void setComparator(java.util.Comparator comparator)
Set the comparator that should be used to order the children.

Specified by:
setComparator in interface TreeView
Parameters:
comparator - the comparator, or null if node path sorting should be used.

getComparator

public java.util.Comparator getComparator()
Return the comparator used to order for children returned from this view.

Specified by:
getComparator in interface TreeView
Returns:
the current comparator; never null

iterator

public java.util.Iterator iterator()
Obtain an iterator for this whole view, which navigates the view's nodes using pre-order rules (i.e., it visits a node before its children).

Specified by:
iterator in interface TreeView
Returns:
the view iterator

iterator

public java.util.Iterator iterator(TreeNode startingPoint)
Obtain an iterator for the view starting at the specified node. This implementation currently navigates the subtree using pre-order rules (i.e., it visits a node before its children).

Specified by:
iterator in interface TreeView
Parameters:
startingPoint - the root of the subtree over which the iterator is to navigate; may not be null
Returns:
the iterator that traverses the nodes in the subtree starting at the specified node; never null

getPropertyDefinitions

public java.util.List getPropertyDefinitions()
Get the definitions of the properties for the TreeNode instances returned from this view.

Specified by:
getPropertyDefinitions in interface TreeView
Returns:
the unmodifiable list of PropertyDefinition instances; never null

getRoots

public java.util.List getRoots()
Returns the single root of this TreeNode system.

Specified by:
getRoots in interface TreeView
Returns:
the unmodifiable list of TreeNode instances that represent the root of this view.

isRoot

public boolean isRoot(TreeNode node)
Determine whether the specified TreeNode is a root of the underlying system.

Specified by:
isRoot in interface TreeView
Parameters:
node - the TreeNode instance that is to be checked; may not be null
Returns:
true if the node is a root, or false otherwise.

allowsChildren

public boolean allowsChildren(TreeNode node)
Determine whether the specified TreeNode may contain children.

Specified by:
allowsChildren in interface TreeView
Parameters:
entry - the TreeNode instance that is to be checked; may not be null
Returns:
true if the entry can contain children, or false otherwise.

allowsChild

public boolean allowsChild(TreeNode parent,
                           TreeNode potentialChild)
Determine whether the specified parent TreeNode may contain the specified child node.

Specified by:
allowsChild in interface TreeView
Parameters:
parent - the TreeNode instance that is to be the parent; may not be null
potentialChild - the TreeNode instance that is to be the child; may not be null
Returns:
true if potentialChild can be placed as a child of parent, or false otherwise.

isHidden

public boolean isHidden(TreeNode node)
Determine whether the specified TreeNode is hidden.

Specified by:
isHidden in interface TreeView
Parameters:
node - the TreeNode instance that is to be checked; may not be null
Returns:
true if the node is hidden, or false otherwise.

isMarked

public boolean isMarked(TreeNode node)
Return the marked state of the specified node.

Specified by:
isMarked in interface TreeView
Returns:
the marked state of the node.

setMarked

public void setMarked(TreeNode node,
                      boolean markedState)
Set the marked state of the specified entry.

Specified by:
setMarked in interface TreeView
Parameters:
true - if the node is to be marked, or false if it is to be un-marked.

getMarked

public java.util.Set getMarked()
Return the set of marked nodes for this view.

Specified by:
getMarked in interface TreeView
Parameters:
the - unmodifiable set of marked nodes; never null

getHome

public TreeNode getHome()
Obtain the TreeNode that represents the home for the view.

Specified by:
getHome in interface TreeView
Returns:
the node that represents the home, or null if no home concept is supported.

getPath

public java.lang.String getPath(TreeNode node)
Obtain the abstract path for this TreeNode.

Specified by:
getPath in interface TreeView
Returns:
the string that represents the abstract path of this node; never null

getSeparatorChar

public char getSeparatorChar()
Obtain the character that is used to separate names in a path sequence for the abstract path. This character is completely dependent upon the implementation.

Specified by:
getSeparatorChar in interface TreeView
Returns:
the charater used to delimit names in the abstract path.

getSeparator

public java.lang.String getSeparator()
Obtain the character (as a String) that is used to separate names in a path sequence for the abstract path.

Specified by:
getSeparator in interface TreeView
Returns:
the string containing the charater used to delimit names in the abstract path; never null

setSeparator

public void setSeparator(java.lang.String delimiter)

getParent

public TreeNode getParent(TreeNode node)
Determine the parent TreeNode for the specified node, or null if the specified node is a root.

Specified by:
getParent in interface TreeView
Parameters:
node - the TreeNode instance for which the parent is to be obtained; may not be null
Returns:
the parent node, or null if there is no parent

getChildren

public java.util.List getChildren(TreeNode parent)
Obtain the set of entries that are considered the children of the specified TreeNode.

Specified by:
getChildren in interface TreeView
Parameters:
parent - the TreeNode instance for which the child entries are to be obtained; may not be null
Returns:
the unmodifiable list of TreeNode instances that are considered the children of the specified node; never null but possibly empty

isParentOf

public boolean isParentOf(TreeNode parent,
                          TreeNode child)
Determine whether the specified node is a child of the given parent node.

Specified by:
isParentOf in interface TreeView
Returns:
true if the node is a child of the given parent node.

getIndexOfChild

public int getIndexOfChild(TreeNode child)

isAncestorOf

public boolean isAncestorOf(TreeNode ancestor,
                            TreeNode descendent)
Determine whether the specified node is a descendent of the given ancestor node.

Specified by:
isAncestorOf in interface TreeView
Returns:
true if the node is a descendent of the given ancestor node.

getPropertiedObjectEditor

public PropertiedObjectEditor getPropertiedObjectEditor()
Return the propertied object editor for this view.

Specified by:
getPropertiedObjectEditor in interface PropertiedObjectView
Returns:
the PropertiedObjectEditor instance

getTreeNodeEditor

public TreeNodeEditor getTreeNodeEditor()
Return the tree node editor for this view.

Specified by:
getTreeNodeEditor in interface TreeView
Returns:
the TreeNodeEditor instance

createReadTransaction

public UserTransaction createReadTransaction()
Create a new instance of a UserTransaction that may be used to read information. Read transactions do not have a source object associated with them (since they never directly modify data).

Specified by:
createReadTransaction in interface UserTransactionFactory
Returns:
the new transaction object

createWriteTransaction

public UserTransaction createWriteTransaction()
Create a new instance of a UserTransaction that may be used to write and/or update information. The transaction will not have a source object associated with it.

Specified by:
createWriteTransaction in interface UserTransactionFactory
Returns:
the new transaction object

createWriteTransaction

public UserTransaction createWriteTransaction(java.lang.Object source)
Create a new instance of a UserTransaction that may be used to write and/or update information. The source object will be used for all events that are fired as a result of or as a product of this transaction.

Specified by:
createWriteTransaction in interface UserTransactionFactory
Parameters:
source - the object that is considered to be the source of the transaction; may be null
Returns:
the new transaction object

lookup

public java.util.Collection lookup(java.lang.String path)
Lookup the BasicTreeNode Object(s) referenced by the relative path in this view. Since this implementation allows some nodes in the same parent to have the same name (restrictions apply), so this method can return multiple BasicTreeNode instances.

This method ignores case.

Parameters:
path - the path of the desired node specified in terms of this view (i.e., the result of calling getPath() on this view with the returned node as the parameter should result in the same value as path); may not be null or zero-length
Returns:
the collection of BasicTreeNode instances that have the specified path; may be empty if no BasicTreeNode exists with the path.
Throws:
java.lang.AssertionError - if the path is null or zero-length

getRoot

protected TreeNode getRoot()
Returns the single root of this TreeView.

Returns:
the TreeNode instance that represent the root of this view.

setRoot

protected boolean setRoot(TreeNode root)
Set the single root used for this TreeView.

Parameters:
root - the TreeNode instance to be used as the root of this view.
Returns:
whether the root was successfully set

getTreeNodeSource

protected TreeNodeSource getTreeNodeSource()
Returns the TreeNodeSource associated with this TreeView.

Returns:
the TreeNodeSource instance of this view.

print

public void print(java.io.PrintStream stream)

print

public void print(java.io.PrintStream stream,
                  boolean showMarked)

collectionToString

public static java.lang.String collectionToString(java.util.Collection objs)


Copyright © 2009. All Rights Reserved.