Package de.jplag
Class Token
java.lang.Object
de.jplag.Token
This class represents a token in a source code. It can represent keywords, identifiers, syntactical structures etc.
What types of tokens there are depends on the specific language, meaning JPlag does not enforce a specific token set.
The language parsers decide what is a token and what is not.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intIndicates that the requested field has no value. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic TokenCreates a token of typeFILE_ENDwithout information about line, column, and length.intReturns the character index which denotes where the code sections represented by this token starts in the line.getFile()intGives the length if the code sections represented by this token.intgetLine()Gives the line index denoting in which line the code sections represented by this token starts.getType()
-
Field Details
-
NO_VALUE
public static final int NO_VALUEIndicates that the requested field has no value.- See Also:
-
-
Constructor Details
-
Token
Creates a token with column and length information.- Parameters:
type- is the token type.file- is the name of the source code file.line- is the line index in the source code where the token resides. Index is 1-based.column- is the column index, meaning where the token starts in the line. Index is 1-based.length- is the length of the token in the source code.
-
-
Method Details
-
fileEnd
Creates a token of typeFILE_ENDwithout information about line, column, and length.- Parameters:
file- is the name of the source code file.
-
getColumn
public int getColumn()Returns the character index which denotes where the code sections represented by this token starts in the line.- Returns:
- the character index in the line.
-
getFile
- Returns:
- the name of the file where the source code that the token represents is located in.
-
getLength
public int getLength()Gives the length if the code sections represented by this token.- Returns:
- the length in characters.
-
getLine
public int getLine()Gives the line index denoting in which line the code sections represented by this token starts.- Returns:
- the line index.
-
getType
- Returns:
- the type of the token.
-