Class TopLevelClass.Default.Token

java.lang.Object
  |
  +--TopLevelClass.Default.Node
        |
        +--TopLevelClass.Default.Token
All Implemented Interfaces:
TopLevelClass.Node, TopLevelClass.Token
Enclosing class:
TopLevelClass.Default

public static class TopLevelClass.Default.Token
extends TopLevelClass.Default.Node
implements TopLevelClass.Token

Provides a simple implementation of TopLevelClass.Token.

Since:
notavaCC 1.0

Constructor Summary
TopLevelClass.Default.Token(int symbolID, String image)
          Constructs a token.
TopLevelClass.Default.Token(int symbolID, String image, String originalImage, String sourceName, int index, int line, int column)
          Constructs a token.
TopLevelClass.Default.Token(int symbolID, String image, String originalImage, TopLevelClass.Token token)
          Constructs a token.
 
Method Summary
 int getColumn()
          Returns the one-based column number in the source where this token begins.
 String getImage()
          Returns the string this token corresponds to.
 int getIndex()
          Returns the zero-based index number in the source where this token begins.
 int getLine()
          Returns the one-based line number in the source where this token begins.
 String getOriginalImage()
          Returns the string this token corresponds to.
 String getSourceName()
          Returns the source name this token coressponds to.
 int getSymbolID()
          Returns the kind of this token.
 boolean isWhite()
          Returnds true if this is a white token.
 String toString()
          Returns the image and the position of this token if supported.
 
Methods inherited from class TopLevelClass.Default.Node
accept, getChildNodes, getParentNode, replace, replaceChild, setParentNode
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface TopLevelClass.Node
accept, getChildNodes, getParentNode, setParentNode
 

Constructor Detail

TopLevelClass.Default.Token

public TopLevelClass.Default.Token(int symbolID,
                                   String image)
Constructs a token.

Parameters:
symbolID - the symbol ID of the token, returned by getSymbolID and getOriginalImage.
image - the image string, returned by getImage.
Since:
notavaCC 1.0

TopLevelClass.Default.Token

public TopLevelClass.Default.Token(int symbolID,
                                   String image,
                                   String originalImage,
                                   String sourceName,
                                   int index,
                                   int line,
                                   int column)
Constructs a token.

Parameters:
symbolID - the symbol ID of the token, returned by getSymbolID.
image - the image string, returned by getImage.
originalImage - the image string, returned by getOriginalImage.
sourceName - the source name returned by getSourceName, or null if not supported.
index - the index returned by getIndex, or -1 if not supported.
line - the line number returned by getLine, or -1 if not supported.
column - the column number returned by getColumn, or -1 if not supported.
Since:
notavaCC 1.0

TopLevelClass.Default.Token

public TopLevelClass.Default.Token(int symbolID,
                                   String image,
                                   String originalImage,
                                   TopLevelClass.Token token)
Constructs a token.

Parameters:
symbolID - the symbol ID of the token, returned by getSymbolID.
image - the image string, returned by getImage.
originalImage - the image string, returned by getOriginalImage.
token - a token that gives the returned value of getSourceName, getIndex, getLine and getColumn.
Since:
notavaCC 1.0
Method Detail

getSymbolID

public int getSymbolID()
Description copied from interface: TopLevelClass.Token
Returns the kind of this token.

The result value should be one of the followings:

valuedescribed token
TopLevelClass.EOF_TOKEN <EOF>
TopLevelClass.TOKEN_TERMINAL TERMINAL

Specified by:
getSymbolID in interface TopLevelClass.Token
Returns:
the kind of this token.

isWhite

public boolean isWhite()
Description copied from interface: TopLevelClass.Token
Returnds true if this is a white token.

Specified by:
isWhite in interface TopLevelClass.Token
Returns:
true if this is a while token.

getImage

public String getImage()
Description copied from interface: TopLevelClass.Token
Returns the string this token corresponds to.

If the string contains some meta notation like Unicode escapes, the returned value is the represented string (e.g., A) rather than the representation (e.g., \u0041). If not, the returned value is the same as TopLevelClass.Token.getOriginalImage().

Specified by:
getImage in interface TopLevelClass.Token
Returns:
the string this token corresponds to.
See Also:
TopLevelClass.Token.getOriginalImage()

getOriginalImage

public String getOriginalImage()
Description copied from interface: TopLevelClass.Token
Returns the string this token corresponds to.

If the string contains some meta notation like Unicode escapes, the returned value is the representation (e.g., \u0041) rather than the represented string (e.g., A). If not, the returned value is the same as TopLevelClass.Token.getImage().

Specified by:
getOriginalImage in interface TopLevelClass.Token
Returns:
the string this token corresponds to.
See Also:
TopLevelClass.Token.getImage()

getSourceName

public String getSourceName()
                     throws UnsupportedOperationException
Description copied from interface: TopLevelClass.Token
Returns the source name this token coressponds to.

Specified by:
getSourceName in interface TopLevelClass.Token
Returns:
the source name this token coressponds to.
Throws:
UnsupportedOperationException - if the method is not suported.

getIndex

public int getIndex()
             throws UnsupportedOperationException
Description copied from interface: TopLevelClass.Token
Returns the zero-based index number in the source where this token begins.

Specified by:
getIndex in interface TopLevelClass.Token
Returns:
the index number in the source where this token begins.
Throws:
UnsupportedOperationException - if the method is not suported.

getLine

public int getLine()
            throws UnsupportedOperationException
Description copied from interface: TopLevelClass.Token
Returns the one-based line number in the source where this token begins.

Specified by:
getLine in interface TopLevelClass.Token
Returns:
the line number in the source where this token begins.
Throws:
UnsupportedOperationException - if the method is not suported.

getColumn

public int getColumn()
              throws UnsupportedOperationException
Description copied from interface: TopLevelClass.Token
Returns the one-based column number in the source where this token begins.

Specified by:
getColumn in interface TopLevelClass.Token
Returns:
the column number in the source where this token begins.
Throws:
UnsupportedOperationException - if the method is not suported.

toString

public String toString()
Description copied from interface: TopLevelClass.Token
Returns the image and the position of this token if supported. For instance, 'identifier' (line 2, column 3) or 'identifier'. The format is not specified strictly.

Specified by:
toString in interface TopLevelClass.Token
Overrides:
toString in class TopLevelClass.Default.Node
Returns:
the image and the parenthesized position of this token.