📄 wsptoken.java
字号:
/*
* JVending - J2ME MMS Client
* Copyright (C) 2004 Shane Isbell
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.jvending.messaging.impl.mms;
/**
* @author Shane Isbell
* @version 1.0.0a
* @created 04/03/27
*/
public class WspToken {
public static final WspTokenType MULTI_OCTET_INTEGER = new WspTokenType("MULTI_OCTET_INTEGER");
public static final WspTokenType UINTVAR_INTEGER = new WspTokenType("UINTVAR_INTEGER");
public static final WspTokenType QUOTED_STRING = new WspTokenType("QUOTED_STRING");
public static final WspTokenType TEXT_STRING = new WspTokenType("TEXT_STRING");
public static final WspTokenType EXTENSION_MEDIA = new WspTokenType("EXTENSION_MEDIA");
public static final WspTokenType SHORT_INTEGER = new WspTokenType("SHORT_INTEGER");
public static final WspTokenType SHORT_LENGTH = new WspTokenType("SHORT_LENGTH");
public static final WspTokenType DATA_OCTETS = new WspTokenType("DATA_OCTETS");
public static final WspTokenType EOF = new WspTokenType("EOF");
protected WspTokenType wspTokenType;
protected Object tokenObject;
//can tell everything about token type based upon the first octet
public WspToken(WspTokenType wspTokenType, Object tokenObject) {
this.wspTokenType = wspTokenType;
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 wspTokenType == QUOTED_STRING;
}
public boolean isMultiOctetInteger() {
return wspTokenType == MULTI_OCTET_INTEGER;
}
public boolean isTextString() {
return wspTokenType == TEXT_STRING;
}
public boolean isExtensionMedia() {
return wspTokenType == EXTENSION_MEDIA;
}
public boolean isShortInteger() {
return wspTokenType == SHORT_INTEGER;
}
public boolean isUintvarInteger() {
return wspTokenType == UINTVAR_INTEGER;
}
public boolean isShortLength() {
return wspTokenType == SHORT_LENGTH;
}
public boolean isEndOfFile() {
return wspTokenType == EOF;
}
public String toString() {
return (wspTokenType + " : " + tokenObject);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -