本文整理匯總了Java中org.codehaus.jackson.JsonToken.isNumeric方法的典型用法代碼示例。如果您正苦於以下問題:Java JsonToken.isNumeric方法的具體用法?Java JsonToken.isNumeric怎麽用?Java JsonToken.isNumeric使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.codehaus.jackson.JsonToken
的用法示例。
在下文中一共展示了JsonToken.isNumeric方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getCircle
import org.codehaus.jackson.JsonToken; //導入方法依賴的package包/類
private Object getCircle(JsonParser jp) throws JsonParseException,
IOException {
JsonToken token = jp.getCurrentToken();
Circle result = new Circle();
while (!token.equals(JsonToken.END_OBJECT)) {
token = jp.nextToken();
if (jp.getCurrentName().equalsIgnoreCase("centerLatitude")) {
if (token.isNumeric()) {
result.setCenterLatitude(jp.getFloatValue());
} else {
result.setCenterLatitude(Float.parseFloat(jp.getText()));
}
} else if (jp.getCurrentName().equalsIgnoreCase("centerLongitude")) {
if (token.isNumeric()) {
result.setCenterLongitude(jp.getFloatValue());
} else {
result.setCenterLongitude(Float.parseFloat(jp.getText()));
}
} else if (jp.getCurrentName().equalsIgnoreCase("radius")) {
if (token.isNumeric()) {
result.setRadius(jp.getFloatValue());
} else {
result.setRadius(Float.parseFloat(jp.getText()));
}
} else {
throw new JsonParseException("unknown field for circle", null);
}
token = jp.nextToken();
}
return result;
}
示例2: getPoint
import org.codehaus.jackson.JsonToken; //導入方法依賴的package包/類
private Object getPoint(JsonParser jp) throws JsonParseException,
IOException {
JsonToken token = jp.getCurrentToken();
Point result = new Point();
while (!token.equals(JsonToken.END_OBJECT)) {
token = jp.nextToken();
if (jp.getCurrentName().equalsIgnoreCase("latitude")) {
if (token.isNumeric()) {
result.setLatitude(jp.getFloatValue());
} else {
result.setLatitude(Float.parseFloat(jp.getText()));
}
} else if (jp.getCurrentName().equalsIgnoreCase("longitude")) {
if (token.isNumeric()) {
result.setLongitude(jp.getFloatValue());
} else {
result.setLongitude(Float.parseFloat(jp.getText()));
}
} else {
throw new JsonParseException("unknown field for circle", null);
}
token = jp.nextToken();
}
return result;
}
示例3: deserialize
import org.codehaus.jackson.JsonToken; //導入方法依賴的package包/類
public StackTraceElement deserialize(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
throws IOException, JsonProcessingException
{
if (paramJsonParser.getCurrentToken() == JsonToken.START_OBJECT)
{
String str1 = "";
String str2 = "";
String str3 = "";
int i = -1;
while (true)
{
JsonToken localJsonToken = paramJsonParser.nextValue();
if (localJsonToken == JsonToken.END_OBJECT)
break;
String str4 = paramJsonParser.getCurrentName();
if ("className".equals(str4))
{
str1 = paramJsonParser.getText();
continue;
}
if ("fileName".equals(str4))
{
str3 = paramJsonParser.getText();
continue;
}
if ("lineNumber".equals(str4))
{
if (localJsonToken.isNumeric())
{
i = paramJsonParser.getIntValue();
continue;
}
throw JsonMappingException.from(paramJsonParser, "Non-numeric token (" + localJsonToken + ") for property 'lineNumber'");
}
if ("methodName".equals(str4))
{
str2 = paramJsonParser.getText();
continue;
}
if ("nativeMethod".equals(str4))
continue;
handleUnknownProperty(paramJsonParser, paramDeserializationContext, this._valueClass, str4);
}
return new StackTraceElement(str1, str2, str3, i);
}
throw paramDeserializationContext.mappingException(this._valueClass);
}
示例4: getPolygon
import org.codehaus.jackson.JsonToken; //導入方法依賴的package包/類
private Object getPolygon(JsonParser jp) throws JsonParseException,
IOException {
JsonToken token = jp.nextToken();
if (!token.equals(JsonToken.START_ARRAY)) {
throw new JsonParseException("Vertices has to be an array", null);
}
token = jp.nextToken();
Polygon result = new Polygon();
ArrayList<Vertex> vertices = new ArrayList<Vertex>();
while (!token.equals(JsonToken.END_ARRAY)) {
if (token.equals(JsonToken.START_OBJECT)) {
Vertex vertex = new Vertex();
while (!token.equals(JsonToken.END_OBJECT)) {
if (token.equals(JsonToken.FIELD_NAME)) {
token = jp.nextToken();
if (jp.getCurrentName().equalsIgnoreCase("latitude")) {
if (token.isNumeric()) {
vertex.setLatitude(jp.getFloatValue());
} else {
vertex.setLatitude(Float.parseFloat(jp
.getText()));
}
} else if (jp.getCurrentName().equalsIgnoreCase(
"longitude")) {
if (token.isNumeric()) {
vertex.setLongitude(jp.getFloatValue());
} else {
vertex.setLongitude(Float.parseFloat(jp
.getText()));
}
}
}
token = jp.nextToken();
}
vertices.add(vertex);
}
token = jp.nextToken();
}
jp.nextToken();
result.setVertexList(vertices);
return result;
}