本文整理汇总了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;
}