com.metamatrix.common.tree
Interface TreeNodeEditor

All Superinterfaces:
PropertiedObjectEditor, PropertyAccessPolicy, UserTransactionFactory
All Known Subinterfaces:
DirectoryEntryEditor
All Known Implementing Classes:
BasicTreeNodeEditor, DefaultTreeNodeEditor, FileSystemEntryEditor

public interface TreeNodeEditor
extends PropertiedObjectEditor

This interface defines a view of a hierarchy of TreeNode instances.


Field Summary
 
Fields inherited from interface com.metamatrix.common.object.PropertiedObjectEditor
NO_VALUE
 
Fields inherited from interface com.metamatrix.common.object.PropertyAccessPolicy
DEFAULT_READ_ONLY_PRIVILEGE
 
Method Summary
 TreeNode create(TreeNode parent, ObjectDefinition type)
          Create a new instance of a TreeNode under the specified parent and with the specified type.
 TreeNode create(TreeNode parent, java.lang.String name, ObjectDefinition type)
          Create a new instance of a TreeNode under the specified parent, with the specified type and with the specified name
 boolean delete(TreeNode node)
          Removes the specified TreeNode instance (and all its children) from its parent.
 PropertyDefinition getNamePropertyDefinition(TreeNode obj)
          Filter the specified PropertyDefinition instances and return the first definition that is mapped to "the name" property for the tree node.
 boolean isAncestorOf(TreeNode ancestor, TreeNode descendent)
          Determine whether the specified node is a descendent of the given ancestor node.
 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 move(TreeNode node, TreeNode newParent)
          Moves this TreeNode to be a child of the specified new parent.
 boolean move(TreeNode node, TreeNode newParent, int indexInNewParent)
          Moves this TreeNode to be a child at a particular index in the specified new parent.
 boolean moveChild(TreeNode child, int newIndex)
          Moves this TreeNode to the specified location within the ordered list of children for the node's parent.
 TreeNode paste(TreeNode original, TreeNode newParent, boolean deepCopy)
          Creates and places a copy of the specified original TreeNode under the specified new parent.
 boolean rename(TreeNode node, java.lang.String newName)
          Renames this TreeNode to the specified new name.
 void setMarked(TreeNode node, boolean marked)
          Set the marked state of the TreeNode node.
 
Methods inherited from interface com.metamatrix.common.object.PropertiedObjectEditor
getAllowedValues, getPolicy, getPropertyDefinitions, getValue, isReadOnly, isValidValue, setPolicy, setValue
 
Methods inherited from interface com.metamatrix.common.object.PropertyAccessPolicy
isReadOnly, reset, setReadOnly, setReadOnly
 
Methods inherited from interface com.metamatrix.common.transaction.UserTransactionFactory
createReadTransaction, createWriteTransaction, createWriteTransaction
 

Method Detail

setMarked

void setMarked(TreeNode node,
               boolean marked)
Set the marked state of the TreeNode node.

Parameters:
marked - the marked state of the node.

isMarked

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

Returns:
the marked state of the node.

isParentOf

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

Returns:
true if the node is a child of the given parent node.

isAncestorOf

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

Returns:
true if the node is a descendent of the given ancestor node.

create

TreeNode create(TreeNode parent,
                ObjectDefinition type)
Create a new instance of a TreeNode under the specified parent and with the specified type. The name of the new object is created automatically.

Parameters:
parent - the TreeNode that is to be the parent of the new tree node object
type - the ObjectDefinition instance that defines the type of tree node object to instantiate.
Returns:
the new instance or null if the new instance could not be created.
Throws:
java.lang.IllegalArgumentException - if the parent and the new TreeNode are not compatible
java.lang.AssertionError - if parent or type is null

create

TreeNode create(TreeNode parent,
                java.lang.String name,
                ObjectDefinition type)
Create a new instance of a TreeNode under the specified parent, with the specified type and with the specified name

Parameters:
parent - the TreeNode that is to be the parent of the new tree node object
name - the name for the new object
type - the ObjectDefinition instance that defines the type of tree node object to instantiate.
Returns:
the new instance or null if the new instance could not be created.
Throws:
java.lang.IllegalArgumentException - if the parent and the new TreeNode are not compatible
java.lang.AssertionError - if parent or type is null

delete

boolean delete(TreeNode node)
Removes the specified TreeNode instance (and all its children) from its parent. After this method is called, the caller is responsible for maintaining the referenced to the specified object (to prevent garbage collection).

Parameters:
obj - the node to be deleted; may not be null
Returns:
true if deletion is successful, or false otherwise.
Throws:
java.lang.AssertionError - if obj is null

paste

TreeNode paste(TreeNode original,
               TreeNode newParent,
               boolean deepCopy)
Creates and places a copy of the specified original TreeNode under the specified new parent. This method does not affect the original TreeNode or its contents.

This methods may be used in conjunction with a reference to an existing TreeNode instance in this or another session to copy TreeNode instances and paste them in this session.

Parameters:
original - the original node to be copied; may not be null
newParent - the nodethat is to be considered the parent of the newly created instances; may not be null
deepCopy - true if this paste operation is to place a deep copy of original, or false if only the original node and its immediate properties are to be pasted.
Returns:
the node that resulted from the paste, or null if the paste failed.
Throws:
java.lang.AssertionError - if either of original or newParent is null

move

boolean move(TreeNode node,
             TreeNode newParent)
Moves this TreeNode to be a child of the specified new parent. The specified object is modified, since it's namespace is changed to be newParent.

This method may be used in conjunction with the delete method of an editor from this or another another session to cut TreeNode instances from the original's session and paste them (or move them) into this session.

Parameters:
obj - the node to be moved; may not be null
newParent - the node that is to be considered the parent of the existing instance; may not be null
Returns:
true if this node was moved, or false otherwise.
Throws:
java.lang.AssertionError - if either of obj or newParent is null

move

boolean move(TreeNode node,
             TreeNode newParent,
             int indexInNewParent)
Moves this TreeNode to be a child at a particular index in the specified new parent. The specified object is modified, since it's namespace is changed to be newParent.

This method may be used in conjunction with the delete method of an editor from this or another another session to cut TreeNode instances from the original's session and paste them (or move them) into this session.

Parameters:
obj - the node to be moved; may not be null
newParent - the node that is to be considered the parent of the existing instance; may not be null
indexInNewParent - the position that this node will occupy within the ordered list of children for newParent.
Returns:
true if this node was moved, or false otherwise.
Throws:
java.lang.AssertionError - if either of obj or newParent is null
java.lang.IndexOutOfBoundsException - if the index is not within the range 0 <= newIndex < childCount

moveChild

boolean moveChild(TreeNode child,
                  int newIndex)
Moves this TreeNode to the specified location within the ordered list of children for the node's parent.

Parameters:
child - the node to be moved; may not be null
newIndex - the position that this node will occupy within the ordered list of children for the node's parent.
Returns:
true if this node was moved, or false otherwise.
Throws:
java.lang.AssertionError - if either of obj or newParent is null
java.lang.IndexOutOfBoundsException - if the index is not within the range 0 <= newIndex < childCount

rename

boolean rename(TreeNode node,
               java.lang.String newName)
Renames this TreeNode to the specified new name. This operation will not succeed if there is already a node underneath the parent with the same name as the specified newName.

Parameters:
obj - the node to be renamed; may not be null
newName - the new name for the object; may not be null or zero-length, and must not be used by an existing sibling
Returns:
true if this node was renamed, or false otherwise.
Throws:
java.lang.AssertionError - if either of obj or newName is null, or if newName is zero-length

getNamePropertyDefinition

PropertyDefinition getNamePropertyDefinition(TreeNode obj)
Filter the specified PropertyDefinition instances and return the first definition that is mapped to "the name" property for the tree node.

Parameters:
obj - the tree node; may not be null
Returns:
the first PropertyDefinition instance found in the list of PropertyDefinition instances that represents the name property for the object, or null if no such PropertyDefinition is found.


Copyright © 2009. All Rights Reserved.