Refine search
throws JsonMappingException final DeserializationConfig config = ctxt.getConfig(); JavaType elemType = type.getContentType(); JsonDeserializer<Object> contentDeser = elemType.getValueHandler(); TypeDeserializer elemTypeDeser = elemType.getTypeHandler(); if (deser == null) { if (contentDeser == null) { Class<?> raw = elemType.getRawClass(); if (elemType.isPrimitive()) { return PrimitiveArrayDeserializers.forType(raw);
Class<?> raw = type.getRawClass(); ser = new ObjectArraySerializer(type.getContentType(), staticTyping, elementTypeSerializer, elementValueSerializer);
public static ArrayType construct(JavaType componentType, TypeBindings bindings, Object valueHandler, Object typeHandler) { // Figuring out raw class for generic array is actually bit tricky... Object emptyInstance = Array.newInstance(componentType.getRawClass(), 0); return new ArrayType(componentType, bindings, emptyInstance, valueHandler, typeHandler, false); }
/** * Handling of narrowing conversions for arrays is trickier: for now, * it is not even allowed. */ @Override protected JavaType _narrow(Class<?> subclass) { /* Ok: need a bit of indirection here. First, must replace component * type (and check that it is compatible), then re-construct. */ if (!subclass.isArray()) { // sanity check, should never occur throw new IllegalArgumentException("Incompatible narrowing operation: trying to narrow "+toString()+" to class "+subclass.getName()); } /* Hmmh. This is an awkward back reference... but seems like the * only simple way to do it. */ Class<?> newCompClass = subclass.getComponentType(); /* 14-Mar-2011, tatu: it gets even worse, as we do not have access to * currently configured TypeFactory. This could theoretically cause * problems (when narrowing from array of Objects, to array of non-standard * Maps, for example); but for now need to defer solving this until * it actually becomes a real problem, not just potential one. * (famous last words?) */ JavaType newCompType = TypeFactory.defaultInstance().constructType(newCompClass); return construct(newCompType, _valueHandler, _typeHandler); }
public ObjectArrayDeserializer(ArrayType arrayType, JsonDeserializer<Object> elemDeser, TypeDeserializer elemTypeDeser) { super(arrayType); _arrayType = arrayType; _elementClass = arrayType.getContentType().getRawClass(); _untyped = (_elementClass == Object.class); _elementDeserializer = elemDeser; _elementTypeDeserializer = elemTypeDeser; }
@Override public JsonNode getSchema(SerializerProvider provider, Type typeHint) throws JsonMappingException { ObjectNode o = createSchemaNode("array", true); if (typeHint != null) { JavaType javaType = provider.constructType(typeHint); if (javaType.isArrayType()) { Class<?> componentType = ((ArrayType) javaType).getContentType().getRawClass(); // 15-Oct-2010, tatu: We can't serialize plain Object.class; but what should it produce here? Untyped? if (componentType == Object.class) { o.put("items", JsonSchema.getDefaultSchemaNode()); } else { JsonSerializer<Object> ser = provider.findValueSerializer(componentType, _property); JsonNode schemaNode = (ser instanceof SchemaAware) ? ((SchemaAware) ser).getSchema(provider, null) : JsonSchema.getDefaultSchemaNode(); o.put("items", schemaNode); } } } return o; }
@Override public JavaType widenContentsBy(Class<?> contentClass) { // Can do a quick check first: if (contentClass == _componentType.getRawClass()) { return this; } return construct(_componentType.widenBy(contentClass), _valueHandler, _typeHandler); }
&& ctxt.isEnabled(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT)) { String str = jp.getText(); if (str.length() == 0) { if (!ctxt.isEnabled(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY)) { return deserializeFromBase64(jp, ctxt); throw ctxt.mappingException(_arrayType.getRawClass());
/** * Same as {@link #getType(com.fasterxml.jackson.databind.type.SimpleType)} * * @param jacksonType * @return */ public Type getType(ArrayType jacksonType) { String signature = JacksonSignature.createSignature(jacksonType); String contentSignature = JacksonSignature.createSignature(jacksonType.getContentType()); Class<?> contentType = jacksonType.getContentType().getRawClass(); Class<?> containerClass = jacksonType.getRawClass(); CollectionTypeJrapidoc type = new CollectionTypeJrapidoc(containerClass.getName(), signature, contentType.getName(), contentSignature); if (cache.containsKey(signature)) { return cache.get(signature); } cache.put(signature, type); getType(jacksonType.getContentType()); return type; }
return ArrayType.construct(_constructType(clz.getComponentType(), null), null, null); keyType = paramTypes.get(0); contentType = (paramTypes.size() >= 2) ? paramTypes.get(1) : _unknownType(); return MapType.construct(clz, keyType, contentType); return _mapType(clz);
&& ctxt.isEnabled(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT)) { String str = p.getText(); if (str.length() == 0) { ctxt.isEnabled(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY)); if (!canWrap) { return deserializeFromBase64(p, ctxt); return (Object[]) ctxt.handleUnexpectedToken(_arrayType.getRawClass(), p);
JavaType result = _findWellKnownSimple(rawType); if (result != null) { return result; result = ArrayType.construct(_fromAny(context, rawType.getComponentType(), bindings), bindings); } else { superInterfaces = _resolveSuperInterfaces(context, rawType, bindings); } else { result = superClass.refine(rawType, bindings, superClass, superInterfaces); if (!result.hasHandlers()) {
@Override public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property) throws JsonMappingException { JsonDeserializer<?> deser = _elementDeserializer; // #125: May have a content converter deser = findConvertingContentDeserializer(ctxt, property, deser); final JavaType vt = _arrayType.getContentType(); if (deser == null) { deser = ctxt.findContextualValueDeserializer(vt, property); } else { // if directly assigned, probably not yet contextual, so: deser = ctxt.handleSecondaryContextualization(deser, property, vt); } TypeDeserializer elemTypeDeser = _elementTypeDeserializer; if (elemTypeDeser != null) { elemTypeDeser = elemTypeDeser.forProperty(property); } return withDeserializer(elemTypeDeser, deser); }
@Override public ArrayType withContentValueHandler(Object h) { if (h == _componentType.<Object>getValueHandler()) { return this; } return new ArrayType(_componentType.withValueHandler(h), _bindings, _emptyArray, _valueHandler, _typeHandler, _asStatic); }
@Override public ArrayType withContentTypeHandler(Object h) { if (h == _componentType.<Object>getTypeHandler()) { return this; } return new ArrayType(_componentType.withTypeHandler(h), _bindings, _emptyArray, _valueHandler, _typeHandler, _asStatic); }
@Override public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property) throws JsonMappingException { JsonDeserializer<?> deser = _elementDeserializer; Boolean unwrapSingle = findFormatFeature(ctxt, property, _arrayType.getRawClass(), JsonFormat.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY); // May have a content converter deser = findConvertingContentDeserializer(ctxt, property, deser); final JavaType vt = _arrayType.getContentType(); if (deser == null) { deser = ctxt.findContextualValueDeserializer(vt, property); } else { // if directly assigned, probably not yet contextual, so: deser = ctxt.handleSecondaryContextualization(deser, property, vt); } TypeDeserializer elemTypeDeser = _elementTypeDeserializer; if (elemTypeDeser != null) { elemTypeDeser = elemTypeDeser.forProperty(property); } return withResolved(elemTypeDeser, deser, unwrapSingle); }
public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property) throws JsonMappingException { JsonDeserializer<?> deser = _elementDeserializer; if (deser == null) { deser = ctxt.findContextualValueDeserializer(_arrayType.getContentType(), property); } else { // if directly assigned, probably not yet contextual, so: if (deser instanceof ContextualDeserializer) { deser = ((ContextualDeserializer) deser).createContextual(ctxt, property); } } TypeDeserializer elemTypeDeser = _elementTypeDeserializer; if (elemTypeDeser != null) { elemTypeDeser = elemTypeDeser.forProperty(property); } return withDeserializer(elemTypeDeser, deser); }
@Override public JavaType getContentType() { return _arrayType.getContentType(); }
/** * Method for constructing an {@link ArrayType}. *<p> * NOTE: type modifiers are NOT called on array type itself; but are called * for element type (and other contained types) */ public ArrayType constructArrayType(Class<?> elementType) { return ArrayType.construct(_constructType(elementType, null), null, null); }
/** * Method for constructing an {@link ArrayType}. *<p> * NOTE: type modifiers are NOT called on array type itself; but are called * for element type (and other contained types) */ public ArrayType constructArrayType(Class<?> elementType) { return ArrayType.construct(_fromAny(null, elementType, null), null); }