up
Class Tree

java.lang.Object
  extended by up.Tree

public class Tree
extends java.lang.Object

A phrase structure tree.


Constructor Summary
Tree()
          Construct a new tree with a null label.
Tree(java.lang.String label)
          Constructs a new tree with the specified label
 
Method Summary
 void addAsLeftmostSubtree(Tree tree)
          Adds the specified tree as the leftmost subtree of this tree.
 void addAsRightmostSubtree(Tree tree)
          Adds the specified tree as the rightmost subtree of this tree.
 void addLeftSibling(Tree tree)
          Adds the specified tree as a left sibling to this tree.
 void addRightSibling(Tree tree)
          Adds the specified tree as a right sibling to this tree.
 Tree getCopy()
          Returns a copy of this tree.
 Tree getCopy(TreePredicate predicate)
          Returns a copy of this tree, ignoring subtrees to which the specified predicate applies.
 java.lang.String getLabel()
          Returns the label of the root node of this tree.
 java.util.List<Tree> getLeaves()
          Returns the leaves of this tree.
 Tree getLeftmostSubtree()
          Returns the leftmost immediate subtree of this tree.
 Tree getLeftSibling()
          Returns the left sibling tree of this tree.
 int getNSubtrees()
          Returns the number of immediate subtrees of this tree.
 Tree getRightmostSubtree()
          Returns the rightmost immediate subtree of this tree.
 Tree getRightSibling()
          Returns the right sibling tree of this tree.
 java.util.Deque<Tree> getSubtrees()
          Returns the subtrees of this tree.
 Tree getSupertree()
          Returns the immediate supertree of this tree.
 java.util.List<java.lang.String> getYield()
          Returns the yield of this tree.
 boolean isInitial()
          Tests whether this tree has any immediate supertrees.
 boolean isLeftmost()
          Tests whether this tree is at the leftmost periphery.
 boolean isRightmost()
          Tests whether this tree is at the rightmost periphery.
 boolean isTerminal()
          Tests whether this tree has any immediate subtrees.
 void setLabel(java.lang.String label)
          Replaces the label of the root node of this tree with the specified label.
 Tree splice(TreePredicate predicate)
          Returns a copy of this tree, with all nodes to which the specified predicate applies spliced out.
 java.lang.String toString()
          Returns a string representation of this tree.
 void traverseLeftToRight(TraversalHandler handler)
          Traverses this tree left-to-right, sending notifications to the specified handler.
 void traverseLeftToRight(TreePredicate predicate, TraversalHandler handler)
          Traverses this tree left-to-right, sending notifications to the specified handler.
 void traverseRightToLeft(TraversalHandler handler)
          Traverses this tree right-to-left, sending notifications to the specified handler.
 void traverseRightToLeft(TreePredicate predicate, TraversalHandler handler)
          Traverses this tree right-to-left, sending notifications to the specified handler.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Tree

public Tree(java.lang.String label)
Constructs a new tree with the specified label

Parameters:
label - the label of the new tree

Tree

public Tree()
Construct a new tree with a null label.

Method Detail

getLabel

public java.lang.String getLabel()
Returns the label of the root node of this tree.

Returns:
the label of the root node of this tree

getSupertree

public Tree getSupertree()
Returns the immediate supertree of this tree.

Returns:
the immediate supertree of this tree

isInitial

public boolean isInitial()
Tests whether this tree has any immediate supertrees.

Returns:
true iff this tree has no immediate supertrees

getLeftSibling

public Tree getLeftSibling()
Returns the left sibling tree of this tree.

Returns:
the left sibling tree of this tree, or null if this tree does not have any left sibling trees

isLeftmost

public boolean isLeftmost()
Tests whether this tree is at the leftmost periphery.

Returns:
true iff this tree is at the leftmost periphery

getRightSibling

public Tree getRightSibling()
Returns the right sibling tree of this tree.

Returns:
the right sibling tree of this tree, or null if this tree does not have any right sibling trees

isRightmost

public boolean isRightmost()
Tests whether this tree is at the rightmost periphery.

Returns:
true iff this tree is at the rightmost periphery

getNSubtrees

public int getNSubtrees()
Returns the number of immediate subtrees of this tree.

Returns:
the number of immediate subtrees of this tree

getLeftmostSubtree

public Tree getLeftmostSubtree()
Returns the leftmost immediate subtree of this tree.

Returns:
the leftmost immediate subtree of this tree

getRightmostSubtree

public Tree getRightmostSubtree()
Returns the rightmost immediate subtree of this tree.

Returns:
the rightmost immediate subtree of this tree

isTerminal

public boolean isTerminal()
Tests whether this tree has any immediate subtrees.

Returns:
true iff this tree has no immediate subtrees

getSubtrees

public java.util.Deque<Tree> getSubtrees()
Returns the subtrees of this tree.

Returns:
the subtrees of this tree as a double-ended queue

setLabel

public void setLabel(java.lang.String label)
Replaces the label of the root node of this tree with the specified label.

Parameters:
label - the new label of the root node of this tree

addLeftSibling

public void addLeftSibling(Tree tree)
Adds the specified tree as a left sibling to this tree.

Parameters:
tree - the tree to be a added as the left sibling of this tree

addRightSibling

public void addRightSibling(Tree tree)
Adds the specified tree as a right sibling to this tree.

Parameters:
tree - the tree to be added as the right sibling of this tree

addAsLeftmostSubtree

public void addAsLeftmostSubtree(Tree tree)
Adds the specified tree as the leftmost subtree of this tree.

Parameters:
tree - the tree to be added as the leftmost subtree of this tree

addAsRightmostSubtree

public void addAsRightmostSubtree(Tree tree)
Adds the specified tree as the rightmost subtree of this tree.

Parameters:
tree - the tree to be added as the rightmost subtree of this tree

traverseLeftToRight

public void traverseLeftToRight(TraversalHandler handler)
Traverses this tree left-to-right, sending notifications to the specified handler.

Parameters:
handler - the handler to be notified during the traversal of this tree

traverseLeftToRight

public void traverseLeftToRight(TreePredicate predicate,
                                TraversalHandler handler)
Traverses this tree left-to-right, sending notifications to the specified handler. During the traversal, subtrees to whose initial tree the specified predicate applies are ignored.

Parameters:
predicate - specifies subtrees that should be ignored during the traversal
handler - the handler to be notified during the traversal of this tree

traverseRightToLeft

public void traverseRightToLeft(TraversalHandler handler)
Traverses this tree right-to-left, sending notifications to the specified handler.

Parameters:
handler - the handler to be notified during the traversal of this tree

traverseRightToLeft

public void traverseRightToLeft(TreePredicate predicate,
                                TraversalHandler handler)
Traverses this tree right-to-left, sending notifications to the specified handler. During the traversal, subtrees to whose initial tree the specified predicate applies are ignored.

Parameters:
predicate - specifies subtrees that should be ignored during the traversal
handler - the handler to be notified during the traversal of this tree

getCopy

public Tree getCopy()
Returns a copy of this tree.

Returns:
a copy of this tree

getCopy

public Tree getCopy(TreePredicate predicate)
Returns a copy of this tree, ignoring subtrees to which the specified predicate applies.

Parameters:
predicate - specifies subtrees that should not be copied
Returns:
a copy of this tree

splice

public Tree splice(TreePredicate predicate)
Returns a copy of this tree, with all nodes to which the specified predicate applies spliced out.

Parameters:
predicate - specifies subtrees whose root nodes should be spliced out
Returns:
a copy of this tree

getYield

public java.util.List<java.lang.String> getYield()
Returns the yield of this tree.

Returns:
the yield of this tree

getLeaves

public java.util.List<Tree> getLeaves()
Returns the leaves of this tree.

Returns:
the leaves of this tree

toString

public java.lang.String toString()
Returns a string representation of this tree.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of this tree