Subversion Repositories general

Compare Revisions

Ignore whitespace Rev 1004 → Rev 1005

/zpath/trunk/src/ak/zpath/Token.java
0,0 → 1,66
package ak.zpath;
 
public class Token
{
public static final int TOKEN_SLASH = 1;
public static final int TOKEN_OPEN_BRACKET = 2;
public static final int TOKEN_CLOSE_BRACKET = 3;
public static final int TOKEN_AT = 4;
public static final int TOKEN_SHARP = 5;
public static final int TOKEN_STRING = 6;
public static final int TOKEN_EQUAL = 7;
public static final int TOKEN_VARIABLE = 8;
public static final int TOKEN_ASSIGN = 9;
public static final int TOKEN_AND = 10;
public static final int TOKEN_OR = 11;
public static final int TOKEN_NEW = 12;
public static final int TOKEN_NAME = 13;
public static final int TOKEN_APPEND = 14;
 
private int type;
private int pos;
private String value;
 
public Token(int type, int pos, String value)
{
this.type = type;
this.pos = pos;
this.value = value;
}
 
public int getType()
{
return type;
}
 
public int getPosition()
{
return pos;
}
 
public String getValue()
{
return value;
}
 
public String toString()
{
switch(type) {
case Token.TOKEN_SLASH: return "slash";
case Token.TOKEN_OPEN_BRACKET: return "open bracket";
case Token.TOKEN_CLOSE_BRACKET: return "close bracket";
case Token.TOKEN_AT: return "at";
case Token.TOKEN_SHARP: return "sharp";
case Token.TOKEN_STRING: return "string [" + value + "]";
case Token.TOKEN_EQUAL: return "equal";
case Token.TOKEN_VARIABLE: return "variable [" + value + "]";
case Token.TOKEN_ASSIGN: return "assign";
case Token.TOKEN_APPEND: return "append";
case Token.TOKEN_AND: return "and";
case Token.TOKEN_OR: return "or";
case Token.TOKEN_NEW: return "new";
case Token.TOKEN_NAME: return "name [" + value + "]";
default: throw new RuntimeException("Unknown token type: " + type);
}
}
}