net.sf.sasl.language.placeholder.syntax
Class ASTNode

java.lang.Object
  extended by net.sf.sasl.language.placeholder.syntax.ASTNode
Direct Known Subclasses:
PlaceholderNode, ScriptNode, TypeValueNode

public abstract class ASTNode
extends Object

Root class for all abstract syntax tree nodes of the placeholder grammar.

Since:
0.0.1 (sasl-common-aspect-library)
Author:
Philipp Förmer

Field Summary
static int INDENT_PER_DEPTH
          How often INDENT_STRING should be repeated in front of each line per tree depth.
static String INDENT_STRING
          Indent string which will be used to pretty print an abstract syntax tree.
 
Constructor Summary
ASTNode()
          Creates an empty root node.
ASTNode(ASTNode parentNode)
          Creates a node that has the given parent node has its parent node.
 
Method Summary
 List<ASTNode> getChildNodes()
          Returns a list of all child nodes of this node.
 ASTNode getParentNode()
          Returns the parent node of this node.
 boolean isLeafNode()
          Returns true if this node is a leaf node.
 boolean isRootNode()
          Returns true if this node is a root node.
abstract  String prettyPrint(int indent)
          Returns a human readable string representation of the tree spanned of by this node.
 void setParentNode(ASTNode parentNode)
          Sets the parent node of this node.
 String toString()
          Returns the same output as calling prettyPrint(int) with indent=0.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

INDENT_PER_DEPTH

public static final int INDENT_PER_DEPTH
How often INDENT_STRING should be repeated in front of each line per tree depth.

Since:
0.0.1 (sasl-common-aspect-library)
See Also:
Constant Field Values

INDENT_STRING

public static final String INDENT_STRING
Indent string which will be used to pretty print an abstract syntax tree.

Since:
0.0.1 (sasl-common-aspect-library)
See Also:
Constant Field Values
Constructor Detail

ASTNode

public ASTNode()
Creates an empty root node.

Since:
0.0.1 (sasl-common-aspect-library)

ASTNode

public ASTNode(ASTNode parentNode)
Creates a node that has the given parent node has its parent node.

Parameters:
parentNode - null or non null
Method Detail

getParentNode

public ASTNode getParentNode()
Returns the parent node of this node.

Returns:
null or non null
Since:
0.0.1 (sasl-common-aspect-library)

setParentNode

public void setParentNode(ASTNode parentNode)
Sets the parent node of this node.

Parameters:
parentNode - null or non null
Since:
0.0.1 (sasl-common-aspect-library)

isRootNode

public boolean isRootNode()
Returns true if this node is a root node. False else.

Returns:
true or false
Since:
0.0.1 (sasl-common-aspect-library)

isLeafNode

public boolean isLeafNode()
Returns true if this node is a leaf node. False else.

Returns:
true or false.
Since:
0.0.1 (sasl-common-aspect-library)

getChildNodes

public List<ASTNode> getChildNodes()
Returns a list of all child nodes of this node.

Returns:
non null list.
Since:
0.0.1 (sasl-common-aspect-library)

prettyPrint

public abstract String prettyPrint(int indent)
                            throws IllegalArgumentException
Returns a human readable string representation of the tree spanned of by this node.

Parameters:
indent - how often INDENT_STRING should be printed in front of each new line at this tree depth.
Returns:
non null string
Throws:
IllegalArgumentException - if parameter indent is lesser than 0.

toString

public String toString()
Returns the same output as calling prettyPrint(int) with indent=0.

Overrides:
toString in class Object
See Also:
Object.toString()


Copyright © 2010. All Rights Reserved.