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


Java DeserializationContext.mappingException方法代码示例

本文整理汇总了Java中com.fasterxml.jackson.databind.DeserializationContext.mappingException方法的典型用法代码示例。如果您正苦于以下问题:Java DeserializationContext.mappingException方法的具体用法?Java DeserializationContext.mappingException怎么用?Java DeserializationContext.mappingException使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.fasterxml.jackson.databind.DeserializationContext的用法示例。


在下文中一共展示了DeserializationContext.mappingException方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: deserialize

import com.fasterxml.jackson.databind.DeserializationContext; //导入方法依赖的package包/类
@Override
public Step deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
    ObjectNode node = jp.readValueAsTree();
    JsonNode stepKind = node.get(STEP_KIND);
    if (stepKind != null) {
        String value = stepKind.textValue();
        Class<? extends Step> resourceType = getTypeForName(value);
        if (resourceType == null) {
            throw ctxt.mappingException("No step type found for kind:" + value);
        }

        return jp.getCodec().treeToValue(node, resourceType);
    }
    return null;
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:16,代码来源:StepDeserializer.java

示例2: deserialize

import com.fasterxml.jackson.databind.DeserializationContext; //导入方法依赖的package包/类
@Override
public Map<String, Object> deserialize(JsonParser parser, DeserializationContext context) throws IOException,
	JsonProcessingException
{
	final Map<String, Object> map = Maps.newHashMap();
	int times = 0;
	while( parser.hasCurrentToken() )
	{
		final JsonToken currentToken = parser.getCurrentToken();
		switch( currentToken )
		{
			case START_OBJECT:
				// sure
				times++;
				if( times > 1 )
				{
					throw context.mappingException("Object opened twice??");
				}
				break;

			case END_OBJECT:
				return map;

			case FIELD_NAME:
				parser.nextToken();
				map.put(parser.getCurrentName(), parse(parser, context));
				break;

			case NOT_AVAILABLE:
				parser.nextToken();
				break;

			default:
				throw context.mappingException("Object can only contain fields " + where(parser, context));
		}
		parser.nextToken();
	}
	throw context.mappingException("No end object encountered " + where(parser, context));
}
 
开发者ID:equella,项目名称:Equella,代码行数:40,代码来源:MapDeserialiser.java

示例3: parseArray

import com.fasterxml.jackson.databind.DeserializationContext; //导入方法依赖的package包/类
private Object[] parseArray(JsonParser parser, DeserializationContext context) throws IOException,
	JsonProcessingException
{
	boolean started = false;
	final List<Object> values = Lists.newArrayList();
	while( parser.hasCurrentToken() )
	{
		final JsonToken currentToken = parser.getCurrentToken();
		switch( currentToken )
		{
			case START_ARRAY:
				if( started )
				{
					values.add(parseArray(parser, context));
				}
				started = true;
				break;
			case END_ARRAY:
				if( !started )
				{
					throw context.mappingException("End array encountered without start " + where(parser, context));
				}
				return values.toArray();
			case NOT_AVAILABLE:
				break;
			default:
				if( !started )
				{
					throw context.mappingException("Value encountered without array start "
						+ where(parser, context));
				}
				values.add(parse(parser, context));
		}
		parser.nextToken();
	}
	throw context.mappingException("No end array found " + where(parser, context));
}
 
开发者ID:equella,项目名称:Equella,代码行数:38,代码来源:MapDeserialiser.java

示例4: deserialize

import com.fasterxml.jackson.databind.DeserializationContext; //导入方法依赖的package包/类
@Override
public ObjectExpression deserialize(JsonParser parser, DeserializationContext context) throws IOException,
	JsonProcessingException
{
	final ObjectExpression map = new ObjectExpression();
	int times = 0;
	while( parser.hasCurrentToken() )
	{
		final JsonToken currentToken = parser.getCurrentToken();
		switch( currentToken )
		{
			case START_OBJECT:
				// sure
				times++;
				if( times > 1 )
				{
					throw context.mappingException("Object opened twice??");
				}
				break;

			case END_OBJECT:
				return map;

			case FIELD_NAME:
				parser.nextToken();
				map.put(parser.getCurrentName(), parse(parser, context));
				break;

			case NOT_AVAILABLE:
				parser.nextToken();
				break;

			default:
				throw context.mappingException("Object can only contain fields " + where(parser, context));
		}
		parser.nextToken();
	}
	throw context.mappingException("No end object encountered " + where(parser, context));
}
 
开发者ID:equella,项目名称:Equella,代码行数:40,代码来源:ObjectExpressionDeserialiser.java

示例5: parseArray

import com.fasterxml.jackson.databind.DeserializationContext; //导入方法依赖的package包/类
private ArrayExpression parseArray(JsonParser parser, DeserializationContext context) throws IOException,
	JsonProcessingException
{
	boolean started = false;
	final List<Object> values = Lists.newArrayList();
	while( parser.hasCurrentToken() )
	{
		final JsonToken currentToken = parser.getCurrentToken();
		switch( currentToken )
		{
			case START_ARRAY:
				if( started )
				{
					values.add(parseArray(parser, context));
				}
				started = true;
				break;
			case END_ARRAY:
				if( !started )
				{
					throw context.mappingException("End array encountered without start " + where(parser, context));
				}
				return new ArrayExpression(values.toArray());
			case NOT_AVAILABLE:
				break;
			default:
				if( !started )
				{
					throw context.mappingException("Value encountered without array start "
						+ where(parser, context));
				}
				values.add(parse(parser, context));
		}
		parser.nextToken();
	}
	throw context.mappingException("No end array found " + where(parser, context));
}
 
开发者ID:equella,项目名称:Equella,代码行数:38,代码来源:ObjectExpressionDeserialiser.java

示例6: deserializeKey

import com.fasterxml.jackson.databind.DeserializationContext; //导入方法依赖的package包/类
@Override
public Object deserializeKey(final String key, final DeserializationContext ctxt) throws IOException {
    try {
        return ctxt.findClass(SimpleClassNameIdResolver.getClassName(key));
    } catch (final Exception e) {
        throw ctxt.mappingException("Cannot find class %s", key);
    }
}
 
开发者ID:gchq,项目名称:koryphe,代码行数:9,代码来源:SimpleClassKeyDeserializer.java

示例7: deserialize

import com.fasterxml.jackson.databind.DeserializationContext; //导入方法依赖的package包/类
@Override
	public List<DataPointRequest> deserialize(JsonParser parser, DeserializationContext deserializationContext) throws IOException
{
		List<DataPointRequest> datapoints = new ArrayList<DataPointRequest>();

		JsonToken token = parser.nextToken();
		if (token != JsonToken.START_ARRAY )
			throw deserializationContext.mappingException("Invalid data point syntax.");

	while(token != null && token != JsonToken.END_ARRAY)
		{
		 	parser.nextToken();
			long timestamp = parser.getLongValue();

			parser.nextToken();
			String value = parser.getText();

			DataPointRequest dataPointRequest = new DataPointRequest(timestamp, value);

			validateObject(dataPointRequest);
			datapoints.add(dataPointRequest);

			token = parser.nextToken();
			if (token != JsonToken.END_ARRAY)
				throw deserializationContext.mappingException("Invalid data point syntax.");

			token = parser.nextToken();
		}

		return datapoints;
	}
 
开发者ID:quqiangsheng,项目名称:abhot,代码行数:32,代码来源:DataPointDeserializer.java

示例8: parse

import com.fasterxml.jackson.databind.DeserializationContext; //导入方法依赖的package包/类
private Object parse(JsonParser parser, DeserializationContext context) throws IOException, JsonProcessingException
{
	final JsonToken currentToken = parser.getCurrentToken();
	switch( currentToken )
	{
		case START_OBJECT:
			final Map<String, Object> oe = new MapDeserialiser().deserialize(parser, context);
			if( parser.getCurrentToken() != JsonToken.END_OBJECT )
			{
				throw context.mappingException("Should be on end object " + where(parser, context));
			}
			return oe;

		case VALUE_FALSE:
		case VALUE_TRUE:
			return parser.getValueAsBoolean();

		case VALUE_NUMBER_INT:
			return parser.getValueAsInt();

		case VALUE_NUMBER_FLOAT:
			return parser.getValueAsDouble();

		case VALUE_NULL:
			return "null";

		case VALUE_STRING:
			return "\"" + parser.getText() + "\"";

		case START_ARRAY:
			final Object[] ae = parseArray(parser, context);
			if( parser.getCurrentToken() != JsonToken.END_ARRAY )
			{
				throw context.mappingException("Should be on end array " + where(parser, context));
			}
			return ae;

		case END_ARRAY:
		case END_OBJECT:
			// whoops
			throw context.mappingException("Unexpected end object/array " + where(parser, context));

		case FIELD_NAME:
		case NOT_AVAILABLE:
			throw context.mappingException("How? " + where(parser, context));

		default:
			throw context.mappingException("Unhandled token " + where(parser, context));
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:51,代码来源:MapDeserialiser.java

示例9: parse

import com.fasterxml.jackson.databind.DeserializationContext; //导入方法依赖的package包/类
private Object parse(JsonParser parser, DeserializationContext context) throws IOException, JsonProcessingException
{
	final JsonToken currentToken = parser.getCurrentToken();
	switch( currentToken )
	{
		case START_OBJECT:
			final ObjectExpression oe = new ObjectExpressionDeserialiser().deserialize(parser, context);
			if( parser.getCurrentToken() != JsonToken.END_OBJECT )
			{
				throw context.mappingException("Should be on end object " + where(parser, context));
			}
			return oe;

		case VALUE_FALSE:
		case VALUE_TRUE:
			return new PrimitiveValueExpression(parser.getValueAsBoolean());

		case VALUE_NUMBER_INT:
			return new PrimitiveValueExpression(parser.getValueAsInt());

		case VALUE_NUMBER_FLOAT:
			return new PrimitiveValueExpression(parser.getValueAsDouble());

		case VALUE_NULL:
			return new NullExpression();

		case VALUE_STRING:
			return new StringExpression(parser.getText());

		case START_ARRAY:
			final ArrayExpression ae = parseArray(parser, context);
			if( parser.getCurrentToken() != JsonToken.END_ARRAY )
			{
				throw context.mappingException("Should be on end array " + where(parser, context));
			}
			return ae;

		case END_ARRAY:
		case END_OBJECT:
			// whoops
			throw context.mappingException("Unexpected end object/array " + where(parser, context));

		case FIELD_NAME:
		case NOT_AVAILABLE:
			throw context.mappingException("How? " + where(parser, context));

		default:
			throw context.mappingException("Unhandled token " + where(parser, context));
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:51,代码来源:ObjectExpressionDeserialiser.java


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