org.antlr.runtime
Class CommonToken

java.lang.Object
  extended by org.antlr.runtime.CommonToken
All Implemented Interfaces:
java.io.Serializable, Token

public class CommonToken
extends java.lang.Object
implements Token, java.io.Serializable

See Also:
Serialized Form

Field Summary
protected  int channel
           
protected  int charPositionInLine
           
protected  int index
          What token number is this from 0..n-1 tokens; < 0 implies invalid index
protected  CharStream input
           
protected  int line
           
protected  int start
          The char position into the input buffer where this token starts
protected  int stop
          The char position into the input buffer where this token stops
protected  java.lang.String text
          We need to be able to change the text once in a while.
protected  int type
           
 
Fields inherited from interface org.antlr.runtime.Token
DEFAULT_CHANNEL, DOWN, EOF, EOF_TOKEN, EOR_TOKEN_TYPE, HIDDEN_CHANNEL, INVALID_TOKEN, INVALID_TOKEN_TYPE, MIN_TOKEN_TYPE, SKIP_TOKEN, UP
 
Constructor Summary
CommonToken(CharStream input, int type, int channel, int start, int stop)
           
CommonToken(int type)
           
CommonToken(int type, java.lang.String text)
           
CommonToken(Token oldToken)
           
 
Method Summary
 int getChannel()
           
 int getCharPositionInLine()
          The index of the first character relative to the beginning of the line 0..n-1
 CharStream getInputStream()
          From what character stream was this token created? You don't have to implement but it's nice to know where a Token comes from if you have include files etc...
 int getLine()
          The line number on which this token was matched; line=1..n
 int getStartIndex()
           
 int getStopIndex()
           
 java.lang.String getText()
          Get the text of the token
 int getTokenIndex()
          An index from 0..n-1 of the token object in the input stream.
 int getType()
           
 void setChannel(int channel)
           
 void setCharPositionInLine(int charPositionInLine)
           
 void setInputStream(CharStream input)
           
 void setLine(int line)
           
 void setStartIndex(int start)
           
 void setStopIndex(int stop)
           
 void setText(java.lang.String text)
          Override the text for this token.
 void setTokenIndex(int index)
           
 void setType(int type)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

type

protected int type

line

protected int line

charPositionInLine

protected int charPositionInLine

channel

protected int channel

input

protected transient CharStream input

text

protected java.lang.String text
We need to be able to change the text once in a while. If this is non-null, then getText should return this. Note that start/stop are not affected by changing this.


index

protected int index
What token number is this from 0..n-1 tokens; < 0 implies invalid index


start

protected int start
The char position into the input buffer where this token starts


stop

protected int stop
The char position into the input buffer where this token stops

Constructor Detail

CommonToken

public CommonToken(int type)

CommonToken

public CommonToken(CharStream input,
                   int type,
                   int channel,
                   int start,
                   int stop)

CommonToken

public CommonToken(int type,
                   java.lang.String text)

CommonToken

public CommonToken(Token oldToken)
Method Detail

getType

public int getType()
Specified by:
getType in interface Token

setLine

public void setLine(int line)
Specified by:
setLine in interface Token

getText

public java.lang.String getText()
Description copied from interface: Token
Get the text of the token

Specified by:
getText in interface Token

setText

public void setText(java.lang.String text)
Override the text for this token. getText() will return this text rather than pulling from the buffer. Note that this does not mean that start/stop indexes are not valid. It means that that input was converted to a new string in the token object.

Specified by:
setText in interface Token

getLine

public int getLine()
Description copied from interface: Token
The line number on which this token was matched; line=1..n

Specified by:
getLine in interface Token

getCharPositionInLine

public int getCharPositionInLine()
Description copied from interface: Token
The index of the first character relative to the beginning of the line 0..n-1

Specified by:
getCharPositionInLine in interface Token

setCharPositionInLine

public void setCharPositionInLine(int charPositionInLine)
Specified by:
setCharPositionInLine in interface Token

getChannel

public int getChannel()
Specified by:
getChannel in interface Token

setChannel

public void setChannel(int channel)
Specified by:
setChannel in interface Token

setType

public void setType(int type)
Specified by:
setType in interface Token

getStartIndex

public int getStartIndex()

setStartIndex

public void setStartIndex(int start)

getStopIndex

public int getStopIndex()

setStopIndex

public void setStopIndex(int stop)

getTokenIndex

public int getTokenIndex()
Description copied from interface: Token
An index from 0..n-1 of the token object in the input stream. This must be valid in order to use the ANTLRWorks debugger.

Specified by:
getTokenIndex in interface Token

setTokenIndex

public void setTokenIndex(int index)
Specified by:
setTokenIndex in interface Token

getInputStream

public CharStream getInputStream()
Description copied from interface: Token
From what character stream was this token created? You don't have to implement but it's nice to know where a Token comes from if you have include files etc... on the input.

Specified by:
getInputStream in interface Token

setInputStream

public void setInputStream(CharStream input)
Specified by:
setInputStream in interface Token

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2013. All Rights Reserved.