当前位置: 首页>>代码示例>>Java>>正文


Java JsonToken.equals方法代码示例

本文整理汇总了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;
}
 
开发者ID:yandex,项目名称:opentsdb-flume,代码行数:19,代码来源:LegacyHttpSource.java

示例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;
}
 
开发者ID:Aeronbroker,项目名称:Aeron,代码行数:23,代码来源:MetadataValueDeserializer.java

示例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;
}
 
开发者ID:Aeronbroker,项目名称:Aeron,代码行数:22,代码来源:MetadataValueDeserializer.java

示例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;
}
 
开发者ID:Aeronbroker,项目名称:Aeron,代码行数:21,代码来源:MetadataValueDeserializer.java

示例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;
}
 
开发者ID:Aeronbroker,项目名称:Aeron,代码行数:34,代码来源:MetadataValueDeserializer.java

示例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;
}
 
开发者ID:Aeronbroker,项目名称:Aeron,代码行数:28,代码来源:MetadataValueDeserializer.java

示例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();

}
 
开发者ID:Aeronbroker,项目名称:Aeron,代码行数:43,代码来源:MetadataValueDeserializer.java

示例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;
}
 
开发者ID:Aeronbroker,项目名称:Aeron,代码行数:45,代码来源:MetadataValueDeserializer.java


注:本文中的org.codehaus.jackson.JsonToken.equals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。