org.annotation.util
Class SpanTreeNode

java.lang.Object
  extended byjavax.swing.tree.DefaultMutableTreeNode
      extended byorg.annotation.util.SpanTreeNode
All Implemented Interfaces:
java.lang.Cloneable, javax.swing.tree.MutableTreeNode, java.io.Serializable, javax.swing.tree.TreeNode

public class SpanTreeNode
extends javax.swing.tree.DefaultMutableTreeNode

SpanTreeNode is a data structure to hold a tree of spans. Spans are inserted such that any span which is contained by another span will be one of its children. Associated with a span is a data element which is is of type Object.

See Also:
Serialized Form

Field Summary
protected  Span span
           
 
Fields inherited from class javax.swing.tree.DefaultMutableTreeNode
allowsChildren, children, EMPTY_ENUMERATION, parent, userObject
 
Constructor Summary
SpanTreeNode(Span s, java.lang.Object data)
           
 
Method Summary
 SpanTreeNode add(SpanTreeNode node)
          Adds a SpanTreeNode to an existing tree inserting it in its proper location.
protected  SpanTreeNode equalAdd(SpanTreeNode node)
          Inserts node into the tree and makes this its child.
protected  int findInsertionIndex(Span s)
          returns the index where the span s would be inserted if the spans were sorted based on their start index alone.
 SpanTreeNode[] getContainedNodesWithProperty(Span s, java.lang.String p, boolean top)
          Finds nodes which are contained by span s and have property p.
 SpanTreeNode[] getContainedNodesWithProperty(java.lang.String p, boolean top)
          Finds nodes which are contained by this node's span and have property p.
 SpanTreeNode getContainerNodeWithProperty(Span s, java.lang.String p)
          Finds node having property p which contains span s
 SpanTreeNode getNode(Span s)
           
 Span getSpan()
           
 boolean hasProperty(java.lang.String p)
           
protected  void init(java.lang.Object data)
           
 void showIndent(java.lang.String indent)
           
 void simpleAdd(SpanTreeNode node)
           
 
Methods inherited from class javax.swing.tree.DefaultMutableTreeNode
add, breadthFirstEnumeration, children, clone, depthFirstEnumeration, getAllowsChildren, getChildAfter, getChildAt, getChildBefore, getChildCount, getDepth, getFirstChild, getFirstLeaf, getIndex, getLastChild, getLastLeaf, getLeafCount, getLevel, getNextLeaf, getNextNode, getNextSibling, getParent, getPath, getPathToRoot, getPreviousLeaf, getPreviousNode, getPreviousSibling, getRoot, getSharedAncestor, getSiblingCount, getUserObject, getUserObjectPath, insert, isLeaf, isNodeAncestor, isNodeChild, isNodeDescendant, isNodeRelated, isNodeSibling, isRoot, pathFromAncestorEnumeration, postorderEnumeration, preorderEnumeration, remove, remove, removeAllChildren, removeFromParent, setAllowsChildren, setParent, setUserObject, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

span

protected Span span
Constructor Detail

SpanTreeNode

public SpanTreeNode(Span s,
                    java.lang.Object data)
Method Detail

init

protected void init(java.lang.Object data)

getSpan

public Span getSpan()

simpleAdd

public void simpleAdd(SpanTreeNode node)

getNode

public SpanTreeNode getNode(Span s)

equalAdd

protected SpanTreeNode equalAdd(SpanTreeNode node)
Inserts node into the tree and makes this its child. Called when node has the same span as this.


add

public SpanTreeNode add(SpanTreeNode node)
Adds a SpanTreeNode to an existing tree inserting it in its proper location. The node in the tree where this node is placed is returned. This will be node unless a node in the tree with the same span already exist.


findInsertionIndex

protected int findInsertionIndex(Span s)
returns the index where the span s would be inserted if the spans were sorted based on their start index alone. If the start index of s is the same as that of one of the children of the tree then the return value will be the index of that node.


getContainerNodeWithProperty

public SpanTreeNode getContainerNodeWithProperty(Span s,
                                                 java.lang.String p)
Finds node having property p which contains span s


getContainedNodesWithProperty

public SpanTreeNode[] getContainedNodesWithProperty(java.lang.String p,
                                                    boolean top)
Finds nodes which are contained by this node's span and have property p. If top is true then only the top-most nodes are returned, otherwise all nodes satisfying the above criteria are returned.


getContainedNodesWithProperty

public SpanTreeNode[] getContainedNodesWithProperty(Span s,
                                                    java.lang.String p,
                                                    boolean top)
Finds nodes which are contained by span s and have property p. If top is true then only the top-most nodes are returned, otherwise all nodes satisfying the above criteria are returned.


hasProperty

public boolean hasProperty(java.lang.String p)

showIndent

public void showIndent(java.lang.String indent)


Copyright © 2004 Thomas Morton and Jeremy LaCivita. All Rights Reserved.