Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package org.codehaus.jackson.map.deser;
import java.util.*;
import java.util.concurrent.*;
import org.codehaus.jackson.JsonNode;
import org.codehaus.jackson.map.*;
import org.codehaus.jackson.map.introspect.Annotated;
import org.codehaus.jackson.map.introspect.BasicBeanDescription;
import org.codehaus.jackson.map.type.*;
import org.codehaus.jackson.map.util.ClassUtil;
import org.codehaus.jackson.type.JavaType;
/**
* Abstract factory base class that can provide deserializers for standard
* JDK classes, including collection classes and simple heuristics for
* "upcasting" commmon collection interface types
* (such as {@link java.util.Collection}).
*
* Since all simple deserializers are eagerly instantiated, and there is
* no additional introspection or customazibility of these types,
* this factory is stateless.
*/
public abstract class BasicDeserializerFactory
extends DeserializerFactory
{
// // Can cache some types
final static JavaType TYPE_STRING = TypeFactory.fromClass(String.class);
/**
* We will pre-create serializers for common non-structured
* (that is things other than Collection, Map or array)
* types. These need not go through factory.
*/
final static HashMap> _simpleDeserializers = StdDeserializers.constructAll();
/* We do some defaulting for abstract Map classes and
* interfaces, to avoid having to use exact types or annotations in
* cases where the most common concrete Maps will do.
*/
@SuppressWarnings("unchecked")
final static HashMap> _mapFallbacks =
new HashMap>();
static {
_mapFallbacks.put(Map.class.getName(), LinkedHashMap.class);
_mapFallbacks.put(ConcurrentMap.class.getName(), ConcurrentHashMap.class);
_mapFallbacks.put(SortedMap.class.getName(), TreeMap.class);
/* 11-Jan-2009, tatu: Let's see if we can still add support for
* JDK 1.6 interfaces, even if we run on 1.5. Just need to be
* more careful with typos, since compiler won't notice any
* problems...
*/
_mapFallbacks.put("java.util.NavigableMap", TreeMap.class);
try {
Class> key = Class.forName("java.util.ConcurrentNavigableMap");
Class> value = Class.forName("java.util.ConcurrentSkipListMap");
@SuppressWarnings("unchecked")
Class extends Map> mapValue = (Class extends Map>) value;
_mapFallbacks.put(key.getName(), mapValue);
} catch (ClassNotFoundException cnfe) { // occurs on 1.5
}
}
/* We do some defaulting for abstract Map classes and
* interfaces, to avoid having to use exact types or annotations in
* cases where the most common concrete Maps will do.
*/
@SuppressWarnings("unchecked")
final static HashMap> _collectionFallbacks =
new HashMap>();
static {
_collectionFallbacks.put(Collection.class.getName(), ArrayList.class);
_collectionFallbacks.put(List.class.getName(), ArrayList.class);
_collectionFallbacks.put(Set.class.getName(), HashSet.class);
_collectionFallbacks.put(SortedSet.class.getName(), TreeSet.class);
_collectionFallbacks.put(Queue.class.getName(), LinkedList.class);
/* 11-Jan-2009, tatu: Let's see if we can still add support for
* JDK 1.6 interfaces, even if we run on 1.5. Just need to be
* more careful with typos, since compiler won't notice any
* problems...
*/
_collectionFallbacks.put("java.util.Deque", LinkedList.class);
_collectionFallbacks.put("java.util.NavigableSet", TreeSet.class);
}
/**
* And finally, we have special array deserializers for primitive
* array types
*/
final static HashMap> _arrayDeserializers = ArrayDeserializers.getAll();
/*
////////////////////////////////////////////////////////////
// Life cycle
////////////////////////////////////////////////////////////
*/
protected BasicDeserializerFactory() { }
/*
////////////////////////////////////////////////////////////
// JsonDeserializerFactory impl
////////////////////////////////////////////////////////////
*/
@Override
public JsonDeserializer> createArrayDeserializer(DeserializationConfig config, ArrayType type, DeserializerProvider p)
throws JsonMappingException
{
// Ok; first: do we have a primitive type?
JavaType elemType = type.getComponentType();
// First, special type(s), such as "primitive" arrays (int[] etc)
JsonDeserializer