Package javax.xml.bind.annotation.adapters

Examples of javax.xml.bind.annotation.adapters.XmlAdapter


    @SuppressWarnings("unchecked")
    protected Object checkAdapter(Object obj, Class<?> cls, Annotation[] anns, boolean marshal) {
        XmlJavaTypeAdapter typeAdapter = getAdapter(obj.getClass(), anns);
        if (typeAdapter != null) {
            try {
                XmlAdapter xmlAdapter = typeAdapter.value().newInstance();
                if (marshal) {
                    return xmlAdapter.marshal(obj);
                } else {
                    return xmlAdapter.unmarshal(obj);
                }
            } catch (Exception ex) {
                LOG.warning("Problem using the XmlJavaTypeAdapter");
                ex.printStackTrace();
            }
View Full Code Here


    @SuppressWarnings("unchecked")
    protected Object checkAdapter(Object obj, Annotation[] anns, boolean marshal) {
        XmlJavaTypeAdapter typeAdapter = getAdapter(obj.getClass(), anns);
        if (typeAdapter != null) {
            try {
                XmlAdapter xmlAdapter = typeAdapter.value().newInstance();
                if (marshal) {
                    return xmlAdapter.marshal(obj);
                } else {
                    return xmlAdapter.unmarshal(obj);
                }
            } catch (Exception ex) {
                LOG.warning("Problem using the XmlJavaTypeAdapter");
                ex.printStackTrace();
            }
View Full Code Here

        if (typeAdapter != null) {
            if (InjectionUtils.isSupportedCollectionOrArray(typeAdapter.value().getClass())) {
                return obj;
            }
            try {
                XmlAdapter xmlAdapter = typeAdapter.value().newInstance();
                if (marshal) {
                    return xmlAdapter.marshal(obj);
                } else {
                    return xmlAdapter.unmarshal(obj);
                }
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
View Full Code Here

    @SuppressWarnings("unchecked")
    protected Object checkAdapter(Object obj, Class<?> cls, Annotation[] anns, boolean marshal) {
        XmlJavaTypeAdapter typeAdapter = getAdapter(obj.getClass(), anns);
        if (typeAdapter != null) {
            try {
                XmlAdapter xmlAdapter = typeAdapter.value().newInstance();
                if (marshal) {
                    return xmlAdapter.marshal(obj);
                } else {
                    return xmlAdapter.unmarshal(obj);
                }
            } catch (Exception ex) {
                LOG.warning("Problem using the XmlJavaTypeAdapter");
                ex.printStackTrace();
            }
View Full Code Here

                XmlJavaTypeAdapters adapters = pkg.getAnnotation(XmlJavaTypeAdapters.class);
                if (adapters != null) {
                    CustomSerializerFactory serializerFactory = new CustomSerializerFactory();
                    BeanDeserializerFactory deserializerFactory = new BeanDeserializerFactory(null);
                    for (XmlJavaTypeAdapter a : adapters.value()) {
                        XmlAdapter xmlAdapter = null;
                        try {
                            xmlAdapter = a.value().newInstance();
                        } catch (Throwable e) {
                            // Ignore
                        }
View Full Code Here

            return obj;
        }
        XmlJavaTypeAdapter xmlJavaTypeAdapter = getXmlJavaTypeAdapter(type, annotations);
        if (xmlJavaTypeAdapter != null) {
            try {
                XmlAdapter xmlAdapter = xmlJavaTypeAdapter.value().newInstance();
                return xmlAdapter.marshal(obj);
            } catch (Exception e) {
                if (logger.isDebugEnabled()) {
                    logger.debug("Could not marshal {} using {} due to exception:", new Object[] {
                        obj, xmlJavaTypeAdapter.value().getName(), e});
                }
View Full Code Here

            return obj;
        }
        XmlJavaTypeAdapter xmlJavaTypeAdapter = getXmlJavaTypeAdapter(type, annotations);
        if (xmlJavaTypeAdapter != null) {
            try {
                XmlAdapter xmlAdapter = xmlJavaTypeAdapter.value().newInstance();
                return xmlAdapter.unmarshal(obj);
            } catch (Exception e) {
                if (logger.isDebugEnabled()) {
                    logger.debug("Could not unmarshal {} using {} due to exception:", new Object[] {
                        obj, xmlJavaTypeAdapter.value().getName(), e});
                }
View Full Code Here

        if (typeAdapter != null) {
            if (InjectionUtils.isSupportedCollectionOrArray(typeAdapter.value().getClass())) {
                return obj;
            }
            try {
                XmlAdapter xmlAdapter = typeAdapter.value().newInstance();
                if (marshal) {
                    return xmlAdapter.marshal(obj);
                } else {
                    return xmlAdapter.unmarshal(obj);
                }
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
View Full Code Here

    @SuppressWarnings("unchecked")
    protected Object checkAdapter(Object obj, Annotation[] anns) {
        XmlJavaTypeAdapter typeAdapter = AnnotationUtils.getAnnotation(anns, XmlJavaTypeAdapter.class);
        if (typeAdapter != null) {
            try {
                XmlAdapter xmlAdapter = typeAdapter.value().newInstance();
                return xmlAdapter.marshal(obj);
            } catch (Exception ex) {
                LOG.warning("Problem using the XmlJavaTypeAdapter");
                ex.printStackTrace();
            }
        }
View Full Code Here

    }

    @SuppressWarnings({ "rawtypes", "unchecked" })
    private static Object getFieldValue(Field f, Object target) throws Exception {
        XmlJavaTypeAdapter adapterAnnotation = JAXBContextInitializer.getFieldXJTA(f);
        XmlAdapter adapter = JAXBContextInitializer.getXmlAdapter(adapterAnnotation);
        return adapter != null ? adapter.marshal(f.get(target)) : f.get(target);
    }
View Full Code Here

TOP

Related Classes of javax.xml.bind.annotation.adapters.XmlAdapter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.