protected boolean isWrapped(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) { if ((Collection.class.isAssignableFrom(type) || type.isArray()) && genericType != null) { Class<?> baseType = Types.getCollectionBaseType(type, genericType); if (baseType == null) return false; baseType = XmlAdapterWrapper.xmlAdapterValueType(baseType, annotations); return (baseType.isAnnotationPresent(XmlRootElement.class) || baseType.isAnnotationPresent(XmlType.class) || baseType.isAnnotationPresent(XmlSeeAlso.class) || JAXBElement.class.equals(baseType)) && (FindAnnotation.findAnnotation(baseType, annotations, DoNotUseJAXBProvider.class) == null) && !IgnoredMediaTypes.ignored(baseType, annotations, mediaType); } return false; }
XmlAdapterWrapper xmlAdapter = XmlAdapterWrapper.getXmlAdapter(valueType, annotations); if (xmlAdapter != null) valueType = xmlAdapter.getValueType(); value = xmlAdapter.marshal(value);
XmlAdapterWrapper xmlAdapter = XmlAdapterWrapper.getXmlAdapter(valueType, annotations); if (xmlAdapter != null) valueType = xmlAdapter.getValueType(); value = xmlAdapter.unmarshal(value);
@SuppressWarnings("unchecked") protected static XmlAdapterWrapper getXmlAdapter(Class<?> baseType, Annotation[] annotations) { if (baseType.isAnnotationPresent(XmlJavaTypeAdapter.class)) { XmlJavaTypeAdapter xmlJavaTypeAdapter = FindAnnotation.findAnnotation(baseType, annotations, XmlJavaTypeAdapter.class); Class<? extends XmlAdapter> adapterClass = xmlJavaTypeAdapter.value(); ParameterizedType xmlAdapterType = ParameterizedType.class.cast(adapterClass.getGenericSuperclass()); Class<?> boundType = Types.getArgumentType(xmlAdapterType, 1); if (boundType.isAssignableFrom(baseType)) { try { Class<?> valueType = Types.getArgumentType(xmlAdapterType, 0); return new XmlAdapterWrapper(adapterClass.newInstance(), valueType); } catch (Exception e) { throw new JAXBMarshalException(e); } } } return null; } }
XmlAdapterWrapper xmlAdapter = XmlAdapterWrapper.getXmlAdapter(baseType, annotations); if (xmlAdapter != null) baseType = xmlAdapter.getValueType(); obj = xmlAdapter.marshal(obj); obj = xmlAdapter.marshal(obj);
XmlAdapterWrapper xmlAdapter = XmlAdapterWrapper.getXmlAdapter(baseType, annotations); JaxbCollection col = null; try if (xmlAdapter != null) Class<?> adaptedType = xmlAdapter.getValueType(); ctx = finder.findCachedContext(adaptedType, mediaType, null); o = xmlAdapter.unmarshal(o); o = xmlAdapter.unmarshal(o);
protected boolean isWrapped(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) { if (Map.class.isAssignableFrom(type) && genericType != null) { Class<?> keyType = Types.getMapKeyType(genericType); if (keyType == null) return false; if (!CharSequence.class.isAssignableFrom(keyType) && !Number.class.isAssignableFrom(keyType)) return false; Class<?> valueType = Types.getMapValueType(genericType); if (valueType == null) return false; valueType = XmlAdapterWrapper.xmlAdapterValueType(valueType, annotations); return (valueType.isAnnotationPresent(XmlRootElement.class) || valueType.isAnnotationPresent(XmlType.class) || valueType.isAnnotationPresent(XmlSeeAlso.class) || JAXBElement.class.equals(valueType)) && (FindAnnotation.findAnnotation(valueType, annotations, DoNotUseJAXBProvider.class) == null) && !IgnoredMediaTypes.ignored(valueType, annotations, mediaType); } return false; }