Search in sources :

Example 21 with XoXMLStreamReader

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

the class JMSConnectionFactory$JAXB method _read.

public static final JMSConnectionFactory _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
    // Check for xsi:nil
    if (reader.isXsiNil()) {
        return null;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final JMSConnectionFactory JMSConnectionFactory = new JMSConnectionFactory();
    context.beforeUnmarshal(JMSConnectionFactory, LifecycleCallback.NONE);
    ArrayList<Text> descriptions = null;
    List<Property> property = null;
    // Check xsi:type
    final QName xsiType = reader.getXsiType();
    if (xsiType != null) {
        if (("jms-connection-factoryType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
            return context.unexpectedXsiType(reader, JMSConnectionFactory.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, JMSConnectionFactory);
            JMSConnectionFactory.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;
            }
            JMSConnectionFactory.name = name;
        } else if (("class-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;
            }
            JMSConnectionFactory.className = name;
        } else if (("interface-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;
            }
            JMSConnectionFactory.className = name;
        } else if (("resource-adapter" == 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;
            }
            JMSConnectionFactory.resourceAdapter = name;
        } else if (("user" == 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;
            }
            JMSConnectionFactory.user = name;
        } else if (("password" == 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;
            }
            JMSConnectionFactory.password = name;
        } else if (("client-id" == 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;
            }
            JMSConnectionFactory.clientId = name;
        } else if (("max-pool-size" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            final Integer portNumber = Integer.valueOf(elementReader.getElementAsString());
            JMSConnectionFactory.maxPoolSize = portNumber;
        } else if (("min-pool-size" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            final Integer portNumber = Integer.valueOf(elementReader.getElementAsString());
            JMSConnectionFactory.minPoolSize = portNumber;
        } else if (("transactional" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            JMSConnectionFactory.transactional = Boolean.parseBoolean(elementReader.getElementAsString());
        } else if (("property" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: property
            final Property propertyItem = readProperty(elementReader, context);
            if (property == null) {
                property = JMSConnectionFactory.property;
                if (property != null) {
                    property.clear();
                } else {
                    property = new ArrayList<>();
                }
            }
            property.add(propertyItem);
        } else if (!Boolean.getBoolean("tomee.xml.passthrough")) {
            // so to pass if not important
            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", "class-name"), new QName("http://java.sun.com/xml/ns/javaee", "server-name"), new QName("http://java.sun.com/xml/ns/javaee", "port-number"), new QName("http://java.sun.com/xml/ns/javaee", "database-name"), new QName("http://java.sun.com/xml/ns/javaee", "url"), new QName("http://java.sun.com/xml/ns/javaee", "user"), new QName("http://java.sun.com/xml/ns/javaee", "password"), new QName("http://java.sun.com/xml/ns/javaee", "property"), new QName("http://java.sun.com/xml/ns/javaee", "login-timeout"), new QName("http://java.sun.com/xml/ns/javaee", "transactional"), new QName("http://java.sun.com/xml/ns/javaee", "isolation-level"), new QName("http://java.sun.com/xml/ns/javaee", "initial-pool-size"), new QName("http://java.sun.com/xml/ns/javaee", "max-pool-size"), new QName("http://java.sun.com/xml/ns/javaee", "min-pool-size"), new QName("http://java.sun.com/xml/ns/javaee", "max-idle-time"), new QName("http://java.sun.com/xml/ns/javaee", "max-statements"));
        }
    }
    if (descriptions != null) {
        try {
            JMSConnectionFactory.description.set(descriptions.toArray(new Text[descriptions.size()]));
        } catch (final Exception e) {
            context.setterError(reader, JMSConnectionFactory.class, "setDescriptions", Text[].class, e);
        }
    }
    if (property != null) {
        JMSConnectionFactory.property = property;
    }
    context.afterUnmarshal(JMSConnectionFactory, LifecycleCallback.NONE);
    return JMSConnectionFactory;
}
Also used : CollapsedStringAdapter(javax.xml.bind.annotation.adapters.CollapsedStringAdapter) 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) RuntimeContext(org.metatype.sxc.jaxb.RuntimeContext) Property$JAXB.readProperty(org.apache.openejb.jee.Property$JAXB.readProperty) XoXMLStreamReader(org.metatype.sxc.util.XoXMLStreamReader)

Example 22 with XoXMLStreamReader

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

the class JavaWsdlMapping$JAXB method _read.

public static final JavaWsdlMapping _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
    // Check for xsi:nil
    if (reader.isXsiNil()) {
        return null;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final JavaWsdlMapping javaWsdlMapping = new JavaWsdlMapping();
    context.beforeUnmarshal(javaWsdlMapping, LifecycleCallback.NONE);
    KeyedCollection<String, PackageMapping> packageMapping = null;
    List<JavaXmlTypeMapping> javaXmlTypeMapping = null;
    KeyedCollection<QName, ExceptionMapping> exceptionMapping = null;
    List<ServiceInterfaceMapping> serviceInterfaceMapping = null;
    KeyedCollection<String, ServiceEndpointInterfaceMapping> serviceEndpointInterfaceMapping = null;
    // Check xsi:type
    final QName xsiType = reader.getXsiType();
    if (xsiType != null) {
        if (("java-wsdl-mappingType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
            return context.unexpectedXsiType(reader, JavaWsdlMapping.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, javaWsdlMapping);
            javaWsdlMapping.id = id;
        } else if (("version" == attribute.getLocalName()) && (("" == attribute.getNamespace()) || (attribute.getNamespace() == null))) {
            // ATTRIBUTE: version
            javaWsdlMapping.version = Adapters.collapsedStringAdapterAdapter.unmarshal(attribute.getValue());
        } else if (XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI != attribute.getNamespace()) {
            context.unexpectedAttribute(attribute, new QName("", "id"), new QName("", "version"));
        }
    }
    // Read elements
    for (final XoXMLStreamReader elementReader : reader.getChildElements()) {
        if (("package-mapping" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: packageMapping
            final PackageMapping packageMappingItem = readPackageMapping(elementReader, context);
            if (packageMapping == null) {
                packageMapping = javaWsdlMapping.packageMapping;
                if (packageMapping != null) {
                    packageMapping.clear();
                } else {
                    packageMapping = new KeyedCollection<String, PackageMapping>();
                }
            }
            packageMapping.add(packageMappingItem);
        } else if (("java-xml-type-mapping" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: javaXmlTypeMapping
            final JavaXmlTypeMapping javaXmlTypeMappingItem = readJavaXmlTypeMapping(elementReader, context);
            if (javaXmlTypeMapping == null) {
                javaXmlTypeMapping = javaWsdlMapping.javaXmlTypeMapping;
                if (javaXmlTypeMapping != null) {
                    javaXmlTypeMapping.clear();
                } else {
                    javaXmlTypeMapping = new ArrayList<JavaXmlTypeMapping>();
                }
            }
            javaXmlTypeMapping.add(javaXmlTypeMappingItem);
        } else if (("exception-mapping" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: exceptionMapping
            final ExceptionMapping exceptionMappingItem = readExceptionMapping(elementReader, context);
            if (exceptionMapping == null) {
                exceptionMapping = javaWsdlMapping.exceptionMapping;
                if (exceptionMapping != null) {
                    exceptionMapping.clear();
                } else {
                    exceptionMapping = new KeyedCollection<QName, ExceptionMapping>();
                }
            }
            exceptionMapping.add(exceptionMappingItem);
        } else if (("service-interface-mapping" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: serviceInterfaceMapping
            final ServiceInterfaceMapping serviceInterfaceMappingItem = readServiceInterfaceMapping(elementReader, context);
            if (serviceInterfaceMapping == null) {
                serviceInterfaceMapping = javaWsdlMapping.serviceInterfaceMapping;
                if (serviceInterfaceMapping != null) {
                    serviceInterfaceMapping.clear();
                } else {
                    serviceInterfaceMapping = new ArrayList<ServiceInterfaceMapping>();
                }
            }
            serviceInterfaceMapping.add(serviceInterfaceMappingItem);
        } else if (("service-endpoint-interface-mapping" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: serviceEndpointInterfaceMapping
            final ServiceEndpointInterfaceMapping serviceEndpointInterfaceMappingItem = readServiceEndpointInterfaceMapping(elementReader, context);
            if (serviceEndpointInterfaceMapping == null) {
                serviceEndpointInterfaceMapping = javaWsdlMapping.serviceEndpointInterfaceMapping;
                if (serviceEndpointInterfaceMapping != null) {
                    serviceEndpointInterfaceMapping.clear();
                } else {
                    serviceEndpointInterfaceMapping = new KeyedCollection<String, ServiceEndpointInterfaceMapping>();
                }
            }
            serviceEndpointInterfaceMapping.add(serviceEndpointInterfaceMappingItem);
        } else {
            context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "package-mapping"), new QName("http://java.sun.com/xml/ns/javaee", "java-xml-type-mapping"), new QName("http://java.sun.com/xml/ns/javaee", "exception-mapping"), new QName("http://java.sun.com/xml/ns/javaee", "service-interface-mapping"), new QName("http://java.sun.com/xml/ns/javaee", "service-endpoint-interface-mapping"));
        }
    }
    if (packageMapping != null) {
        javaWsdlMapping.packageMapping = packageMapping;
    }
    if (javaXmlTypeMapping != null) {
        javaWsdlMapping.javaXmlTypeMapping = javaXmlTypeMapping;
    }
    if (exceptionMapping != null) {
        javaWsdlMapping.exceptionMapping = exceptionMapping;
    }
    if (serviceInterfaceMapping != null) {
        javaWsdlMapping.serviceInterfaceMapping = serviceInterfaceMapping;
    }
    if (serviceEndpointInterfaceMapping != null) {
        javaWsdlMapping.serviceEndpointInterfaceMapping = serviceEndpointInterfaceMapping;
    }
    context.afterUnmarshal(javaWsdlMapping, LifecycleCallback.NONE);
    return javaWsdlMapping;
}
Also used : Attribute(org.metatype.sxc.util.Attribute) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) JavaXmlTypeMapping$JAXB.readJavaXmlTypeMapping(org.apache.openejb.jee.JavaXmlTypeMapping$JAXB.readJavaXmlTypeMapping) JavaXmlTypeMapping$JAXB.writeJavaXmlTypeMapping(org.apache.openejb.jee.JavaXmlTypeMapping$JAXB.writeJavaXmlTypeMapping) ExceptionMapping$JAXB.readExceptionMapping(org.apache.openejb.jee.ExceptionMapping$JAXB.readExceptionMapping) ExceptionMapping$JAXB.writeExceptionMapping(org.apache.openejb.jee.ExceptionMapping$JAXB.writeExceptionMapping) ServiceEndpointInterfaceMapping$JAXB.writeServiceEndpointInterfaceMapping(org.apache.openejb.jee.ServiceEndpointInterfaceMapping$JAXB.writeServiceEndpointInterfaceMapping) ServiceEndpointInterfaceMapping$JAXB.readServiceEndpointInterfaceMapping(org.apache.openejb.jee.ServiceEndpointInterfaceMapping$JAXB.readServiceEndpointInterfaceMapping) ServiceInterfaceMapping$JAXB.readServiceInterfaceMapping(org.apache.openejb.jee.ServiceInterfaceMapping$JAXB.readServiceInterfaceMapping) ServiceInterfaceMapping$JAXB.writeServiceInterfaceMapping(org.apache.openejb.jee.ServiceInterfaceMapping$JAXB.writeServiceInterfaceMapping) RuntimeContext(org.metatype.sxc.jaxb.RuntimeContext) PackageMapping$JAXB.readPackageMapping(org.apache.openejb.jee.PackageMapping$JAXB.readPackageMapping) PackageMapping$JAXB.writePackageMapping(org.apache.openejb.jee.PackageMapping$JAXB.writePackageMapping) XoXMLStreamReader(org.metatype.sxc.util.XoXMLStreamReader)

Example 23 with XoXMLStreamReader

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

the class JavaXmlTypeMapping$JAXB method _read.

public static final JavaXmlTypeMapping _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
    // Check for xsi:nil
    if (reader.isXsiNil()) {
        return null;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final JavaXmlTypeMapping javaXmlTypeMapping = new JavaXmlTypeMapping();
    context.beforeUnmarshal(javaXmlTypeMapping, LifecycleCallback.NONE);
    List<VariableMapping> variableMapping = null;
    // Check xsi:type
    final QName xsiType = reader.getXsiType();
    if (xsiType != null) {
        if (("java-xml-type-mappingType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
            return context.unexpectedXsiType(reader, JavaXmlTypeMapping.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, javaXmlTypeMapping);
            javaXmlTypeMapping.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 (("java-type" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: javaType
            final String javaTypeRaw = elementReader.getElementAsString();
            final String javaType;
            try {
                javaType = Adapters.collapsedStringAdapterAdapter.unmarshal(javaTypeRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            javaXmlTypeMapping.javaType = javaType;
        } else if (("root-type-qname" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: rootTypeQname
            final QName rootTypeQname = elementReader.getElementAsQName();
            javaXmlTypeMapping.rootTypeQname = rootTypeQname;
        } else if (("anonymous-type-qname" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: anonymousTypeQname
            final String anonymousTypeQnameRaw = elementReader.getElementAsString();
            final String anonymousTypeQname;
            try {
                anonymousTypeQname = Adapters.collapsedStringAdapterAdapter.unmarshal(anonymousTypeQnameRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            javaXmlTypeMapping.anonymousTypeQname = anonymousTypeQname;
        } else if (("qname-scope" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: qnameScope
            final String qnameScopeRaw = elementReader.getElementAsString();
            final String qnameScope;
            try {
                qnameScope = Adapters.collapsedStringAdapterAdapter.unmarshal(qnameScopeRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            javaXmlTypeMapping.qnameScope = qnameScope;
        } else if (("variable-mapping" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: variableMapping
            final VariableMapping variableMappingItem = readVariableMapping(elementReader, context);
            if (variableMapping == null) {
                variableMapping = javaXmlTypeMapping.variableMapping;
                if (variableMapping != null) {
                    variableMapping.clear();
                } else {
                    variableMapping = new ArrayList<VariableMapping>();
                }
            }
            variableMapping.add(variableMappingItem);
        } else {
            context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "java-type"), new QName("http://java.sun.com/xml/ns/javaee", "root-type-qname"), new QName("http://java.sun.com/xml/ns/javaee", "anonymous-type-qname"), new QName("http://java.sun.com/xml/ns/javaee", "qname-scope"), new QName("http://java.sun.com/xml/ns/javaee", "variable-mapping"));
        }
    }
    if (variableMapping != null) {
        javaXmlTypeMapping.variableMapping = variableMapping;
    }
    context.afterUnmarshal(javaXmlTypeMapping, LifecycleCallback.NONE);
    return javaXmlTypeMapping;
}
Also used : CollapsedStringAdapter(javax.xml.bind.annotation.adapters.CollapsedStringAdapter) Attribute(org.metatype.sxc.util.Attribute) VariableMapping$JAXB.readVariableMapping(org.apache.openejb.jee.VariableMapping$JAXB.readVariableMapping) VariableMapping$JAXB.writeVariableMapping(org.apache.openejb.jee.VariableMapping$JAXB.writeVariableMapping) QName(javax.xml.namespace.QName) RuntimeContext(org.metatype.sxc.jaxb.RuntimeContext) XoXMLStreamReader(org.metatype.sxc.util.XoXMLStreamReader)

Example 24 with XoXMLStreamReader

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

the class JspConfig$JAXB method _read.

public static final JspConfig _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
    // Check for xsi:nil
    if (reader.isXsiNil()) {
        return null;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final JspConfig jspConfig = new JspConfig();
    context.beforeUnmarshal(jspConfig, LifecycleCallback.NONE);
    List<Taglib> taglib = null;
    List<JspPropertyGroup> jspPropertyGroup = null;
    // Check xsi:type
    final QName xsiType = reader.getXsiType();
    if (xsiType != null) {
        if (("jsp-configType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
            return context.unexpectedXsiType(reader, JspConfig.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, jspConfig);
            jspConfig.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 (("taglib" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: taglib
            final Taglib taglibItem = readTaglib(elementReader, context);
            if (taglib == null) {
                taglib = jspConfig.taglib;
                if (taglib != null) {
                    taglib.clear();
                } else {
                    taglib = new ArrayList<Taglib>();
                }
            }
            taglib.add(taglibItem);
        } else if (("jsp-property-group" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: jspPropertyGroup
            final JspPropertyGroup jspPropertyGroupItem = readJspPropertyGroup(elementReader, context);
            if (jspPropertyGroup == null) {
                jspPropertyGroup = jspConfig.jspPropertyGroup;
                if (jspPropertyGroup != null) {
                    jspPropertyGroup.clear();
                } else {
                    jspPropertyGroup = new ArrayList<JspPropertyGroup>();
                }
            }
            jspPropertyGroup.add(jspPropertyGroupItem);
        } else {
            context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "taglib"), new QName("http://java.sun.com/xml/ns/javaee", "jsp-property-group"));
        }
    }
    if (taglib != null) {
        jspConfig.taglib = taglib;
    }
    if (jspPropertyGroup != null) {
        jspConfig.jspPropertyGroup = jspPropertyGroup;
    }
    context.afterUnmarshal(jspConfig, LifecycleCallback.NONE);
    return jspConfig;
}
Also used : Taglib$JAXB.writeTaglib(org.apache.openejb.jee.Taglib$JAXB.writeTaglib) Taglib$JAXB.readTaglib(org.apache.openejb.jee.Taglib$JAXB.readTaglib) Attribute(org.metatype.sxc.util.Attribute) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) RuntimeContext(org.metatype.sxc.jaxb.RuntimeContext) JspPropertyGroup$JAXB.readJspPropertyGroup(org.apache.openejb.jee.JspPropertyGroup$JAXB.readJspPropertyGroup) JspPropertyGroup$JAXB.writeJspPropertyGroup(org.apache.openejb.jee.JspPropertyGroup$JAXB.writeJspPropertyGroup) XoXMLStreamReader(org.metatype.sxc.util.XoXMLStreamReader)

Example 25 with XoXMLStreamReader

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

the class Listener$JAXB method _read.

public static final Listener _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
    // Check for xsi:nil
    if (reader.isXsiNil()) {
        return null;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final Listener listener = new Listener();
    context.beforeUnmarshal(listener, LifecycleCallback.NONE);
    ArrayList<Text> descriptions = null;
    ArrayList<Text> displayNames = null;
    LocalCollection<Icon> icon = null;
    // Check xsi:type
    final QName xsiType = reader.getXsiType();
    if (xsiType != null) {
        if (("listenerType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
            return context.unexpectedXsiType(reader, Listener.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, listener);
            listener.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 = listener.icon;
                if (icon != null) {
                    icon.clear();
                } else {
                    icon = new LocalCollection<Icon>();
                }
            }
            icon.add(iconItem);
        } else if (("listener-class" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: listenerClass
            final String listenerClassRaw = elementReader.getElementAsString();
            final String listenerClass;
            try {
                listenerClass = Adapters.collapsedStringAdapterAdapter.unmarshal(listenerClassRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            listener.listenerClass = listenerClass;
        } 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", "listener-class"));
        }
    }
    if (descriptions != null) {
        try {
            listener.setDescriptions(descriptions.toArray(new Text[descriptions.size()]));
        } catch (final Exception e) {
            context.setterError(reader, Listener.class, "setDescriptions", Text[].class, e);
        }
    }
    if (displayNames != null) {
        try {
            listener.setDisplayNames(displayNames.toArray(new Text[displayNames.size()]));
        } catch (final Exception e) {
            context.setterError(reader, Listener.class, "setDisplayNames", Text[].class, e);
        }
    }
    if (icon != null) {
        listener.icon = icon;
    }
    context.afterUnmarshal(listener, LifecycleCallback.NONE);
    return listener;
}
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) 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)

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