Search in sources :

Example 1 with XmlAdapter

use of javax.xml.bind.annotation.adapters.XmlAdapter in project cxf by apache.

the class Utils method getMethodValue.

@SuppressWarnings({ "rawtypes", "unchecked" })
static Object getMethodValue(Method m, Object target) throws Exception {
    XmlJavaTypeAdapter adapterAnnotation = getMethodXJTA(m);
    XmlAdapter adapter = getXmlAdapter(adapterAnnotation);
    return adapter != null ? adapter.marshal(m.invoke(target)) : m.invoke(target);
}
Also used : XmlJavaTypeAdapter(javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter) XmlAdapter(javax.xml.bind.annotation.adapters.XmlAdapter)

Example 2 with XmlAdapter

use of javax.xml.bind.annotation.adapters.XmlAdapter in project cxf by apache.

the class Utils method setFieldValue.

@SuppressWarnings({ "rawtypes", "unchecked" })
static void setFieldValue(Field f, Object target, Object value) throws Exception {
    XmlJavaTypeAdapter xjta = getFieldXJTA(f);
    XmlAdapter adapter = getXmlAdapter(xjta);
    f.set(target, adapter != null ? adapter.unmarshal(value) : value);
}
Also used : XmlJavaTypeAdapter(javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter) XmlAdapter(javax.xml.bind.annotation.adapters.XmlAdapter)

Example 3 with XmlAdapter

use of javax.xml.bind.annotation.adapters.XmlAdapter in project cxf by apache.

the class Utils method setMethodValue.

@SuppressWarnings({ "rawtypes", "unchecked" })
static void setMethodValue(Method getter, Method setter, Object target, Object value) throws Exception {
    XmlJavaTypeAdapter xjta = getMethodXJTA(getter);
    XmlAdapter adapter = getXmlAdapter(xjta);
    setter.invoke(target, adapter != null ? adapter.unmarshal(value) : value);
}
Also used : XmlJavaTypeAdapter(javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter) XmlAdapter(javax.xml.bind.annotation.adapters.XmlAdapter)

Example 4 with XmlAdapter

use of javax.xml.bind.annotation.adapters.XmlAdapter in project ddf by codice.

the class TestXmlParserConfigurator method setup.

@Before
public void setup() {
    pc = new XmlParserConfigurator();
    testHandler = new ValidationEventHandler() {

        @Override
        public boolean handleEvent(ValidationEvent event) {
            return false;
        }
    };
    testAdapter = new XmlAdapter() {

        @Override
        public Object unmarshal(Object v) throws Exception {
            return null;
        }

        @Override
        public Object marshal(Object v) throws Exception {
            return null;
        }
    };
}
Also used : ValidationEventHandler(javax.xml.bind.ValidationEventHandler) ValidationEvent(javax.xml.bind.ValidationEvent) XmlAdapter(javax.xml.bind.annotation.adapters.XmlAdapter) Before(org.junit.Before)

Example 5 with XmlAdapter

use of javax.xml.bind.annotation.adapters.XmlAdapter in project cxf by apache.

the class Utils method getFieldValue.

@SuppressWarnings({ "rawtypes", "unchecked" })
static Object getFieldValue(Field f, Object target) throws Exception {
    XmlJavaTypeAdapter adapterAnnotation = getFieldXJTA(f);
    XmlAdapter adapter = getXmlAdapter(adapterAnnotation);
    return adapter != null ? adapter.marshal(f.get(target)) : f.get(target);
}
Also used : XmlJavaTypeAdapter(javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter) XmlAdapter(javax.xml.bind.annotation.adapters.XmlAdapter)

Aggregations

XmlAdapter (javax.xml.bind.annotation.adapters.XmlAdapter)6 XmlJavaTypeAdapter (javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter)4 ValidationEvent (javax.xml.bind.ValidationEvent)2 ValidationEventHandler (javax.xml.bind.ValidationEventHandler)2 Before (org.junit.Before)2