本文整理匯總了Java中org.codehaus.jackson.map.JsonDeserializer類的典型用法代碼示例。如果您正苦於以下問題:Java JsonDeserializer類的具體用法?Java JsonDeserializer怎麽用?Java JsonDeserializer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
JsonDeserializer類屬於org.codehaus.jackson.map包,在下文中一共展示了JsonDeserializer類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: _findRootDeserializer
import org.codehaus.jackson.map.JsonDeserializer; //導入依賴的package包/類
/**
* Method called to locate deserializer for the passed root-level value.
*/
protected JsonDeserializer<Object> _findRootDeserializer(DeserializationConfig cfg, JavaType valueType)
throws JsonMappingException {
// Sanity check: must have actual type...
if (valueType == null) {
throw new JsonMappingException("No value type configured for ObjectReader");
}
// First: have we already seen it?
JsonDeserializer<Object> deser = _rootDeserializers.get(valueType);
if (deser != null) {
return deser;
}
// es-hadoop: findType with 2 args have been removed since 1.9 so this code compiles on 1.8 (which has the fallback method)
// es-hadoop: on 1.5 only the 2 args method exists, since 1.9 only the one with 3 args hence the if
// Nope: need to ask provider to resolve it
deser = _provider.findTypedValueDeserializer(cfg, valueType);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type " + valueType);
}
_rootDeserializers.put(valueType, deser);
return deser;
}
示例2: BackportedJacksonMappingIterator
import org.codehaus.jackson.map.JsonDeserializer; //導入依賴的package包/類
@SuppressWarnings("unchecked")
protected BackportedJacksonMappingIterator(JavaType type, JsonParser jp, DeserializationContext ctxt, JsonDeserializer<?> deser) {
_type = type;
_parser = jp;
_context = ctxt;
_deserializer = (JsonDeserializer<T>) deser;
/* One more thing: if we are at START_ARRAY (but NOT root-level
* one!), advance to next token (to allow matching END_ARRAY)
*/
if (jp != null && jp.getCurrentToken() == JsonToken.START_ARRAY) {
JsonStreamContext sc = jp.getParsingContext();
// safest way to skip current token is to clear it (so we'll advance soon)
if (!sc.inRoot()) {
jp.clearCurrentToken();
}
}
}
示例3: addDiscoverableDeserializers
import org.codehaus.jackson.map.JsonDeserializer; //導入依賴的package包/類
/**
* Search for any registered JsonDeserialize instances that have been declared using the
* ServiceLoader. Add any found to the given mapper in a 'magic' module.
*/
private static void addDiscoverableDeserializers(final ObjectMapper mapper) {
final ServiceLoader<JsonDeserializer> loader = ServiceLoader.load(JsonDeserializer.class);
final Iterator<JsonDeserializer> iterator = loader.iterator();
final SimpleModule magic = new SimpleModule("magic", new Version(1, 0, 0, ""));
while (iterator.hasNext()) {
final JsonDeserializer<?> deserializer = iterator.next();
try {
final Method deserialeMethod = deserializer.getClass()
.getDeclaredMethod("deserialize", JsonParser.class, DeserializationContext.class);
final Class<?> jsonType = deserialeMethod.getReturnType();
//noinspection unchecked
magic.addDeserializer(jsonType, (JsonDeserializer) deserializer);
}
catch(Exception e) {
throw new IllegalStateException(e);
}
}
mapper.registerModule(magic);
}
示例4: _findDeserializer
import org.codehaus.jackson.map.JsonDeserializer; //導入依賴的package包/類
protected final JsonDeserializer<Object> _findDeserializer(DeserializationContext paramDeserializationContext, String paramString)
throws IOException, JsonProcessingException
{
JavaType localJavaType;
synchronized (this._deserializers)
{
localJsonDeserializer = (JsonDeserializer)this._deserializers.get(paramString);
if (localJsonDeserializer != null)
break label125;
localJavaType = this._idResolver.typeFromId(paramString);
if (localJavaType == null)
throw paramDeserializationContext.unknownTypeException(this._baseType, paramString);
}
if ((this._baseType != null) && (this._baseType.getClass() == localJavaType.getClass()))
localJavaType = this._baseType.narrowBy(localJavaType.getRawClass());
JsonDeserializer localJsonDeserializer = paramDeserializationContext.getDeserializerProvider().findValueDeserializer(paramDeserializationContext.getConfig(), localJavaType, this._property);
this._deserializers.put(paramString, localJsonDeserializer);
label125: monitorexit;
return localJsonDeserializer;
}
示例5: createCollectionLikeDeserializer
import org.codehaus.jackson.map.JsonDeserializer; //導入依賴的package包/類
public JsonDeserializer<?> createCollectionLikeDeserializer(DeserializationConfig paramDeserializationConfig, DeserializerProvider paramDeserializerProvider, CollectionLikeType paramCollectionLikeType, BeanProperty paramBeanProperty)
throws JsonMappingException
{
CollectionLikeType localCollectionLikeType1 = (CollectionLikeType)mapAbstractType(paramDeserializationConfig, paramCollectionLikeType);
BasicBeanDescription localBasicBeanDescription = (BasicBeanDescription)paramDeserializationConfig.introspectClassAnnotations(localCollectionLikeType1.getRawClass());
JsonDeserializer localJsonDeserializer1 = findDeserializerFromAnnotation(paramDeserializationConfig, localBasicBeanDescription.getClassInfo(), paramBeanProperty);
if (localJsonDeserializer1 != null)
return localJsonDeserializer1;
CollectionLikeType localCollectionLikeType2 = (CollectionLikeType)modifyTypeByAnnotation(paramDeserializationConfig, localBasicBeanDescription.getClassInfo(), localCollectionLikeType1, null);
JavaType localJavaType = localCollectionLikeType2.getContentType();
JsonDeserializer localJsonDeserializer2 = (JsonDeserializer)localJavaType.getValueHandler();
TypeDeserializer localTypeDeserializer = (TypeDeserializer)localJavaType.getTypeHandler();
if (localTypeDeserializer == null)
localTypeDeserializer = findTypeDeserializer(paramDeserializationConfig, localJavaType, paramBeanProperty);
return _findCustomCollectionLikeDeserializer(localCollectionLikeType2, paramDeserializationConfig, paramDeserializerProvider, localBasicBeanDescription, paramBeanProperty, localTypeDeserializer, localJsonDeserializer2);
}
示例6: createEnumDeserializer
import org.codehaus.jackson.map.JsonDeserializer; //導入依賴的package包/類
public JsonDeserializer<?> createEnumDeserializer(DeserializationConfig paramDeserializationConfig, DeserializerProvider paramDeserializerProvider, JavaType paramJavaType, BeanProperty paramBeanProperty)
throws JsonMappingException
{
BasicBeanDescription localBasicBeanDescription = (BasicBeanDescription)paramDeserializationConfig.introspectForCreation(paramJavaType);
JsonDeserializer localJsonDeserializer1 = findDeserializerFromAnnotation(paramDeserializationConfig, localBasicBeanDescription.getClassInfo(), paramBeanProperty);
if (localJsonDeserializer1 != null)
return localJsonDeserializer1;
Class localClass = paramJavaType.getRawClass();
JsonDeserializer localJsonDeserializer2 = _findCustomEnumDeserializer(localClass, paramDeserializationConfig, localBasicBeanDescription, paramBeanProperty);
if (localJsonDeserializer2 != null)
return localJsonDeserializer2;
Iterator localIterator = localBasicBeanDescription.getFactoryMethods().iterator();
while (localIterator.hasNext())
{
AnnotatedMethod localAnnotatedMethod = (AnnotatedMethod)localIterator.next();
if (!paramDeserializationConfig.getAnnotationIntrospector().hasCreatorAnnotation(localAnnotatedMethod))
continue;
if ((localAnnotatedMethod.getParameterCount() == 1) && (localAnnotatedMethod.getRawType().isAssignableFrom(localClass)))
return EnumDeserializer.deserializerForCreator(paramDeserializationConfig, localClass, localAnnotatedMethod);
throw new IllegalArgumentException("Unsuitable method (" + localAnnotatedMethod + ") decorated with @JsonCreator (for Enum type " + localClass.getName() + ")");
}
return new EnumDeserializer(constructEnumResolver(localClass, paramDeserializationConfig));
}
示例7: createMapLikeDeserializer
import org.codehaus.jackson.map.JsonDeserializer; //導入依賴的package包/類
public JsonDeserializer<?> createMapLikeDeserializer(DeserializationConfig paramDeserializationConfig, DeserializerProvider paramDeserializerProvider, MapLikeType paramMapLikeType, BeanProperty paramBeanProperty)
throws JsonMappingException
{
MapLikeType localMapLikeType1 = (MapLikeType)mapAbstractType(paramDeserializationConfig, paramMapLikeType);
BasicBeanDescription localBasicBeanDescription = (BasicBeanDescription)paramDeserializationConfig.introspectForCreation(localMapLikeType1);
JsonDeserializer localJsonDeserializer1 = findDeserializerFromAnnotation(paramDeserializationConfig, localBasicBeanDescription.getClassInfo(), paramBeanProperty);
if (localJsonDeserializer1 != null)
return localJsonDeserializer1;
MapLikeType localMapLikeType2 = (MapLikeType)modifyTypeByAnnotation(paramDeserializationConfig, localBasicBeanDescription.getClassInfo(), localMapLikeType1, null);
JavaType localJavaType1 = localMapLikeType2.getKeyType();
JavaType localJavaType2 = localMapLikeType2.getContentType();
JsonDeserializer localJsonDeserializer2 = (JsonDeserializer)localJavaType2.getValueHandler();
KeyDeserializer localKeyDeserializer = (KeyDeserializer)localJavaType1.getValueHandler();
if (localKeyDeserializer == null)
localKeyDeserializer = paramDeserializerProvider.findKeyDeserializer(paramDeserializationConfig, localJavaType1, paramBeanProperty);
TypeDeserializer localTypeDeserializer = (TypeDeserializer)localJavaType2.getTypeHandler();
if (localTypeDeserializer == null)
localTypeDeserializer = findTypeDeserializer(paramDeserializationConfig, localJavaType2, paramBeanProperty);
return _findCustomMapLikeDeserializer(localMapLikeType2, paramDeserializationConfig, paramDeserializerProvider, localBasicBeanDescription, paramBeanProperty, localKeyDeserializer, localTypeDeserializer, localJsonDeserializer2);
}
示例8: findStdBeanDeserializer
import org.codehaus.jackson.map.JsonDeserializer; //導入依賴的package包/類
protected JsonDeserializer<Object> findStdBeanDeserializer(DeserializationConfig paramDeserializationConfig, DeserializerProvider paramDeserializerProvider, JavaType paramJavaType, BeanProperty paramBeanProperty)
throws JsonMappingException
{
JsonDeserializer localJsonDeserializer1 = (JsonDeserializer)_simpleDeserializers.get(paramJavaType);
if (localJsonDeserializer1 != null)
return localJsonDeserializer1;
if (AtomicReference.class.isAssignableFrom(paramJavaType.getRawClass()))
{
JavaType[] arrayOfJavaType = paramDeserializationConfig.getTypeFactory().findTypeParameters(paramJavaType, AtomicReference.class);
if ((arrayOfJavaType == null) || (arrayOfJavaType.length < 1));
for (JavaType localJavaType = TypeFactory.unknownType(); ; localJavaType = arrayOfJavaType[0])
return new StdDeserializer.AtomicReferenceDeserializer(localJavaType, paramBeanProperty);
}
JsonDeserializer localJsonDeserializer2 = this.optionalHandlers.findDeserializer(paramJavaType, paramDeserializationConfig, paramDeserializerProvider);
if (localJsonDeserializer2 != null)
return localJsonDeserializer2;
return null;
}
示例9: handlePolymorphic
import org.codehaus.jackson.map.JsonDeserializer; //導入依賴的package包/類
protected Object handlePolymorphic(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext, Object paramObject, TokenBuffer paramTokenBuffer)
throws IOException, JsonProcessingException
{
JsonDeserializer localJsonDeserializer = _findSubclassDeserializer(paramDeserializationContext, paramObject, paramTokenBuffer);
if (localJsonDeserializer != null)
{
if (paramTokenBuffer != null)
{
paramTokenBuffer.writeEndObject();
JsonParser localJsonParser = paramTokenBuffer.asParser();
localJsonParser.nextToken();
paramObject = localJsonDeserializer.deserialize(localJsonParser, paramDeserializationContext, paramObject);
}
if (paramJsonParser != null)
paramObject = localJsonDeserializer.deserialize(paramJsonParser, paramDeserializationContext, paramObject);
return paramObject;
}
if (paramTokenBuffer != null)
paramObject = handleUnknownProperties(paramDeserializationContext, paramObject, paramTokenBuffer);
if (paramJsonParser != null)
paramObject = deserialize(paramJsonParser, paramDeserializationContext, paramObject);
return paramObject;
}
示例10: findValueDeserializer
import org.codehaus.jackson.map.JsonDeserializer; //導入依賴的package包/類
public JsonDeserializer<Object> findValueDeserializer(DeserializationConfig paramDeserializationConfig, JavaType paramJavaType, BeanProperty paramBeanProperty)
throws JsonMappingException
{
JsonDeserializer localJsonDeserializer1 = _findCachedDeserializer(paramJavaType);
if (localJsonDeserializer1 != null)
{
if ((localJsonDeserializer1 instanceof ContextualDeserializer))
localJsonDeserializer1 = ((ContextualDeserializer)localJsonDeserializer1).createContextual(paramDeserializationConfig, paramBeanProperty);
return localJsonDeserializer1;
}
JsonDeserializer localJsonDeserializer2 = _createAndCacheValueDeserializer(paramDeserializationConfig, paramJavaType, paramBeanProperty);
if (localJsonDeserializer2 == null)
localJsonDeserializer2 = _handleUnknownValueDeserializer(paramJavaType);
if ((localJsonDeserializer2 instanceof ContextualDeserializer))
localJsonDeserializer2 = ((ContextualDeserializer)localJsonDeserializer2).createContextual(paramDeserializationConfig, paramBeanProperty);
return localJsonDeserializer2;
}
示例11: hasValueDeserializerFor
import org.codehaus.jackson.map.JsonDeserializer; //導入依賴的package包/類
public boolean hasValueDeserializerFor(DeserializationConfig paramDeserializationConfig, JavaType paramJavaType)
{
Object localObject = _findCachedDeserializer(paramJavaType);
if (localObject == null);
try
{
JsonDeserializer localJsonDeserializer = _createAndCacheValueDeserializer(paramDeserializationConfig, paramJavaType, null);
localObject = localJsonDeserializer;
int i = 0;
if (localObject != null)
i = 1;
return i;
}
catch (Exception localException)
{
}
return false;
}
示例12: handleNonArray
import org.codehaus.jackson.map.JsonDeserializer; //導入依賴的package包/類
private final Collection<Object> handleNonArray(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext, Collection<Object> paramCollection)
throws IOException, JsonProcessingException
{
if (!paramDeserializationContext.isEnabled(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY))
throw paramDeserializationContext.mappingException(this._collectionType.getRawClass());
JsonDeserializer localJsonDeserializer = this._valueDeserializer;
TypeDeserializer localTypeDeserializer = this._valueTypeDeserializer;
Object localObject;
if (paramJsonParser.getCurrentToken() == JsonToken.VALUE_NULL)
localObject = null;
while (true)
{
paramCollection.add(localObject);
return paramCollection;
if (localTypeDeserializer == null)
{
localObject = localJsonDeserializer.deserialize(paramJsonParser, paramDeserializationContext);
continue;
}
localObject = localJsonDeserializer.deserializeWithType(paramJsonParser, paramDeserializationContext, localTypeDeserializer);
}
}
示例13: deserializeUsingCustom
import org.codehaus.jackson.map.JsonDeserializer; //導入依賴的package包/類
private Collection<String> deserializeUsingCustom(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext, Collection<String> paramCollection)
throws IOException, JsonProcessingException
{
JsonDeserializer localJsonDeserializer = this._valueDeserializer;
JsonToken localJsonToken = paramJsonParser.nextToken();
if (localJsonToken != JsonToken.END_ARRAY)
{
if (localJsonToken == JsonToken.VALUE_NULL);
for (Object localObject = null; ; localObject = (String)localJsonDeserializer.deserialize(paramJsonParser, paramDeserializationContext))
{
paramCollection.add(localObject);
break;
}
}
return (Collection<String>)paramCollection;
}
示例14: handleNonArray
import org.codehaus.jackson.map.JsonDeserializer; //導入依賴的package包/類
private final Collection<String> handleNonArray(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext, Collection<String> paramCollection)
throws IOException, JsonProcessingException
{
if (!paramDeserializationContext.isEnabled(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY))
throw paramDeserializationContext.mappingException(this._collectionType.getRawClass());
JsonDeserializer localJsonDeserializer = this._valueDeserializer;
if (paramJsonParser.getCurrentToken() == JsonToken.VALUE_NULL)
{
localObject = null;
paramCollection.add(localObject);
return paramCollection;
}
if (localJsonDeserializer == null);
for (Object localObject = paramJsonParser.getText(); ; localObject = (String)localJsonDeserializer.deserialize(paramJsonParser, paramDeserializationContext))
break;
}
示例15: buildBeanDeserializer
import org.codehaus.jackson.map.JsonDeserializer; //導入依賴的package包/類
public JsonDeserializer<Object> buildBeanDeserializer(DeserializationConfig paramDeserializationConfig, JavaType paramJavaType, BasicBeanDescription paramBasicBeanDescription, BeanProperty paramBeanProperty)
throws JsonMappingException
{
BeanDeserializerBuilder localBeanDeserializerBuilder = constructBeanDeserializerBuilder(paramBasicBeanDescription);
localBeanDeserializerBuilder.setCreators(findDeserializerCreators(paramDeserializationConfig, paramBasicBeanDescription));
addBeanProps(paramDeserializationConfig, paramBasicBeanDescription, localBeanDeserializerBuilder);
addReferenceProperties(paramDeserializationConfig, paramBasicBeanDescription, localBeanDeserializerBuilder);
if (this._factoryConfig.hasDeserializerModifiers())
{
Iterator localIterator2 = this._factoryConfig.deserializerModifiers().iterator();
while (localIterator2.hasNext())
localBeanDeserializerBuilder = ((BeanDeserializerModifier)localIterator2.next()).updateBuilder(paramDeserializationConfig, paramBasicBeanDescription, localBeanDeserializerBuilder);
}
JsonDeserializer localJsonDeserializer = localBeanDeserializerBuilder.build(paramBeanProperty);
if (this._factoryConfig.hasDeserializerModifiers())
{
Iterator localIterator1 = this._factoryConfig.deserializerModifiers().iterator();
while (localIterator1.hasNext())
localJsonDeserializer = ((BeanDeserializerModifier)localIterator1.next()).modifyDeserializer(paramDeserializationConfig, paramBasicBeanDescription, localJsonDeserializer);
}
return localJsonDeserializer;
}