com.fasterxml.jackson.databind.ext.CoreXMLDeserializers Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aem-sdk-api Show documentation
Show all versions of aem-sdk-api Show documentation
The Adobe Experience Manager SDK
package com.fasterxml.jackson.databind.ext;
import java.io.IOException;
import java.util.*;
import javax.xml.datatype.*;
import javax.xml.namespace.QName;
import com.fasterxml.jackson.core.*;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.deser.Deserializers;
import com.fasterxml.jackson.databind.deser.std.FromStringDeserializer;
/**
* Container deserializers that handle "core" XML types: ones included in standard
* JDK 1.5. Types are directly needed by JAXB, but may be unavailable on some
* limited platforms; hence separate out from basic deserializer factory.
*/
public class CoreXMLDeserializers extends Deserializers.Base
{
protected final static QName EMPTY_QNAME = QName.valueOf("");
/**
* Data type factories are thread-safe after instantiation (and
* configuration, if any); and since instantiation (esp. implementation
* introspection) can be expensive we better reuse the instance.
*/
final static DatatypeFactory _dataTypeFactory;
static {
try {
_dataTypeFactory = DatatypeFactory.newInstance();
} catch (DatatypeConfigurationException e) {
throw new RuntimeException(e);
}
}
@Override
public JsonDeserializer> findBeanDeserializer(JavaType type,
DeserializationConfig config, BeanDescription beanDesc)
{
Class> raw = type.getRawClass();
if (raw == QName.class) {
return new Std(raw, TYPE_QNAME);
}
if (raw == XMLGregorianCalendar.class) {
return new Std(raw, TYPE_G_CALENDAR);
}
if (raw == Duration.class) {
return new Std(raw, TYPE_DURATION);
}
return null;
}
@Override // since 2.11
public boolean hasDeserializerFor(DeserializationConfig config, Class> valueType) {
return (valueType == QName.class)
|| (valueType == XMLGregorianCalendar.class)
|| (valueType == Duration.class)
;
}
/*
/**********************************************************
/* Concrete deserializers
/**********************************************************
*/
protected final static int TYPE_DURATION = 1;
protected final static int TYPE_G_CALENDAR = 2;
protected final static int TYPE_QNAME = 3;
/**
* Combo-deserializer that supports deserialization of somewhat optional
* javax.xml types {@link QName}, {@link Duration} and {@link XMLGregorianCalendar}.
* Combined into a single class to eliminate bunch of one-off implementation
* classes, to reduce resulting jar size (mostly).
*
* @since 2.4
*/
public static class Std extends FromStringDeserializer
© 2015 - 2024 Weber Informatics LLC | Privacy Policy