本文整理匯總了Java中com.fasterxml.jackson.core.JsonParser.getCurrentLocation方法的典型用法代碼示例。如果您正苦於以下問題:Java JsonParser.getCurrentLocation方法的具體用法?Java JsonParser.getCurrentLocation怎麽用?Java JsonParser.getCurrentLocation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.fasterxml.jackson.core.JsonParser
的用法示例。
在下文中一共展示了JsonParser.getCurrentLocation方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: deserialize
import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
@Override
public I18NStrings deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException,
JsonProcessingException
{
Map<String, LanguageString> strings = Maps.newHashMap();
JsonToken currentToken = jp.getCurrentToken();
if( currentToken != JsonToken.START_OBJECT )
{
throw new JsonParseException("Must be an object", jp.getCurrentLocation());
}
while( jp.nextToken() == JsonToken.FIELD_NAME )
{
String textValue = jp.nextTextValue();
LanguageBundle tempBundle = LangUtils.createTempLangugageBundle(null, textValue);
LanguageString tempLangString = LangUtils.createLanguageString(tempBundle, CurrentLocale.getLocale(),
textValue);
strings.put(jp.getCurrentName(), tempLangString);
}
return new SimpleI18NStrings(strings);
}
示例2: testLocation
import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
public void testLocation() throws Exception
{
JsonFactory jf = new JsonFactory();
JsonParser jp = jf.createParser(ObjectReadContext.empty(), " { }");
assertToken(JsonToken.START_OBJECT, jp.nextToken());
JsonLocation loc = jp.getCurrentLocation();
byte[] stuff = jdkSerialize(loc);
JsonLocation loc2 = jdkDeserialize(stuff);
assertNotNull(loc2);
assertEquals(loc.getLineNr(), loc2.getLineNr());
assertEquals(loc.getColumnNr(), loc2.getColumnNr());
jp.close();
}
示例3: deserialize
import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
@Override
public LineString deserialize(JsonParser jp, DeserializationContext ctxt)
throws IOException, JsonProcessingException {
Geometry geom = parse(jp);
if(geom instanceof LineString) {
return (LineString)geom;
}
throw new JsonParseException(jp, "parsed geometry was not a LineString!", jp.getCurrentLocation());
}
示例4: parse
import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
private Geometry parse(JsonParser jp) throws IOException, JsonProcessingException {
WKTReader reader = new WKTReader();
Geometry geom;
try {
geom = reader.read(jp.getText());
} catch (ParseException e) {
throw new JsonParseException(jp, "wkt not parsable", jp.getCurrentLocation(), e);
}
return geom;
}
示例5: throwE
import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
private static void throwE(JsonParser jp, String e) throws JsonParseException {
throw new JsonParseException(e, jp.getCurrentLocation());
}