Search in sources :

Example 31 with XoXMLStreamReader

use of org.metatype.sxc.util.XoXMLStreamReader in project tomee by apache.

the class EnvEntry$JAXB method _read.

public static final EnvEntry _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
    // Check for xsi:nil
    if (reader.isXsiNil()) {
        return null;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final EnvEntry envEntry = new EnvEntry();
    context.beforeUnmarshal(envEntry, LifecycleCallback.NONE);
    ArrayList<Text> descriptions = null;
    Set<InjectionTarget> injectionTarget = null;
    // Check xsi:type
    final QName xsiType = reader.getXsiType();
    if (xsiType != null) {
        if (("env-entryType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
            return context.unexpectedXsiType(reader, EnvEntry.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, envEntry);
            envEntry.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 (("env-entry-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: envEntryName
            final String envEntryNameRaw = elementReader.getElementAsString();
            final String envEntryName;
            try {
                envEntryName = Adapters.collapsedStringAdapterAdapter.unmarshal(envEntryNameRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            envEntry.envEntryName = envEntryName;
        } else if (("env-entry-type" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: envEntryType
            final String envEntryTypeRaw = elementReader.getElementAsString();
            final String envEntryType;
            try {
                envEntryType = Adapters.collapsedStringAdapterAdapter.unmarshal(envEntryTypeRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            envEntry.envEntryType = envEntryType;
        } else if (("env-entry-value" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: envEntryValue
            // don't trim
            final String envEntryValueRaw = elementReader.getElementText();
            final String envEntryValue;
            try {
                envEntryValue = Adapters.stringAdapterAdapter.unmarshal(envEntryValueRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, StringAdapter.class, String.class, String.class, e);
                continue;
            }
            envEntry.envEntryValue = envEntryValue;
        } else if (("mapped-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: mappedName
            final String mappedNameRaw = elementReader.getElementAsString();
            final String mappedName;
            try {
                mappedName = Adapters.collapsedStringAdapterAdapter.unmarshal(mappedNameRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            envEntry.mappedName = mappedName;
        } else if (("injection-target" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: injectionTarget
            final InjectionTarget injectionTargetItem = readInjectionTarget(elementReader, context);
            if (injectionTarget == null) {
                injectionTarget = envEntry.injectionTarget;
                if (injectionTarget != null) {
                    injectionTarget.clear();
                } else {
                    injectionTarget = new LinkedHashSet<InjectionTarget>();
                }
            }
            injectionTarget.add(injectionTargetItem);
        } else if (("lookup-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: lookupName
            final String lookupNameRaw = elementReader.getElementAsString();
            final String lookupName;
            try {
                lookupName = Adapters.collapsedStringAdapterAdapter.unmarshal(lookupNameRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            envEntry.lookupName = lookupName;
        } else {
            context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "description"), new QName("http://java.sun.com/xml/ns/javaee", "env-entry-name"), new QName("http://java.sun.com/xml/ns/javaee", "env-entry-type"), new QName("http://java.sun.com/xml/ns/javaee", "env-entry-value"), new QName("http://java.sun.com/xml/ns/javaee", "mapped-name"), new QName("http://java.sun.com/xml/ns/javaee", "injection-target"), new QName("http://java.sun.com/xml/ns/javaee", "lookup-name"));
        }
    }
    if (descriptions != null) {
        try {
            envEntry.setDescriptions(descriptions.toArray(new Text[descriptions.size()]));
        } catch (final Exception e) {
            context.setterError(reader, EnvEntry.class, "setDescriptions", Text[].class, e);
        }
    }
    if (injectionTarget != null) {
        envEntry.injectionTarget = injectionTarget;
    }
    context.afterUnmarshal(envEntry, LifecycleCallback.NONE);
    return envEntry;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) CollapsedStringAdapter(javax.xml.bind.annotation.adapters.CollapsedStringAdapter) Attribute(org.metatype.sxc.util.Attribute) QName(javax.xml.namespace.QName) Text$JAXB.readText(org.apache.openejb.jee.Text$JAXB.readText) Text$JAXB.writeText(org.apache.openejb.jee.Text$JAXB.writeText) InjectionTarget$JAXB.writeInjectionTarget(org.apache.openejb.jee.InjectionTarget$JAXB.writeInjectionTarget) InjectionTarget$JAXB.readInjectionTarget(org.apache.openejb.jee.InjectionTarget$JAXB.readInjectionTarget) RuntimeContext(org.metatype.sxc.jaxb.RuntimeContext) XoXMLStreamReader(org.metatype.sxc.util.XoXMLStreamReader)

Example 32 with XoXMLStreamReader

use of org.metatype.sxc.util.XoXMLStreamReader in project tomee by apache.

the class ExcludeList$JAXB method _read.

public static final ExcludeList _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
    // Check for xsi:nil
    if (reader.isXsiNil()) {
        return null;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final ExcludeList excludeList = new ExcludeList();
    context.beforeUnmarshal(excludeList, LifecycleCallback.NONE);
    ArrayList<Text> descriptions = null;
    List<Method> method = null;
    // Check xsi:type
    final QName xsiType = reader.getXsiType();
    if (xsiType != null) {
        if (("exclude-listType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
            return context.unexpectedXsiType(reader, ExcludeList.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, excludeList);
            excludeList.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 (("method" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: method
            final Method methodItem = readMethod(elementReader, context);
            if (method == null) {
                method = excludeList.method;
                if (method != null) {
                    method.clear();
                } else {
                    method = new ArrayList<Method>();
                }
            }
            method.add(methodItem);
        } else {
            context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "description"), new QName("http://java.sun.com/xml/ns/javaee", "method"));
        }
    }
    if (descriptions != null) {
        try {
            excludeList.setDescriptions(descriptions.toArray(new Text[descriptions.size()]));
        } catch (final Exception e) {
            context.setterError(reader, ExcludeList.class, "setDescriptions", Text[].class, e);
        }
    }
    if (method != null) {
        excludeList.method = method;
    }
    context.afterUnmarshal(excludeList, LifecycleCallback.NONE);
    return excludeList;
}
Also used : Attribute(org.metatype.sxc.util.Attribute) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) Text$JAXB.readText(org.apache.openejb.jee.Text$JAXB.readText) Text$JAXB.writeText(org.apache.openejb.jee.Text$JAXB.writeText) Method$JAXB.readMethod(org.apache.openejb.jee.Method$JAXB.readMethod) Method$JAXB.writeMethod(org.apache.openejb.jee.Method$JAXB.writeMethod) RuntimeContext(org.metatype.sxc.jaxb.RuntimeContext) XoXMLStreamReader(org.metatype.sxc.util.XoXMLStreamReader)

Example 33 with XoXMLStreamReader

use of org.metatype.sxc.util.XoXMLStreamReader in project tomee by apache.

the class FacesApplicationExtension$JAXB method _read.

public static final FacesApplicationExtension _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
    // Check for xsi:nil
    if (reader.isXsiNil()) {
        return null;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final FacesApplicationExtension facesApplicationExtension = new FacesApplicationExtension();
    context.beforeUnmarshal(facesApplicationExtension, LifecycleCallback.NONE);
    List<Object> any = null;
    // Check xsi:type
    final QName xsiType = reader.getXsiType();
    if (xsiType != null) {
        if (("faces-config-application-extensionType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
            return context.unexpectedXsiType(reader, FacesApplicationExtension.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, facesApplicationExtension);
            facesApplicationExtension.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()) {
        // ELEMENT_REF: any
        if (any == null) {
            any = facesApplicationExtension.any;
            if (any != null) {
                any.clear();
            } else {
                any = new ArrayList<Object>();
            }
        }
        any.add(context.readXmlAny(elementReader, Object.class, true));
    }
    if (any != null) {
        facesApplicationExtension.any = any;
    }
    context.afterUnmarshal(facesApplicationExtension, LifecycleCallback.NONE);
    return facesApplicationExtension;
}
Also used : Attribute(org.metatype.sxc.util.Attribute) QName(javax.xml.namespace.QName) JAXBObject(org.metatype.sxc.jaxb.JAXBObject) RuntimeContext(org.metatype.sxc.jaxb.RuntimeContext) XoXMLStreamReader(org.metatype.sxc.util.XoXMLStreamReader)

Example 34 with XoXMLStreamReader

use of org.metatype.sxc.util.XoXMLStreamReader in project tomee by apache.

the class FacesAttribute$JAXB method _read.

public static final FacesAttribute _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
    // Check for xsi:nil
    if (reader.isXsiNil()) {
        return null;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final FacesAttribute facesAttribute = new FacesAttribute();
    context.beforeUnmarshal(facesAttribute, LifecycleCallback.NONE);
    ArrayList<Text> descriptions = null;
    ArrayList<Text> displayNames = null;
    LocalCollection<Icon> icon = null;
    List<FacesAttributeExtension> attributeExtension = null;
    // Check xsi:type
    final QName xsiType = reader.getXsiType();
    if (xsiType != null) {
        if (("faces-config-attributeType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
            return context.unexpectedXsiType(reader, FacesAttribute.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, facesAttribute);
            facesAttribute.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 (("display-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: displayNames
            final Text displayNamesItem = readText(elementReader, context);
            if (displayNames == null) {
                displayNames = new ArrayList<Text>();
            }
            displayNames.add(displayNamesItem);
        } else if (("icon" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: icon
            final Icon iconItem = readIcon(elementReader, context);
            if (icon == null) {
                icon = facesAttribute.icon;
                if (icon != null) {
                    icon.clear();
                } else {
                    icon = new LocalCollection<Icon>();
                }
            }
            icon.add(iconItem);
        } else if (("attribute-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: attributeName
            final String attributeNameRaw = elementReader.getElementAsString();
            final String attributeName;
            try {
                attributeName = Adapters.collapsedStringAdapterAdapter.unmarshal(attributeNameRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            facesAttribute.attributeName = attributeName;
        } else if (("attribute-class" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: attributeClass
            final String attributeClassRaw = elementReader.getElementAsString();
            final String attributeClass;
            try {
                attributeClass = Adapters.collapsedStringAdapterAdapter.unmarshal(attributeClassRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            facesAttribute.attributeClass = attributeClass;
        } else if (("default-value" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: defaultValue
            final String defaultValueRaw = elementReader.getElementAsString();
            final String defaultValue;
            try {
                defaultValue = Adapters.collapsedStringAdapterAdapter.unmarshal(defaultValueRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            facesAttribute.defaultValue = defaultValue;
        } else if (("suggested-value" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: suggestedValue
            final String suggestedValueRaw = elementReader.getElementAsString();
            final String suggestedValue;
            try {
                suggestedValue = Adapters.collapsedStringAdapterAdapter.unmarshal(suggestedValueRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            facesAttribute.suggestedValue = suggestedValue;
        } else if (("attribute-extension" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: attributeExtension
            final FacesAttributeExtension attributeExtensionItem = readFacesAttributeExtension(elementReader, context);
            if (attributeExtension == null) {
                attributeExtension = facesAttribute.attributeExtension;
                if (attributeExtension != null) {
                    attributeExtension.clear();
                } else {
                    attributeExtension = new ArrayList<FacesAttributeExtension>();
                }
            }
            attributeExtension.add(attributeExtensionItem);
        } else {
            context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "description"), new QName("http://java.sun.com/xml/ns/javaee", "display-name"), new QName("http://java.sun.com/xml/ns/javaee", "icon"), new QName("http://java.sun.com/xml/ns/javaee", "attribute-name"), new QName("http://java.sun.com/xml/ns/javaee", "attribute-class"), new QName("http://java.sun.com/xml/ns/javaee", "default-value"), new QName("http://java.sun.com/xml/ns/javaee", "suggested-value"), new QName("http://java.sun.com/xml/ns/javaee", "attribute-extension"));
        }
    }
    if (descriptions != null) {
        try {
            facesAttribute.setDescriptions(descriptions.toArray(new Text[descriptions.size()]));
        } catch (final Exception e) {
            context.setterError(reader, FacesAttribute.class, "setDescriptions", Text[].class, e);
        }
    }
    if (displayNames != null) {
        try {
            facesAttribute.setDisplayNames(displayNames.toArray(new Text[displayNames.size()]));
        } catch (final Exception e) {
            context.setterError(reader, FacesAttribute.class, "setDisplayNames", Text[].class, e);
        }
    }
    if (icon != null) {
        facesAttribute.icon = icon;
    }
    if (attributeExtension != null) {
        facesAttribute.attributeExtension = attributeExtension;
    }
    context.afterUnmarshal(facesAttribute, LifecycleCallback.NONE);
    return facesAttribute;
}
Also used : CollapsedStringAdapter(javax.xml.bind.annotation.adapters.CollapsedStringAdapter) Attribute(org.metatype.sxc.util.Attribute) QName(javax.xml.namespace.QName) FacesAttributeExtension$JAXB.writeFacesAttributeExtension(org.apache.openejb.jee.FacesAttributeExtension$JAXB.writeFacesAttributeExtension) FacesAttributeExtension$JAXB.readFacesAttributeExtension(org.apache.openejb.jee.FacesAttributeExtension$JAXB.readFacesAttributeExtension) ArrayList(java.util.ArrayList) Text$JAXB.readText(org.apache.openejb.jee.Text$JAXB.readText) Text$JAXB.writeText(org.apache.openejb.jee.Text$JAXB.writeText) Icon$JAXB.readIcon(org.apache.openejb.jee.Icon$JAXB.readIcon) Icon$JAXB.writeIcon(org.apache.openejb.jee.Icon$JAXB.writeIcon) RuntimeContext(org.metatype.sxc.jaxb.RuntimeContext) XoXMLStreamReader(org.metatype.sxc.util.XoXMLStreamReader)

Example 35 with XoXMLStreamReader

use of org.metatype.sxc.util.XoXMLStreamReader in project tomee by apache.

the class FacesBehavior$JAXB method _read.

public static final FacesBehavior _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
    // Check for xsi:nil
    if (reader.isXsiNil()) {
        return null;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final FacesBehavior facesBehavior = new FacesBehavior();
    context.beforeUnmarshal(facesBehavior, LifecycleCallback.NONE);
    ArrayList<Text> descriptions = null;
    ArrayList<Text> displayNames = null;
    LocalCollection<Icon> icon = null;
    List<FacesAttribute> attribute1 = null;
    List<FacesProperty> property = null;
    List<FacesBehaviorExtension> behaviorExtension = null;
    // Check xsi:type
    final QName xsiType = reader.getXsiType();
    if (xsiType != null) {
        if (("faces-config-behaviorType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
            return context.unexpectedXsiType(reader, FacesBehavior.class);
        }
    }
    // Read attributes
    for (final Attribute attribute : reader.getAttributes()) {
        if (XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI != attribute.getNamespace()) {
            context.unexpectedAttribute(attribute);
        }
    }
    // 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 (("display-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: displayNames
            final Text displayNamesItem = readText(elementReader, context);
            if (displayNames == null) {
                displayNames = new ArrayList<Text>();
            }
            displayNames.add(displayNamesItem);
        } else if (("icon" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: icon
            final Icon iconItem = readIcon(elementReader, context);
            if (icon == null) {
                icon = facesBehavior.icon;
                if (icon != null) {
                    icon.clear();
                } else {
                    icon = new LocalCollection<Icon>();
                }
            }
            icon.add(iconItem);
        } else if (("behavior-id" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: behaviorId
            final String behaviorIdRaw = elementReader.getElementAsString();
            final String behaviorId;
            try {
                behaviorId = Adapters.collapsedStringAdapterAdapter.unmarshal(behaviorIdRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            facesBehavior.behaviorId = behaviorId;
        } else if (("behavior-class" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: behaviorClass
            final String behaviorClassRaw = elementReader.getElementAsString();
            final String behaviorClass;
            try {
                behaviorClass = Adapters.collapsedStringAdapterAdapter.unmarshal(behaviorClassRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            facesBehavior.behaviorClass = behaviorClass;
        } else if (("attribute" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: attribute
            final FacesAttribute attributeItem = readFacesAttribute(elementReader, context);
            if (attribute1 == null) {
                attribute1 = facesBehavior.attribute;
                if (attribute1 != null) {
                    attribute1.clear();
                } else {
                    attribute1 = new ArrayList<FacesAttribute>();
                }
            }
            attribute1.add(attributeItem);
        } else if (("property" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: property
            final FacesProperty propertyItem = readFacesProperty(elementReader, context);
            if (property == null) {
                property = facesBehavior.property;
                if (property != null) {
                    property.clear();
                } else {
                    property = new ArrayList<FacesProperty>();
                }
            }
            property.add(propertyItem);
        } else if (("behavior-extension" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: behaviorExtension
            final FacesBehaviorExtension behaviorExtensionItem = readFacesBehaviorExtension(elementReader, context);
            if (behaviorExtension == null) {
                behaviorExtension = facesBehavior.behaviorExtension;
                if (behaviorExtension != null) {
                    behaviorExtension.clear();
                } else {
                    behaviorExtension = new ArrayList<FacesBehaviorExtension>();
                }
            }
            behaviorExtension.add(behaviorExtensionItem);
        } else {
        // just here ATM to not prevent users to get JSF 2.2 feature because we can't read it
        // TODO: handle it properly
        // context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "description"), new QName("http://java.sun.com/xml/ns/javaee", "display-name"), new QName("http://java.sun.com/xml/ns/javaee", "icon"), new QName("http://java.sun.com/xml/ns/javaee", "behavior-id"), new QName("http://java.sun.com/xml/ns/javaee", "behavior-class"), new QName("http://java.sun.com/xml/ns/javaee", "attribute"), new QName("http://java.sun.com/xml/ns/javaee", "property"), new QName("http://java.sun.com/xml/ns/javaee", "behavior-extension"));
        }
    }
    if (descriptions != null) {
        try {
            facesBehavior.setDescriptions(descriptions.toArray(new Text[descriptions.size()]));
        } catch (final Exception e) {
            context.setterError(reader, FacesBehavior.class, "setDescriptions", Text[].class, e);
        }
    }
    if (displayNames != null) {
        try {
            facesBehavior.setDisplayNames(displayNames.toArray(new Text[displayNames.size()]));
        } catch (final Exception e) {
            context.setterError(reader, FacesBehavior.class, "setDisplayNames", Text[].class, e);
        }
    }
    if (icon != null) {
        facesBehavior.icon = icon;
    }
    if (attribute1 != null) {
        facesBehavior.attribute = attribute1;
    }
    if (property != null) {
        facesBehavior.property = property;
    }
    if (behaviorExtension != null) {
        facesBehavior.behaviorExtension = behaviorExtension;
    }
    context.afterUnmarshal(facesBehavior, LifecycleCallback.NONE);
    return facesBehavior;
}
Also used : CollapsedStringAdapter(javax.xml.bind.annotation.adapters.CollapsedStringAdapter) FacesAttribute$JAXB.readFacesAttribute(org.apache.openejb.jee.FacesAttribute$JAXB.readFacesAttribute) FacesAttribute$JAXB.writeFacesAttribute(org.apache.openejb.jee.FacesAttribute$JAXB.writeFacesAttribute) Attribute(org.metatype.sxc.util.Attribute) QName(javax.xml.namespace.QName) FacesBehaviorExtension$JAXB.writeFacesBehaviorExtension(org.apache.openejb.jee.FacesBehaviorExtension$JAXB.writeFacesBehaviorExtension) FacesBehaviorExtension$JAXB.readFacesBehaviorExtension(org.apache.openejb.jee.FacesBehaviorExtension$JAXB.readFacesBehaviorExtension) ArrayList(java.util.ArrayList) FacesAttribute$JAXB.readFacesAttribute(org.apache.openejb.jee.FacesAttribute$JAXB.readFacesAttribute) FacesAttribute$JAXB.writeFacesAttribute(org.apache.openejb.jee.FacesAttribute$JAXB.writeFacesAttribute) Text$JAXB.readText(org.apache.openejb.jee.Text$JAXB.readText) Text$JAXB.writeText(org.apache.openejb.jee.Text$JAXB.writeText) Icon$JAXB.readIcon(org.apache.openejb.jee.Icon$JAXB.readIcon) Icon$JAXB.writeIcon(org.apache.openejb.jee.Icon$JAXB.writeIcon) RuntimeContext(org.metatype.sxc.jaxb.RuntimeContext) FacesProperty$JAXB.readFacesProperty(org.apache.openejb.jee.FacesProperty$JAXB.readFacesProperty) FacesProperty$JAXB.writeFacesProperty(org.apache.openejb.jee.FacesProperty$JAXB.writeFacesProperty) XoXMLStreamReader(org.metatype.sxc.util.XoXMLStreamReader)

Aggregations

XoXMLStreamReader (org.metatype.sxc.util.XoXMLStreamReader)184 QName (javax.xml.namespace.QName)182 RuntimeContext (org.metatype.sxc.jaxb.RuntimeContext)182 Attribute (org.metatype.sxc.util.Attribute)182 CollapsedStringAdapter (javax.xml.bind.annotation.adapters.CollapsedStringAdapter)112 Text$JAXB.readText (org.apache.openejb.jee.Text$JAXB.readText)78 Text$JAXB.writeText (org.apache.openejb.jee.Text$JAXB.writeText)77 ArrayList (java.util.ArrayList)70 Icon$JAXB.readIcon (org.apache.openejb.jee.Icon$JAXB.readIcon)37 Icon$JAXB.writeIcon (org.apache.openejb.jee.Icon$JAXB.writeIcon)37 JAXBObject (org.metatype.sxc.jaxb.JAXBObject)18 InjectionTarget$JAXB.readInjectionTarget (org.apache.openejb.jee.InjectionTarget$JAXB.readInjectionTarget)9 InjectionTarget$JAXB.writeInjectionTarget (org.apache.openejb.jee.InjectionTarget$JAXB.writeInjectionTarget)9 DataSource$JAXB.readDataSource (org.apache.openejb.jee.DataSource$JAXB.readDataSource)7 DataSource$JAXB.writeDataSource (org.apache.openejb.jee.DataSource$JAXB.writeDataSource)7 EjbLocalRef$JAXB.readEjbLocalRef (org.apache.openejb.jee.EjbLocalRef$JAXB.readEjbLocalRef)7 EjbLocalRef$JAXB.writeEjbLocalRef (org.apache.openejb.jee.EjbLocalRef$JAXB.writeEjbLocalRef)7 EjbRef$JAXB.readEjbRef (org.apache.openejb.jee.EjbRef$JAXB.readEjbRef)7 EjbRef$JAXB.writeEjbRef (org.apache.openejb.jee.EjbRef$JAXB.writeEjbRef)7 EnvEntry$JAXB.readEnvEntry (org.apache.openejb.jee.EnvEntry$JAXB.readEnvEntry)7