Search in sources :

Example 1 with XmlAttribute

use of com.sun.xml.txw2.annotation.XmlAttribute in project jaxb-ri by eclipse-ee4j.

the class ContainerElement method invoke.

@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
    if (method.getDeclaringClass() == TypedXmlWriter.class || method.getDeclaringClass() == Object.class) {
        // forward to myself
        try {
            return method.invoke(this, args);
        } catch (InvocationTargetException e) {
            throw e.getTargetException();
        }
    }
    XmlAttribute xa = method.getAnnotation(XmlAttribute.class);
    XmlValue xv = method.getAnnotation(XmlValue.class);
    XmlElement xe = method.getAnnotation(XmlElement.class);
    if (xa != null) {
        if (xv != null || xe != null)
            throw new IllegalAnnotationException(method.toString());
        addAttribute(xa, method, args);
        // allow method chaining
        return proxy;
    }
    if (xv != null) {
        if (xe != null)
            throw new IllegalAnnotationException(method.toString());
        _pcdata(args);
        // allow method chaining
        return proxy;
    }
    return addElement(xe, method, args);
}
Also used : XmlAttribute(com.sun.xml.txw2.annotation.XmlAttribute) XmlValue(com.sun.xml.txw2.annotation.XmlValue) XmlElement(com.sun.xml.txw2.annotation.XmlElement) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

XmlAttribute (com.sun.xml.txw2.annotation.XmlAttribute)1 XmlElement (com.sun.xml.txw2.annotation.XmlElement)1 XmlValue (com.sun.xml.txw2.annotation.XmlValue)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1