本文整理汇总了Java中org.codehaus.jackson.JsonToken.equals方法的典型用法代码示例。如果您正苦于以下问题:Java JsonToken.equals方法的具体用法?Java JsonToken.equals怎么用?Java JsonToken.equals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.codehaus.jackson.JsonToken
的用法示例。
在下文中一共展示了JsonToken.equals方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseMetricArray
import org.codehaus.jackson.JsonToken; //导入方法依赖的package包/类
private int parseMetricArray(String metric, JsonParser parser) throws IOException {
JsonToken currentToken;
int illegalTokens = 0;
while ((currentToken = parser.nextToken()) != JsonToken.END_ARRAY) {
if(!currentToken.equals(JsonToken.START_OBJECT)) {
logger.warn("Illegal token: expected {}, but was {}: {}",
new Object[] {JsonToken.START_OBJECT, currentToken, parser.getText()});
illegalTokens++;
} else {
parseMetricObject(metric, parser);
}
}
return illegalTokens;
}
示例2: getAsJsonString
import org.codehaus.jackson.JsonToken; //导入方法依赖的package包/类
private Object getAsJsonString(JsonParser jp) throws JsonParseException,
IOException {
String asString = "";
JsonToken token = jp.getCurrentToken();
while (!token.equals(JsonToken.END_OBJECT)) {
String key = jp.getText();
token = jp.nextToken();
String value = jp.getText();
String.format("\"%s\" : \"%s\"", key, value);
if (asString.isEmpty()) {
asString += String.format("\"%s\" : \"%s\"", key, value);
} else {
asString += String.format(", \"%s\" : \"%s\"", key, value);
}
token = jp.nextToken();
}
asString = String.format("{%s}", asString);
return asString;
}
示例3: getSegment
import org.codehaus.jackson.JsonToken; //导入方法依赖的package包/类
private Object getSegment(JsonParser jp) throws JsonParseException,
IOException {
JsonToken token = jp.getCurrentToken();
Segment result = new Segment();
while (!token.equals(JsonToken.END_OBJECT)) {
token = jp.nextToken();
if (jp.getCurrentName().equalsIgnoreCase("height")) {
result.setHeight(jp.getDoubleValue());
} else if (jp.getCurrentName().equalsIgnoreCase("nw_Corner")) {
result.setNW_Corner(jp.getText());
} else if (jp.getCurrentName().equalsIgnoreCase("se_Corner")) {
result.setSE_Corner(jp.getText());
} else {
throw new JsonParseException("unknown field for segment", null);
}
token = jp.nextToken();
}
return result;
}
示例4: getPEPCredentials
import org.codehaus.jackson.JsonToken; //导入方法依赖的package包/类
private Object getPEPCredentials(JsonParser jp) throws JsonParseException,
IOException {
JsonToken token = jp.getCurrentToken();
PEPCredentials result = new PEPCredentials();
while (!token.equals(JsonToken.END_OBJECT)) {
token = jp.nextToken();
if (jp.getCurrentName().equalsIgnoreCase("username")) {
result.setUsername(jp.getText());
} else if (jp.getCurrentName().equalsIgnoreCase("password")) {
result.setPassword(jp.getText());
} else {
throw new JsonParseException(
"unknown field for pepcredentials", null);
}
token = jp.nextToken();
}
return result;
}
示例5: 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;
}
示例6: 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;
}
示例7: deserialize
import org.codehaus.jackson.JsonToken; //导入方法依赖的package包/类
@Override
public Object deserialize(JsonParser jp, DeserializationContext ctxt)
throws IOException, JsonProcessingException {
JsonToken token = jp.getCurrentToken();
if (token.equals(JsonToken.START_OBJECT)) {
token = jp.nextToken();
if (token.equals(JsonToken.FIELD_NAME)) {
String name = jp.getCurrentName();
name = name.toLowerCase();
try {
if ("vertices".equals(name)) {
return getPolygon(jp);
} else if ("centerlatitude".equals(name)
|| "centerlongitude".equals(name)
|| "radius".equals(name)) {
return getCircle(jp);
} else if ("height".equals(name)
|| "nw_corner".equals(name)
|| "se_corner".equals(name)) {
return getSegment(jp);
} else if ("username".equals(name)
|| "password".equals(name)) {
return getPEPCredentials(jp);
} else if ("latitude".equals(name)
|| "longitude".equals(name)) {
return getPoint(jp);
} else {
return getAsJsonString(jp);
}
} catch (JsonProcessingException e) {
logger.info("Error on parsing metadata");
}
} else {
return getAsJsonString(jp);
}
}
return jp.getText();
}
示例8: 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;
}