Jalopy 1.0b10

de.hunsicker.jalopy.language
Class Node

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

public class Node
extends CommonASTWithHiddenTokens
implements Comparable

A node which stores information about its span.

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

Field Summary
protected  int endColumn
          Column number where this node ends.
protected  int endLine
          Line number where this node ends.
protected  int startColumn
          Column number where this node starts.
protected  int startLine
          Line number where this node starts.
protected  String text
          Node text.
protected  int type
          Node type.
 
Fields inherited from class de.hunsicker.antlr.CommonASTWithHiddenTokens
hiddenAfter, hiddenBefore
 
Fields inherited from class de.hunsicker.antlr.BaseAST
down, right
 
Constructor Summary
Node()
          Creates a new Node object.
Node(int startLine, int startColumn, int endLine, int endColumn)
          Creates a new Node object.
Node(int type, String text)
          Creates a new Node object.
Node(int type, String text, int startLine, int startColumn, int endLine, int endColumn)
          Creates a new Node object.
Node(String text)
          Creates a new Node object.
Node(Token tok)
          Creates a new Node object from the given token.
 
Method Summary
 int compareTo(Object o)
          Compares this object with the specified object for order.
 boolean contains(int line, int column)
          Checks whether this node contains the given position.
 boolean contains(int startLine, int startColumn, int endLine, int endColumn)
          Checks whether this node contains the given position.
 boolean contains(Node node)
          Checks whether this node contains the given node.
 boolean endsAfter(Node other)
          Determines whether this node starts after another one.
 boolean equals(Object o)
          Compares the specified object with this object for equality.
 int getEndColumn()
          Returns the column number where this node ends.
 int getEndLine()
          Returns the line number where this node ends.
 int getStartColumn()
          Returns the column number where this node starts.
 int getStartLine()
          Returns the line number where this node starts.
 String getText()
          Get the token text for this node
 int getType()
          Get the token type for this node
 void initialize(AST node)
          Initializes this node with information from the given node.
 void initialize(int type, String text)
          Initializes this node with the given information.
 void initialize(Token tok)
          Initializes this node with information from the given token.
 boolean isPositionKnown()
          Indicates whether this node has its location information set.
 void setEndColumn(int column)
          Sets the end column value.
 void setEndLine(int line)
          Sets the end line value.
 void setHiddenAfter(CommonHiddenStreamToken token)
          Sets the first hidden token that appears after this node.
 void setHiddenBefore(CommonHiddenStreamToken token)
          Sets the first hidden token that appears before this node.
 void setStartColumn(int column)
          Sets the column where this node starts.
 void setStartLine(int line)
          Sets the line where this node starts.
 void setText(String text)
          Sets the text of this node.
 void setType(int type)
          Sets the type of this node.
 boolean startsBefore(Node other)
          Determines whether this node starts before another one.
 String toString()
          Returns a string representation of this node.
 
Methods inherited from class de.hunsicker.antlr.CommonASTWithHiddenTokens
getHiddenAfter, getHiddenBefore
 
Methods inherited from class de.hunsicker.antlr.BaseAST
addChild, 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

text

protected String text
Node text.

endColumn

protected int endColumn
Column number where this node ends.

endLine

protected int endLine
Line number where this node ends.

startColumn

protected int startColumn
Column number where this node starts.

startLine

protected int startLine
Line number where this node starts.

type

protected int type
Node type.
Constructor Detail

Node

public Node()
Creates a new Node object.

Node

public Node(int type,
            String text,
            int startLine,
            int startColumn,
            int endLine,
            int endColumn)
Creates a new Node object.
Parameters:
type - node type
text - node text.
startLine - line number where this node starts.
startColumn - column number where this node starts.
endLine - line number where this node ends.
endColumn - column number where this node ends.

Node

public Node(int startLine,
            int startColumn,
            int endLine,
            int endColumn)
Creates a new Node object.
Parameters:
startLine - line number where this node starts.
startColumn - column number where this node starts.
endLine - line number where this node ends.
endColumn - column number where this node ends.

Node

public Node(int type,
            String text)
Creates a new Node object.
Parameters:
type - node type
text - node text.

Node

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

Node

public Node(String text)
Creates a new Node object.
Parameters:
text - text to add.
Method Detail

setEndColumn

public void setEndColumn(int column)
Sets the end column value.
Parameters:
column - new end column value.

getEndColumn

public int getEndColumn()
Returns the column number where this node ends.
Returns:
ending column number of this node.

setEndLine

public void setEndLine(int line)
Sets the end line value.
Parameters:
line - new end line value.

getEndLine

public int getEndLine()
Returns the line number where this node ends.
Returns:
ending line number of this node.

setHiddenAfter

public void setHiddenAfter(CommonHiddenStreamToken token)
Sets the first hidden token that appears after this node.
Parameters:
token - a hidden token.

setHiddenBefore

public void setHiddenBefore(CommonHiddenStreamToken token)
Sets the first hidden token that appears before this node.
Parameters:
token - a hidden token.

isPositionKnown

public boolean isPositionKnown()
Indicates whether this node has its location information set.
Returns:
true if this node has its location information set.

setStartColumn

public void setStartColumn(int column)
Sets the column where this node starts.
Parameters:
column - the column where this node starts.

getStartColumn

public int getStartColumn()
Returns the column number where this node starts.
Returns:
starting column number of this node.

setStartLine

public void setStartLine(int line)
Sets the line where this node starts.
Parameters:
line - the line where this node starts.

getStartLine

public int getStartLine()
Returns the line number where this node starts.
Returns:
starting line number of this node.

setText

public void setText(String text)
Sets the text of this node.
Overrides:
setText in class CommonAST
Parameters:
text - text to set.

getText

public String getText()
Get the token text for this node
Overrides:
getText in class CommonAST
Returns:
the text of this node.

setType

public void setType(int type)
Sets the type of this node.
Overrides:
setType in class CommonAST
Parameters:
type - type to set.

getType

public int getType()
Get the token type for this node
Overrides:
getType in class CommonAST
Returns:
the type of this node.

compareTo

public int compareTo(Object o)
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
Specified by:
compareTo in interface Comparable
Parameters:
o - the Object to be compared
Returns:
a negative integer, zero, or a positive integer as this node's extent starts before, with or after the extent of the specified node.
Throws:
NullPointerException - if object == null
ClassCastException - if the specified object's type prevents it from being compared to this object.

contains

public boolean contains(Node node)
Checks whether this node contains the given node.
Parameters:
node - to check.
Returns:
true if the given node is contained in this node.

contains

public boolean contains(int startLine,
                        int startColumn,
                        int endLine,
                        int endColumn)
Checks whether this node contains the given position.
Parameters:
startLine - start line to check.
startColumn - start column to check.
endLine - end line to check.
endColumn - end column to check.
Returns:
true if the given position is contained in this span.

contains

public boolean contains(int line,
                        int column)
Checks whether this node contains the given position.
Parameters:
line - line to check.
column - column to check.
Returns:
true if the given position is contained in this span.

endsAfter

public boolean endsAfter(Node other)
Determines whether this node starts after another one.
Parameters:
other - node to check for.
Returns:
true if this node ends after the other node.

equals

public boolean equals(Object o)
Compares the specified object with this object for equality. Returns true if and only if the specified object is also an Node and both nodes have the same text and type. So it does actually the same job as BaseAST.equals(AST).
Overrides:
equals in class Object
Parameters:
o - the object to be compared for equality with this node.
Returns:
true if the specified object is equal to this object.

initialize

public void initialize(AST node)
Initializes this node with information from the given node.
Overrides:
initialize in class CommonAST
Parameters:
node - node to setup this node with.

initialize

public void initialize(int type,
                       String text)
Initializes this node with the given information.
Overrides:
initialize in class CommonAST
Parameters:
type - type to set.
text - text to set.

initialize

public void initialize(Token tok)
Initializes this node with information from the given token.
Overrides:
initialize in class CommonASTWithHiddenTokens
Parameters:
tok - token to setup this node with.

startsBefore

public boolean startsBefore(Node other)
Determines whether this node starts before another one.
Parameters:
other - node to check for.
Returns:
true if this node starts before the other one.

toString

public String toString()
Returns a string representation of this node.
Overrides:
toString in class BaseAST
Returns:
a string representation of this node.

Jalopy 1.0b10

Submit a bug or feature.

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