本文整理汇总了Java中org.codehaus.jackson.map.DeserializationContext.mappingException方法的典型用法代码示例。如果您正苦于以下问题:Java DeserializationContext.mappingException方法的具体用法?Java DeserializationContext.mappingException怎么用?Java DeserializationContext.mappingException使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.codehaus.jackson.map.DeserializationContext
的用法示例。
在下文中一共展示了DeserializationContext.mappingException方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deserialize
import org.codehaus.jackson.map.DeserializationContext; //导入方法依赖的package包/类
@Override
public Directive deserialize(JsonParser jp, DeserializationContext ctx)
throws IOException {
ObjectReader reader = ObjectMapperUtil.instance().getObjectReader();
ObjectNode obj = (ObjectNode) reader.readTree(jp);
Iterator<Map.Entry<String, JsonNode>> elementsIterator = obj.getFields();
String rawMessage = obj.toString();
DialogRequestIdHeader header = null;
JsonNode payloadNode = null;
ObjectReader headerReader =
ObjectMapperUtil.instance().getObjectReader(DialogRequestIdHeader.class);
while (elementsIterator.hasNext()) {
Map.Entry<String, JsonNode> element = elementsIterator.next();
if (element.getKey().equals("header")) {
header = headerReader.readValue(element.getValue());
}
if (element.getKey().equals("payload")) {
payloadNode = element.getValue();
}
}
if (header == null) {
throw ctx.mappingException("Missing header");
}
if (payloadNode == null) {
throw ctx.mappingException("Missing payload");
}
return createDirective(header, payloadNode, rawMessage);
}
示例2: deserialize
import org.codehaus.jackson.map.DeserializationContext; //导入方法依赖的package包/类
@Override
public Instant deserialize(final JsonParser parser, final DeserializationContext ctxt)
throws IOException, JsonProcessingException
{
final JsonToken jsonToken = parser.getCurrentToken();
if (jsonToken == JsonToken.VALUE_NUMBER_INT)
{
return new Instant(parser.getLongValue());
}
else if (jsonToken == JsonToken.VALUE_STRING)
{
final String str = parser.getText().trim();
if (str.length() == 0)
{
return null;
}
final DateTimeFormatter formatter = ISODateTimeFormat.dateTimeParser();
final DateTime dateTime = formatter.parseDateTime(str);
return new Instant(dateTime.getMillis());
}
throw ctxt.mappingException(Instant.class);
}
示例3: deserialize
import org.codehaus.jackson.map.DeserializationContext; //导入方法依赖的package包/类
public Map<Object, Object> deserialize(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
throws IOException, JsonProcessingException
{
JsonToken localJsonToken = paramJsonParser.getCurrentToken();
if ((localJsonToken != JsonToken.START_OBJECT) && (localJsonToken != JsonToken.FIELD_NAME) && (localJsonToken != JsonToken.END_OBJECT))
throw paramDeserializationContext.mappingException(getMapClass());
if (this._propertyBasedCreator != null)
return _deserializeUsingCreator(paramJsonParser, paramDeserializationContext);
if (this._defaultCtor == null)
throw paramDeserializationContext.instantiationException(getMapClass(), "No default constructor found");
try
{
Map localMap = (Map)this._defaultCtor.newInstance(new Object[0]);
_readAndBind(paramJsonParser, paramDeserializationContext, localMap);
return localMap;
}
catch (Exception localException)
{
}
throw paramDeserializationContext.instantiationException(getMapClass(), localException);
}
示例4: deserialize
import org.codehaus.jackson.map.DeserializationContext; //导入方法依赖的package包/类
public Enum<?> deserialize(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
throws IOException, JsonProcessingException
{
JsonToken localJsonToken = paramJsonParser.getCurrentToken();
if (localJsonToken == JsonToken.VALUE_STRING)
{
String str = paramJsonParser.getText();
Enum localEnum2 = this._resolver.findEnum(str);
if (localEnum2 == null)
throw paramDeserializationContext.weirdStringException(this._resolver.getEnumClass(), "value not one of declared Enum instance names");
return localEnum2;
}
if (localJsonToken == JsonToken.VALUE_NUMBER_INT)
{
if (paramDeserializationContext.isEnabled(DeserializationConfig.Feature.FAIL_ON_NUMBERS_FOR_ENUMS))
throw paramDeserializationContext.mappingException("Not allowed to deserialize Enum value out of JSON number (disable DeserializationConfig.Feature.FAIL_ON_NUMBERS_FOR_ENUMS to allow)");
int i = paramJsonParser.getIntValue();
Enum localEnum1 = this._resolver.getEnum(i);
if (localEnum1 == null)
throw paramDeserializationContext.weirdNumberException(this._resolver.getEnumClass(), "index value outside legal index range [0.." + this._resolver.lastValidIndex() + "]");
return localEnum1;
}
throw paramDeserializationContext.mappingException(this._resolver.getEnumClass());
}
示例5: deserialize
import org.codehaus.jackson.map.DeserializationContext; //导入方法依赖的package包/类
public BigDecimal deserialize(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
throws IOException, JsonProcessingException
{
JsonToken localJsonToken = paramJsonParser.getCurrentToken();
if ((localJsonToken == JsonToken.VALUE_NUMBER_INT) || (localJsonToken == JsonToken.VALUE_NUMBER_FLOAT))
return paramJsonParser.getDecimalValue();
if (localJsonToken == JsonToken.VALUE_STRING)
{
String str = paramJsonParser.getText().trim();
if (str.length() == 0)
return null;
try
{
BigDecimal localBigDecimal = new BigDecimal(str);
return localBigDecimal;
}
catch (IllegalArgumentException localIllegalArgumentException)
{
throw paramDeserializationContext.weirdStringException(this._valueClass, "not a valid representation");
}
}
throw paramDeserializationContext.mappingException(this._valueClass);
}
示例6: deserialize
import org.codehaus.jackson.map.DeserializationContext; //导入方法依赖的package包/类
@Override
public Set<Date> deserialize( final JsonParser parser, final DeserializationContext context )
throws IOException
{
if ( !parser.isExpectedStartArrayToken() )
{
throw context.mappingException( Set.class );
}
final HashSet<Date> result = new HashSet<Date>();
final DateFormat formatter = DateUtil.newDateFormatter();
JsonToken token;
while ( JsonToken.END_ARRAY != ( token = parser.nextToken() ) )
{
if ( JsonToken.VALUE_NULL == token )
{
throw context.mappingException( Set.class );
}
result.add( DateUtil.parse( formatter, parser.getText() ) );
}
return result;
}
示例7: deserialize
import org.codehaus.jackson.map.DeserializationContext; //导入方法依赖的package包/类
@Override
public Duration deserialize(final JsonParser parser, final DeserializationContext ctxt)
throws JsonParseException, IOException
{
final JsonToken jsonToken = parser.getCurrentToken();
if (jsonToken == JsonToken.VALUE_NUMBER_INT)
{
return new Duration(parser.getLongValue());
}
else if (jsonToken == JsonToken.VALUE_STRING)
{
final String str = parser.getText().trim();
if (str.length() == 0)
{
return null;
}
final PeriodFormatter formatter = ISOPeriodFormat.standard();
return formatter.parsePeriod(str).toStandardDuration();
}
throw ctxt.mappingException(Duration.class);
}
示例8: deserializeUsingCreator
import org.codehaus.jackson.map.DeserializationContext; //导入方法依赖的package包/类
public Object deserializeUsingCreator(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
throws IOException, JsonProcessingException
{
if (this._delegatingCreator != null)
try
{
Object localObject = this._delegatingCreator.deserialize(paramJsonParser, paramDeserializationContext);
return localObject;
}
catch (Exception localException)
{
wrapInstantiationProblem(localException, paramDeserializationContext);
}
throw paramDeserializationContext.mappingException(getBeanClass());
}
示例9: handleNonArray
import org.codehaus.jackson.map.DeserializationContext; //导入方法依赖的package包/类
private final String[] handleNonArray(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
throws IOException, JsonProcessingException
{
if (!paramDeserializationContext.isEnabled(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY))
throw paramDeserializationContext.mappingException(this._valueClass);
String[] arrayOfString = new String[1];
if (paramJsonParser.getCurrentToken() == JsonToken.VALUE_NULL);
for (String str = null; ; str = paramJsonParser.getText())
{
arrayOfString[0] = str;
return arrayOfString;
}
}
示例10: _parseLong
import org.codehaus.jackson.map.DeserializationContext; //导入方法依赖的package包/类
protected final Long _parseLong(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
throws IOException, JsonProcessingException
{
JsonToken localJsonToken1 = paramJsonParser.getCurrentToken();
Long localLong1;
if ((localJsonToken1 == JsonToken.VALUE_NUMBER_INT) || (localJsonToken1 == JsonToken.VALUE_NUMBER_FLOAT))
localLong1 = Long.valueOf(paramJsonParser.getLongValue());
JsonToken localJsonToken2;
do
{
while (true)
{
return localLong1;
if (localJsonToken1 != JsonToken.VALUE_STRING)
break;
String str = paramJsonParser.getText().trim();
int i = str.length();
localLong1 = null;
if (i == 0)
continue;
try
{
Long localLong2 = Long.valueOf(NumberInput.parseLong(str));
return localLong2;
}
catch (IllegalArgumentException localIllegalArgumentException)
{
throw paramDeserializationContext.weirdStringException(this._valueClass, "not a valid Long value");
}
}
localJsonToken2 = JsonToken.VALUE_NULL;
localLong1 = null;
}
while (localJsonToken1 == localJsonToken2);
throw paramDeserializationContext.mappingException(this._valueClass);
}
示例11: _parseLongPrimitive
import org.codehaus.jackson.map.DeserializationContext; //导入方法依赖的package包/类
protected final long _parseLongPrimitive(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
throws IOException, JsonProcessingException
{
long l1 = 0L;
JsonToken localJsonToken = paramJsonParser.getCurrentToken();
if ((localJsonToken == JsonToken.VALUE_NUMBER_INT) || (localJsonToken == JsonToken.VALUE_NUMBER_FLOAT))
l1 = paramJsonParser.getLongValue();
do
while (true)
{
return l1;
if (localJsonToken != JsonToken.VALUE_STRING)
break;
String str = paramJsonParser.getText().trim();
if (str.length() == 0)
continue;
try
{
long l2 = NumberInput.parseLong(str);
return l2;
}
catch (IllegalArgumentException localIllegalArgumentException)
{
throw paramDeserializationContext.weirdStringException(this._valueClass, "not a valid long value");
}
}
while (localJsonToken == JsonToken.VALUE_NULL);
throw paramDeserializationContext.mappingException(this._valueClass);
}
示例12: deserialize
import org.codehaus.jackson.map.DeserializationContext; //导入方法依赖的package包/类
public ArrayNode deserialize(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
throws IOException, JsonProcessingException
{
if (paramJsonParser.isExpectedStartArrayToken())
return deserializeArray(paramJsonParser, paramDeserializationContext);
throw paramDeserializationContext.mappingException(ArrayNode.class);
}
示例13: _parseDouble
import org.codehaus.jackson.map.DeserializationContext; //导入方法依赖的package包/类
protected final Double _parseDouble(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
throws IOException, JsonProcessingException
{
JsonToken localJsonToken1 = paramJsonParser.getCurrentToken();
Double localDouble1;
if ((localJsonToken1 == JsonToken.VALUE_NUMBER_INT) || (localJsonToken1 == JsonToken.VALUE_NUMBER_FLOAT))
localDouble1 = Double.valueOf(paramJsonParser.getDoubleValue());
JsonToken localJsonToken2;
do
{
while (true)
{
return localDouble1;
if (localJsonToken1 != JsonToken.VALUE_STRING)
break;
String str = paramJsonParser.getText().trim();
int i = str.length();
localDouble1 = null;
if (i == 0)
continue;
switch (str.charAt(0))
{
default:
case 'I':
case 'N':
case '-':
}
try
{
do
{
do
{
do
{
Double localDouble2 = Double.valueOf(parseDouble(str));
return localDouble2;
}
while ((!"Infinity".equals(str)) && (!"INF".equals(str)));
return Double.valueOf((1.0D / 0.0D));
}
while (!"NaN".equals(str));
return Double.valueOf((0.0D / 0.0D));
}
while ((!"-Infinity".equals(str)) && (!"-INF".equals(str)));
return Double.valueOf((-1.0D / 0.0D));
}
catch (IllegalArgumentException localIllegalArgumentException)
{
throw paramDeserializationContext.weirdStringException(this._valueClass, "not a valid Double value");
}
}
localJsonToken2 = JsonToken.VALUE_NULL;
localDouble1 = null;
}
while (localJsonToken1 == localJsonToken2);
throw paramDeserializationContext.mappingException(this._valueClass);
}
示例14: _parseDoublePrimitive
import org.codehaus.jackson.map.DeserializationContext; //导入方法依赖的package包/类
protected final double _parseDoublePrimitive(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
throws IOException, JsonProcessingException
{
double d1 = 0.0D;
JsonToken localJsonToken = paramJsonParser.getCurrentToken();
if ((localJsonToken == JsonToken.VALUE_NUMBER_INT) || (localJsonToken == JsonToken.VALUE_NUMBER_FLOAT))
d1 = paramJsonParser.getDoubleValue();
do
while (true)
{
return d1;
if (localJsonToken != JsonToken.VALUE_STRING)
break;
String str = paramJsonParser.getText().trim();
if (str.length() == 0)
continue;
switch (str.charAt(0))
{
default:
case 'I':
case 'N':
case '-':
}
try
{
do
{
do
{
do
{
double d2 = parseDouble(str);
return d2;
}
while ((!"Infinity".equals(str)) && (!"INF".equals(str)));
return (1.0D / 0.0D);
}
while (!"NaN".equals(str));
return (0.0D / 0.0D);
}
while ((!"-Infinity".equals(str)) && (!"-INF".equals(str)));
return (-1.0D / 0.0D);
}
catch (IllegalArgumentException localIllegalArgumentException)
{
throw paramDeserializationContext.weirdStringException(this._valueClass, "not a valid double value");
}
}
while (localJsonToken == JsonToken.VALUE_NULL);
throw paramDeserializationContext.mappingException(this._valueClass);
}
示例15: _parseFloat
import org.codehaus.jackson.map.DeserializationContext; //导入方法依赖的package包/类
protected final Float _parseFloat(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
throws IOException, JsonProcessingException
{
JsonToken localJsonToken1 = paramJsonParser.getCurrentToken();
Float localFloat1;
if ((localJsonToken1 == JsonToken.VALUE_NUMBER_INT) || (localJsonToken1 == JsonToken.VALUE_NUMBER_FLOAT))
localFloat1 = Float.valueOf(paramJsonParser.getFloatValue());
JsonToken localJsonToken2;
do
{
while (true)
{
return localFloat1;
if (localJsonToken1 != JsonToken.VALUE_STRING)
break;
String str = paramJsonParser.getText().trim();
int i = str.length();
localFloat1 = null;
if (i == 0)
continue;
switch (str.charAt(0))
{
default:
case 'I':
case 'N':
case '-':
}
try
{
do
{
do
{
do
{
Float localFloat2 = Float.valueOf(Float.parseFloat(str));
return localFloat2;
}
while ((!"Infinity".equals(str)) && (!"INF".equals(str)));
return Float.valueOf((1.0F / 1.0F));
}
while (!"NaN".equals(str));
return Float.valueOf((0.0F / 0.0F));
}
while ((!"-Infinity".equals(str)) && (!"-INF".equals(str)));
return Float.valueOf((1.0F / -1.0F));
}
catch (IllegalArgumentException localIllegalArgumentException)
{
throw paramDeserializationContext.weirdStringException(this._valueClass, "not a valid Float value");
}
}
localJsonToken2 = JsonToken.VALUE_NULL;
localFloat1 = null;
}
while (localJsonToken1 == localJsonToken2);
throw paramDeserializationContext.mappingException(this._valueClass);
}