Jalopy 1.0b10

de.hunsicker.jalopy.language
Class JavaNode

java.lang.Object
  |
  +--de.hunsicker.antlr.BaseAST
        |
        +--de.hunsicker.antlr.CommonAST
              |
              +--de.hunsicker.antlr.CommonASTWithHiddenTokens
                    |
                    +--de.hunsicker.jalopy.language.Node
                          |
                          +--de.hunsicker.jalopy.language.JavaNode
All Implemented Interfaces:
AST, Comparable, Serializable

public class JavaNode
extends Node

A node representing an element in a Java source file.

Version:
$Revision: 1.4 $
Author:
Marco Hunsicker
See Also:
Serialized Form

Field Summary
protected  JavaNode parent
          Parent node.
protected  JavaNode prevSibling
          Previous node.
 
Fields inherited from class de.hunsicker.jalopy.language.Node
endColumn, endLine, startColumn, startLine, text, type
 
Fields inherited from class de.hunsicker.antlr.CommonASTWithHiddenTokens
hiddenAfter, hiddenBefore
 
Fields inherited from class de.hunsicker.antlr.BaseAST
down, right
 
Constructor Summary
JavaNode()
          Creates a new JavaNode object.
JavaNode(int startLine, int startColumn, int endLine, int endColumn)
          Creates a new JavaNode object.
JavaNode(int type, String text)
          Creates a new JavaNode object.
JavaNode(Token tok)
          Creates a new JavaNode object from the given token.
 
Method Summary
 void addChild(AST node)
          Adds a node to the end of the child list for this node.
 void attachAnnotation(Annotation annotation)
          Attaches an annotation to this node.
 List detachAnnotations()
          Detaches and returns all annotations that are attached to this node.
 CommonHiddenStreamToken getCommentAfter()
          Returns the first comment that appears after this node.
 CommonHiddenStreamToken getCommentBefore()
          Returns the first comment before this node.
 JavaNode getParent()
          Returns the parent node of this node.
 Position getPosition()
          Gets the tracked position.
 JavaNode getPreviousSibling()
          Returns the previous sibling of this node.
 int getSizeCommentsAfter()
          Returns the number of comments that appear after this node.
 int getSizeCommentsBefore()
          Returns the number of comments that appear before this node.
 boolean hasCommentsAfter()
          Indicates whether comments appear before of this node.
 boolean hasCommentsBefore()
          Indicates whether comments appear after this node.
 boolean hasJavadocComment()
          Indicates whether this node has a Javadoc comment attached.
 void initialize(AST node)
          {@inheritDoc}
 void setParent(JavaNode node)
          Sets the parent to the given node.
 void setPosition(Position position)
          Sets the position that is to be tracked.
 void setPreviousSibling(JavaNode node)
          Sets the previous sibling to the given node.
 String toString()
          {@inheritDoc}
 void updatePosition(int line, int column)
          Updates the position information of this node (and all annotations), if necessary.
 
Methods inherited from class de.hunsicker.jalopy.language.Node
compareTo, contains, contains, contains, endsAfter, equals, getEndColumn, getEndLine, getStartColumn, getStartLine, getText, getType, initialize, initialize, isPositionKnown, setEndColumn, setEndLine, setHiddenAfter, setHiddenBefore, setStartColumn, setStartLine, setText, setType, startsBefore
 
Methods inherited from class de.hunsicker.antlr.CommonASTWithHiddenTokens
getHiddenAfter, getHiddenBefore
 
Methods inherited from class de.hunsicker.antlr.BaseAST
decode, encode, equals, equalsList, equalsListPartial, equalsTree, equalsTreePartial, findAll, findAllPartial, getFirstChild, getNextSibling, removeChildren, setFirstChild, setNextSibling, setVerboseStringConversion, toStringList, toStringTree, xmlSerialize, xmlSerializeNode, xmlSerializeRootClose, xmlSerializeRootOpen
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

parent

protected JavaNode parent
Parent node.

prevSibling

protected JavaNode prevSibling
Previous node.
Constructor Detail

JavaNode

public JavaNode(int startLine,
                int startColumn,
                int endLine,
                int endColumn)
Creates a new JavaNode object.
Parameters:
startLine - the starting line.
startColumn - the starting column offset.
endLine - the ending line.
endColumn - the ending column offset.

JavaNode

public JavaNode()
Creates a new JavaNode object.

JavaNode

public JavaNode(Token tok)
Creates a new JavaNode object from the given token.
Parameters:
tok - token to initialize the node with.

JavaNode

public JavaNode(int type,
                String text)
Creates a new JavaNode object.
Parameters:
type - the type of the node.
text - the text of the node.
Method Detail

getCommentAfter

public CommonHiddenStreamToken getCommentAfter()
Returns the first comment that appears after this node.
Returns:
the first comment that appears after this node. Returns null if no comments appear after this node.
Since:
1.0b9

getCommentBefore

public CommonHiddenStreamToken getCommentBefore()
Returns the first comment before this node.
Returns:
the first comment before the node. Returns null if this node does not have a comment before.
Since:
1.0b8

setParent

public void setParent(JavaNode node)
Sets the parent to the given node.
Parameters:
node - a node.

getParent

public JavaNode getParent()
Returns the parent node of this node.
Returns:
parent node.

setPosition

public void setPosition(Position position)
Sets the position that is to be tracked. This information can be used by printers to update the position information.
Parameters:
position - position to track.
Since:
1.0b9
See Also:
updatePosition(int, int)

getPosition

public Position getPosition()
Gets the tracked position.
Returns:
the tracked position. Returns null if no position was set.
Since:
1.0b9

setPreviousSibling

public void setPreviousSibling(JavaNode node)
Sets the previous sibling to the given node.
Parameters:
node - a node.

getPreviousSibling

public JavaNode getPreviousSibling()
Returns the previous sibling of this node.
Returns:
previous sibling node.

getSizeCommentsAfter

public int getSizeCommentsAfter()
Returns the number of comments that appear after this node.
Returns:
number of comment after this node.
Since:
1.0b8

getSizeCommentsBefore

public int getSizeCommentsBefore()
Returns the number of comments that appear before this node.
Returns:
number of comment before this node.
Since:
1.0b8

addChild

public void addChild(AST node)
Adds a node to the end of the child list for this node.
Overrides:
addChild in class BaseAST
Parameters:
node - node to add as a new child.

attachAnnotation

public void attachAnnotation(Annotation annotation)
Attaches an annotation to this node.
Parameters:
annotation - annotation.
Since:
1.0b9

detachAnnotations

public List detachAnnotations()
Detaches and returns all annotations that are attached to this node.
Returns:
list of attached annotations (of type <Annotation>). Returns an empty list in case no annotations were found.
Since:
1.0b9

hasCommentsAfter

public boolean hasCommentsAfter()
Indicates whether comments appear before of this node.
Returns:
true if comments appear before this node.

hasCommentsBefore

public boolean hasCommentsBefore()
Indicates whether comments appear after this node.
Returns:
true if comments follows this node.

hasJavadocComment

public boolean hasJavadocComment()
Indicates whether this node has a Javadoc comment attached.
Returns:
true if this node has a Javadoc comment attached.

initialize

public void initialize(AST node)
{@inheritDoc}
Overrides:
initialize in class Node
Following copied from class: de.hunsicker.jalopy.language.Node
Parameters:
node - node to setup this node with.

toString

public String toString()
{@inheritDoc}
Overrides:
toString in class Node
Following copied from class: de.hunsicker.jalopy.language.Node
Returns:
a string representation of this node.

updatePosition

public void updatePosition(int line,
                           int column)
Updates the position information of this node (and all annotations), if necessary.
Parameters:
line - the new line information.
column - the new column offset information.
Since:
1.0b9
See Also:
setPosition(de.hunsicker.jalopy.language.Position), attachAnnotation(de.hunsicker.jalopy.language.Annotation)

Jalopy 1.0b10

Submit a bug or feature.

For further information and documentation, visit the official Jalopy website.
This page generated: November 14 2002