Top Fields Constructors Methods
org.antlr.runtime

public Class CommonToken

extends Object
implements Token, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, org.antlr.runtime.Token
Imports
java.io.Serializable

Field Summary

Modifier and TypeField and Description
protected int
protected int
protected int
index

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

protected transient CharStream
protected int
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 String
text

We need to be able to change the text once in a while.

protected int

Constructor Summary

AccessConstructor and Description
public
CommonToken(int type)

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

public
CommonToken(int type, String text)

public
CommonToken(Token oldToken)

Method Summary

Modifier and TypeMethod and Description
public int
public int
getCharPositionInLine()

Implements org.antlr.runtime.Token.getCharPositionInLine.

The index of the first character relative to the beginning of the line 0..n-1
public CharStream
getInputStream()

Implements org.antlr.runtime.Token.getInputStream.

From what character stream was this token created?
public int
getLine()

Implements org.antlr.runtime.Token.getLine.

The line number on which this token was matched; line=1..n
public int
public int
public String
getText()

Implements org.antlr.runtime.Token.getText.

Get the text of the token
public int
getTokenIndex()

Implements org.antlr.runtime.Token.getTokenIndex.

An index from 0..n-1 of the token object in the input stream.
public int
public void
public void
public void
public void
public void
setStartIndex(int start)

public void
setStopIndex(int stop)

public void
setText(String text)

Implements org.antlr.runtime.Token.setText.

Override the text for this token.
public void
public void
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

channelback to summary
protected int channel
charPositionInLineback to summary
protected int charPositionInLine
indexback to summary
protected int index

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

inputback to summary
protected transient CharStream input
lineback to summary
protected int line
startback to summary
protected int start

The char position into the input buffer where this token starts

stopback to summary
protected int stop

The char position into the input buffer where this token stops

textback to summary
protected 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.

typeback to summary
protected int type

Constructor Detail

CommonTokenback to summary
public CommonToken(int type)
CommonTokenback to summary
public CommonToken(CharStream input, int type, int channel, int start, int stop)
CommonTokenback to summary
public CommonToken(int type, String text)
CommonTokenback to summary
public CommonToken(Token oldToken)

Method Detail

getChannelback to summary
public int getChannel()

Implements org.antlr.runtime.Token.getChannel.

Annotations
@Override
getCharPositionInLineback to summary
public int getCharPositionInLine()

Implements org.antlr.runtime.Token.getCharPositionInLine.

Doc from org.antlr.runtime.Token.getCharPositionInLine.

The index of the first character relative to the beginning of the line 0..n-1

Annotations
@Override
getInputStreamback to summary
public CharStream getInputStream()

Implements org.antlr.runtime.Token.getInputStream.

Doc from org.antlr.runtime.Token.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... on the input.

Annotations
@Override
getLineback to summary
public int getLine()

Implements org.antlr.runtime.Token.getLine.

Doc from org.antlr.runtime.Token.getLine.

The line number on which this token was matched; line=1..n

Annotations
@Override
getStartIndexback to summary
public int getStartIndex()
getStopIndexback to summary
public int getStopIndex()
getTextback to summary
public String getText()

Implements org.antlr.runtime.Token.getText.

Doc from org.antlr.runtime.Token.getText.

Get the text of the token

Annotations
@Override
getTokenIndexback to summary
public int getTokenIndex()

Implements org.antlr.runtime.Token.getTokenIndex.

Doc from org.antlr.runtime.Token.getTokenIndex.

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.

Annotations
@Override
getTypeback to summary
public int getType()

Implements org.antlr.runtime.Token.getType.

Annotations
@Override
setChannelback to summary
public void setChannel(int channel)

Implements org.antlr.runtime.Token.setChannel.

Annotations
@Override
setCharPositionInLineback to summary
public void setCharPositionInLine(int charPositionInLine)

Implements org.antlr.runtime.Token.setCharPositionInLine.

Annotations
@Override
setInputStreamback to summary
public void setInputStream(CharStream input)

Implements org.antlr.runtime.Token.setInputStream.

Annotations
@Override
setLineback to summary
public void setLine(int line)

Implements org.antlr.runtime.Token.setLine.

Annotations
@Override
setStartIndexback to summary
public void setStartIndex(int start)
setStopIndexback to summary
public void setStopIndex(int stop)
setTextback to summary
public void setText(String text)

Implements org.antlr.runtime.Token.setText.

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.

Annotations
@Override
setTokenIndexback to summary
public void setTokenIndex(int index)

Implements org.antlr.runtime.Token.setTokenIndex.

Annotations
@Override
setTypeback to summary
public void setType(int type)

Implements org.antlr.runtime.Token.setType.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override