📄 token.java
字号:
/*
* JVending - J2ME MMS Client
*
* Distributed under Apache style software license included with the source code.
*/
package org.jvending.messaging.wsp.tokens;
/**
* @author Shane Isbell
* @version 1.0.0a
* @created 04/03/27
*/
public class Token {
public static final TokenType MULTI_OCTET_INTEGER = new TokenType("MULTI_OCTET_INTEGER");
public static final TokenType UINTVAR_INTEGER = new TokenType("UINTVAR_INTEGER");
public static final TokenType QUOTED_STRING = new TokenType("QUOTED_STRING");
public static final TokenType TEXT_STRING = new TokenType("TEXT_STRING");
public static final TokenType EXTENSION_MEDIA = new TokenType("EXTENSION_MEDIA");
public static final TokenType SHORT_INTEGER = new TokenType("SHORT_INTEGER");
public static final TokenType SHORT_LENGTH = new TokenType("SHORT_LENGTH");
public static final TokenType DATA_OCTETS = new TokenType("DATA_OCTETS");
public static final TokenType EOF = new TokenType("EOF");
protected TokenType tokenType;
protected Object tokenObject;
//can tell everything about token type based upon the first octet
public Token(TokenType tokenType, Object tokenObject) {
this.tokenType = tokenType;
this.tokenObject = tokenObject;
}
public String getStringValue() {
if(tokenObject instanceof String)
return (String) tokenObject;
else
return null;
}
public int getIntValue() {
if(tokenObject instanceof Integer)
return ((Integer) tokenObject).intValue();
else
return -1;
}
public long getLongValue() {
if(tokenObject instanceof Long)
return ((Long) tokenObject).longValue();
else
return -11;
}
public int[] getOctets() {
if(tokenObject instanceof int[])
return ( (int[]) tokenObject);
else
return null;
}
public boolean isQuotedString() {
return tokenType == QUOTED_STRING;
}
public boolean isMultiOctetInteger() {
return tokenType == MULTI_OCTET_INTEGER;
}
public boolean isTextString() {
return tokenType == TEXT_STRING;
}
public boolean isExtensionMedia() {
return tokenType == EXTENSION_MEDIA;
}
public boolean isShortInteger() {
return tokenType == SHORT_INTEGER;
}
public boolean isUintvarInteger() {
return tokenType == UINTVAR_INTEGER;
}
public boolean isShortLength() {
return tokenType == SHORT_LENGTH;
}
public boolean isEndOfFile() {
return tokenType == EOF;
}
public String toString() {
return (tokenType + " : " + tokenObject);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -