Building Parsers with Java

sjm.examples.pretty
Class ComponentNode

java.lang.Object
  |
  +--sjm.examples.pretty.ComponentNode
Direct Known Subclasses:
CompositeNode, TerminalNode

public abstract class ComponentNode
extends java.lang.Object

This class tops a hierarchy that implements the Composite pattern. The two subclasses are CompositeNode and TerminalNode. A composite node contains other nodes, which can be other composites or terminal nodes. A terminal node does not contain other nodes.


Field Summary
protected  java.lang.Object value
           
 
Constructor Summary
ComponentNode()
           
 
Method Summary
static java.lang.String indent(int n)
          Returns a string of blanks.
 java.lang.String toString()
          Return a textual description of this node.
protected abstract  java.lang.String toString(int n, boolean label, java.util.Vector visited)
           
 java.lang.String toStringWithoutLabels()
          Return a textual description of this node without showing composite values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

value

protected java.lang.Object value
Constructor Detail

ComponentNode

public ComponentNode()
Method Detail

indent

public static java.lang.String indent(int n)
Returns a string of blanks.
Returns:
a string of blanks

toString

public java.lang.String toString()
Return a textual description of this node.
Overrides:
toString in class java.lang.Object
Returns:
a textual description of this node

toString

protected abstract java.lang.String toString(int n,
                                             boolean label,
                                             java.util.Vector visited)

toStringWithoutLabels

public java.lang.String toStringWithoutLabels()
Return a textual description of this node without showing composite values. This is useful if the presence of a composite is clear just from the indenting in the display string. The class ShowDangle gives an example.
Returns:
a textual description of this node, omitting composite values

by Steve Metsker