Search in sources :

Example 1 with TldDeferredValue$JAXB.readTldDeferredValue

use of org.apache.openejb.jee.TldDeferredValue$JAXB.readTldDeferredValue in project tomee by apache.

the class TldAttribute$JAXB method _read.

public static final TldAttribute _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
    // Check for xsi:nil
    if (reader.isXsiNil()) {
        return null;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final TldAttribute tldAttribute = new TldAttribute();
    context.beforeUnmarshal(tldAttribute, LifecycleCallback.NONE);
    ArrayList<Text> descriptions = null;
    // Check xsi:type
    final QName xsiType = reader.getXsiType();
    if (xsiType != null) {
        if (("tld-attributeType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
            return context.unexpectedXsiType(reader, TldAttribute.class);
        }
    }
    // Read attributes
    for (final Attribute attribute : reader.getAttributes()) {
        if (("id" == attribute.getLocalName()) && (("" == attribute.getNamespace()) || (attribute.getNamespace() == null))) {
            // ATTRIBUTE: id
            final String id = Adapters.collapsedStringAdapterAdapter.unmarshal(attribute.getValue());
            context.addXmlId(reader, id, tldAttribute);
            tldAttribute.id = id;
        } else if (XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI != attribute.getNamespace()) {
            context.unexpectedAttribute(attribute, new QName("", "id"));
        }
    }
    // Read elements
    for (final XoXMLStreamReader elementReader : reader.getChildElements()) {
        if (("description" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: descriptions
            final Text descriptionsItem = readText(elementReader, context);
            if (descriptions == null) {
                descriptions = new ArrayList<Text>();
            }
            descriptions.add(descriptionsItem);
        } else if (("name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: name
            final String nameRaw = elementReader.getElementAsString();
            final String name;
            try {
                name = Adapters.collapsedStringAdapterAdapter.unmarshal(nameRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            tldAttribute.name = name;
        } else if (("required" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: required
            final String requiredRaw = elementReader.getElementAsString();
            final String required;
            try {
                required = Adapters.collapsedStringAdapterAdapter.unmarshal(requiredRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            tldAttribute.required = required;
        } else if (("rtexprvalue" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: rtexprvalue
            final String rtexprvalueRaw = elementReader.getElementAsString();
            final String rtexprvalue;
            try {
                rtexprvalue = Adapters.collapsedStringAdapterAdapter.unmarshal(rtexprvalueRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            tldAttribute.rtexprvalue = rtexprvalue;
        } else if (("type" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: type
            final String typeRaw = elementReader.getElementAsString();
            final String type;
            try {
                type = Adapters.collapsedStringAdapterAdapter.unmarshal(typeRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            tldAttribute.type = type;
        } else if (("deferred-value" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: deferredValue
            final TldDeferredValue deferredValue = readTldDeferredValue(elementReader, context);
            tldAttribute.deferredValue = deferredValue;
        } else if (("deferred-method" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: deferredMethod
            final TldDeferredMethod deferredMethod = readTldDeferredMethod(elementReader, context);
            tldAttribute.deferredMethod = deferredMethod;
        } else if (("fragment" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: fragment
            final String fragmentRaw = elementReader.getElementAsString();
            final String fragment;
            try {
                fragment = Adapters.collapsedStringAdapterAdapter.unmarshal(fragmentRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            tldAttribute.fragment = fragment;
        } else {
            context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "description"), new QName("http://java.sun.com/xml/ns/javaee", "name"), new QName("http://java.sun.com/xml/ns/javaee", "required"), new QName("http://java.sun.com/xml/ns/javaee", "rtexprvalue"), new QName("http://java.sun.com/xml/ns/javaee", "type"), new QName("http://java.sun.com/xml/ns/javaee", "deferred-value"), new QName("http://java.sun.com/xml/ns/javaee", "deferred-method"), new QName("http://java.sun.com/xml/ns/javaee", "fragment"));
        }
    }
    if (descriptions != null) {
        try {
            tldAttribute.setDescriptions(descriptions.toArray(new Text[descriptions.size()]));
        } catch (final Exception e) {
            context.setterError(reader, TldAttribute.class, "setDescriptions", Text[].class, e);
        }
    }
    context.afterUnmarshal(tldAttribute, LifecycleCallback.NONE);
    return tldAttribute;
}
Also used : CollapsedStringAdapter(javax.xml.bind.annotation.adapters.CollapsedStringAdapter) Attribute(org.metatype.sxc.util.Attribute) QName(javax.xml.namespace.QName) TldDeferredValue$JAXB.readTldDeferredValue(org.apache.openejb.jee.TldDeferredValue$JAXB.readTldDeferredValue) TldDeferredValue$JAXB.writeTldDeferredValue(org.apache.openejb.jee.TldDeferredValue$JAXB.writeTldDeferredValue) Text$JAXB.readText(org.apache.openejb.jee.Text$JAXB.readText) Text$JAXB.writeText(org.apache.openejb.jee.Text$JAXB.writeText) TldDeferredMethod$JAXB.writeTldDeferredMethod(org.apache.openejb.jee.TldDeferredMethod$JAXB.writeTldDeferredMethod) TldDeferredMethod$JAXB.readTldDeferredMethod(org.apache.openejb.jee.TldDeferredMethod$JAXB.readTldDeferredMethod) RuntimeContext(org.metatype.sxc.jaxb.RuntimeContext) XoXMLStreamReader(org.metatype.sxc.util.XoXMLStreamReader)

Example 2 with TldDeferredValue$JAXB.readTldDeferredValue

use of org.apache.openejb.jee.TldDeferredValue$JAXB.readTldDeferredValue in project tomee by apache.

the class TldAttribute$JAXB method _write.

public static final void _write(final XoXMLStreamWriter writer, final TldAttribute tldAttribute, RuntimeContext context) throws Exception {
    if (tldAttribute == null) {
        writer.writeXsiNil();
        return;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final String prefix = writer.getUniquePrefix("http://java.sun.com/xml/ns/javaee");
    if (TldAttribute.class != tldAttribute.getClass()) {
        context.unexpectedSubclass(writer, tldAttribute, TldAttribute.class);
        return;
    }
    context.beforeMarshal(tldAttribute, LifecycleCallback.NONE);
    // ATTRIBUTE: id
    final String idRaw = tldAttribute.id;
    if (idRaw != null) {
        String id = null;
        try {
            id = Adapters.collapsedStringAdapterAdapter.marshal(idRaw);
        } catch (final Exception e) {
            context.xmlAdapterError(tldAttribute, "id", CollapsedStringAdapter.class, String.class, String.class, e);
        }
        writer.writeAttribute("", "", "id", id);
    }
    // ELEMENT: descriptions
    Text[] descriptions = null;
    try {
        descriptions = tldAttribute.getDescriptions();
    } catch (final Exception e) {
        context.getterError(tldAttribute, "descriptions", TldAttribute.class, "getDescriptions", e);
    }
    if (descriptions != null) {
        for (final Text descriptionsItem : descriptions) {
            if (descriptionsItem != null) {
                writer.writeStartElement(prefix, "description", "http://java.sun.com/xml/ns/javaee");
                writeText(writer, descriptionsItem, context);
                writer.writeEndElement();
            } else {
                context.unexpectedNullValue(tldAttribute, "descriptions");
            }
        }
    }
    // ELEMENT: name
    final String nameRaw = tldAttribute.name;
    String name = null;
    try {
        name = Adapters.collapsedStringAdapterAdapter.marshal(nameRaw);
    } catch (final Exception e) {
        context.xmlAdapterError(tldAttribute, "name", CollapsedStringAdapter.class, String.class, String.class, e);
    }
    if (name != null) {
        writer.writeStartElement(prefix, "name", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(name);
        writer.writeEndElement();
    } else {
        context.unexpectedNullValue(tldAttribute, "name");
    }
    // ELEMENT: required
    final String requiredRaw = tldAttribute.required;
    String required = null;
    try {
        required = Adapters.collapsedStringAdapterAdapter.marshal(requiredRaw);
    } catch (final Exception e) {
        context.xmlAdapterError(tldAttribute, "required", CollapsedStringAdapter.class, String.class, String.class, e);
    }
    if (required != null) {
        writer.writeStartElement(prefix, "required", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(required);
        writer.writeEndElement();
    }
    // ELEMENT: rtexprvalue
    final String rtexprvalueRaw = tldAttribute.rtexprvalue;
    String rtexprvalue = null;
    try {
        rtexprvalue = Adapters.collapsedStringAdapterAdapter.marshal(rtexprvalueRaw);
    } catch (final Exception e) {
        context.xmlAdapterError(tldAttribute, "rtexprvalue", CollapsedStringAdapter.class, String.class, String.class, e);
    }
    if (rtexprvalue != null) {
        writer.writeStartElement(prefix, "rtexprvalue", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(rtexprvalue);
        writer.writeEndElement();
    }
    // ELEMENT: type
    final String typeRaw = tldAttribute.type;
    String type = null;
    try {
        type = Adapters.collapsedStringAdapterAdapter.marshal(typeRaw);
    } catch (final Exception e) {
        context.xmlAdapterError(tldAttribute, "type", CollapsedStringAdapter.class, String.class, String.class, e);
    }
    if (type != null) {
        writer.writeStartElement(prefix, "type", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(type);
        writer.writeEndElement();
    }
    // ELEMENT: deferredValue
    final TldDeferredValue deferredValue = tldAttribute.deferredValue;
    if (deferredValue != null) {
        writer.writeStartElement(prefix, "deferred-value", "http://java.sun.com/xml/ns/javaee");
        writeTldDeferredValue(writer, deferredValue, context);
        writer.writeEndElement();
    }
    // ELEMENT: deferredMethod
    final TldDeferredMethod deferredMethod = tldAttribute.deferredMethod;
    if (deferredMethod != null) {
        writer.writeStartElement(prefix, "deferred-method", "http://java.sun.com/xml/ns/javaee");
        writeTldDeferredMethod(writer, deferredMethod, context);
        writer.writeEndElement();
    }
    // ELEMENT: fragment
    final String fragmentRaw = tldAttribute.fragment;
    String fragment = null;
    try {
        fragment = Adapters.collapsedStringAdapterAdapter.marshal(fragmentRaw);
    } catch (final Exception e) {
        context.xmlAdapterError(tldAttribute, "fragment", CollapsedStringAdapter.class, String.class, String.class, e);
    }
    if (fragment != null) {
        writer.writeStartElement(prefix, "fragment", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(fragment);
        writer.writeEndElement();
    }
    context.afterMarshal(tldAttribute, LifecycleCallback.NONE);
}
Also used : CollapsedStringAdapter(javax.xml.bind.annotation.adapters.CollapsedStringAdapter) TldDeferredValue$JAXB.readTldDeferredValue(org.apache.openejb.jee.TldDeferredValue$JAXB.readTldDeferredValue) TldDeferredValue$JAXB.writeTldDeferredValue(org.apache.openejb.jee.TldDeferredValue$JAXB.writeTldDeferredValue) Text$JAXB.readText(org.apache.openejb.jee.Text$JAXB.readText) Text$JAXB.writeText(org.apache.openejb.jee.Text$JAXB.writeText) TldDeferredMethod$JAXB.writeTldDeferredMethod(org.apache.openejb.jee.TldDeferredMethod$JAXB.writeTldDeferredMethod) TldDeferredMethod$JAXB.readTldDeferredMethod(org.apache.openejb.jee.TldDeferredMethod$JAXB.readTldDeferredMethod) RuntimeContext(org.metatype.sxc.jaxb.RuntimeContext)

Aggregations

CollapsedStringAdapter (javax.xml.bind.annotation.adapters.CollapsedStringAdapter)2 Text$JAXB.readText (org.apache.openejb.jee.Text$JAXB.readText)2 Text$JAXB.writeText (org.apache.openejb.jee.Text$JAXB.writeText)2 TldDeferredMethod$JAXB.readTldDeferredMethod (org.apache.openejb.jee.TldDeferredMethod$JAXB.readTldDeferredMethod)2 TldDeferredMethod$JAXB.writeTldDeferredMethod (org.apache.openejb.jee.TldDeferredMethod$JAXB.writeTldDeferredMethod)2 TldDeferredValue$JAXB.readTldDeferredValue (org.apache.openejb.jee.TldDeferredValue$JAXB.readTldDeferredValue)2 TldDeferredValue$JAXB.writeTldDeferredValue (org.apache.openejb.jee.TldDeferredValue$JAXB.writeTldDeferredValue)2 RuntimeContext (org.metatype.sxc.jaxb.RuntimeContext)2 QName (javax.xml.namespace.QName)1 Attribute (org.metatype.sxc.util.Attribute)1 XoXMLStreamReader (org.metatype.sxc.util.XoXMLStreamReader)1