Search in sources :

Example 11 with Attribute

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

the class AuthConstraint$JAXB method _read.

public static final AuthConstraint _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
    // Check for xsi:nil
    if (reader.isXsiNil()) {
        return null;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final AuthConstraint authConstraint = new AuthConstraint();
    context.beforeUnmarshal(authConstraint, LifecycleCallback.NONE);
    ArrayList<Text> descriptions = null;
    List<String> roleName = null;
    // Check xsi:type
    final QName xsiType = reader.getXsiType();
    if (xsiType != null) {
        if (("auth-constraintType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
            return context.unexpectedXsiType(reader, AuthConstraint.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, authConstraint);
            authConstraint.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 (("role-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: roleName
            final String roleNameItemRaw = elementReader.getElementAsString();
            final String roleNameItem;
            try {
                roleNameItem = Adapters.collapsedStringAdapterAdapter.unmarshal(roleNameItemRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            if (roleName == null) {
                roleName = authConstraint.roleName;
                if (roleName != null) {
                    roleName.clear();
                } else {
                    roleName = new ArrayList<String>();
                }
            }
            roleName.add(roleNameItem);
        } else {
            context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "description"), new QName("http://java.sun.com/xml/ns/javaee", "role-name"));
        }
    }
    if (descriptions != null) {
        try {
            authConstraint.setDescriptions(descriptions.toArray(new Text[descriptions.size()]));
        } catch (final Exception e) {
            context.setterError(reader, AuthConstraint.class, "setDescriptions", Text[].class, e);
        }
    }
    if (roleName != null) {
        authConstraint.roleName = roleName;
    }
    context.afterUnmarshal(authConstraint, LifecycleCallback.NONE);
    return authConstraint;
}
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) RuntimeContext(org.metatype.sxc.jaxb.RuntimeContext) XoXMLStreamReader(org.metatype.sxc.util.XoXMLStreamReader)

Example 12 with Attribute

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

the class AuthenticationMechanism$JAXB method _read.

public static final AuthenticationMechanism _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
    // Check for xsi:nil
    if (reader.isXsiNil()) {
        return null;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final AuthenticationMechanism authenticationMechanism = new AuthenticationMechanism();
    context.beforeUnmarshal(authenticationMechanism, LifecycleCallback.NONE);
    ArrayList<Text> descriptions = null;
    // Check xsi:type
    final QName xsiType = reader.getXsiType();
    if (xsiType != null) {
        if (("authentication-mechanismType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
            return context.unexpectedXsiType(reader, AuthenticationMechanism.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, authenticationMechanism);
            authenticationMechanism.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 (("authentication-mechanism-type" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: authenticationMechanismType
            final String authenticationMechanismTypeRaw = elementReader.getElementAsString();
            final String authenticationMechanismType;
            try {
                authenticationMechanismType = Adapters.collapsedStringAdapterAdapter.unmarshal(authenticationMechanismTypeRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            authenticationMechanism.authenticationMechanismType = authenticationMechanismType;
        } else if (("credential-interface" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: credentialInterface
            final String credentialInterfaceRaw = elementReader.getElementAsString();
            final String credentialInterface;
            try {
                credentialInterface = Adapters.collapsedStringAdapterAdapter.unmarshal(credentialInterfaceRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            authenticationMechanism.credentialInterface = credentialInterface;
        } else {
            context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "description"), new QName("http://java.sun.com/xml/ns/javaee", "authentication-mechanism-type"), new QName("http://java.sun.com/xml/ns/javaee", "credential-interface"));
        }
    }
    if (descriptions != null) {
        try {
            authenticationMechanism.setDescriptions(descriptions.toArray(new Text[descriptions.size()]));
        } catch (final Exception e) {
            context.setterError(reader, AuthenticationMechanism.class, "setDescriptions", Text[].class, e);
        }
    }
    context.afterUnmarshal(authenticationMechanism, LifecycleCallback.NONE);
    return authenticationMechanism;
}
Also used : 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) RuntimeContext(org.metatype.sxc.jaxb.RuntimeContext) XoXMLStreamReader(org.metatype.sxc.util.XoXMLStreamReader)

Example 13 with Attribute

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

the class ConnectionDefinition$JAXB method _read.

public static final ConnectionDefinition _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
    // Check for xsi:nil
    if (reader.isXsiNil()) {
        return null;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final ConnectionDefinition connectionDefinition = new ConnectionDefinition();
    context.beforeUnmarshal(connectionDefinition, LifecycleCallback.NONE);
    List<ConfigProperty> configProperty = null;
    // Check xsi:type
    final QName xsiType = reader.getXsiType();
    if (xsiType != null) {
        if (("connection-definitionType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
            return context.unexpectedXsiType(reader, ConnectionDefinition.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, connectionDefinition);
            connectionDefinition.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 (("managedconnectionfactory-class" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: managedConnectionFactoryClass
            final String managedConnectionFactoryClassRaw = elementReader.getElementAsString();
            final String managedConnectionFactoryClass;
            try {
                managedConnectionFactoryClass = Adapters.collapsedStringAdapterAdapter.unmarshal(managedConnectionFactoryClassRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            connectionDefinition.managedConnectionFactoryClass = managedConnectionFactoryClass;
        } else if (("config-property" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: configProperty
            final ConfigProperty configPropertyItem = readConfigProperty(elementReader, context);
            if (configProperty == null) {
                configProperty = connectionDefinition.configProperty;
                if (configProperty != null) {
                    configProperty.clear();
                } else {
                    configProperty = new ArrayList<ConfigProperty>();
                }
            }
            configProperty.add(configPropertyItem);
        } else if (("connectionfactory-interface" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: connectionFactoryInterface
            final String connectionFactoryInterfaceRaw = elementReader.getElementAsString();
            final String connectionFactoryInterface;
            try {
                connectionFactoryInterface = Adapters.collapsedStringAdapterAdapter.unmarshal(connectionFactoryInterfaceRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            connectionDefinition.connectionFactoryInterface = connectionFactoryInterface;
        } else if (("connectionfactory-impl-class" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: connectionFactoryImplClass
            final String connectionFactoryImplClassRaw = elementReader.getElementAsString();
            final String connectionFactoryImplClass;
            try {
                connectionFactoryImplClass = Adapters.collapsedStringAdapterAdapter.unmarshal(connectionFactoryImplClassRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            connectionDefinition.connectionFactoryImplClass = connectionFactoryImplClass;
        } else if (("connection-interface" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: connectionInterface
            final String connectionInterfaceRaw = elementReader.getElementAsString();
            final String connectionInterface;
            try {
                connectionInterface = Adapters.collapsedStringAdapterAdapter.unmarshal(connectionInterfaceRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            connectionDefinition.connectionInterface = connectionInterface;
        } else if (("connection-impl-class" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: connectionImplClass
            final String connectionImplClassRaw = elementReader.getElementAsString();
            final String connectionImplClass;
            try {
                connectionImplClass = Adapters.collapsedStringAdapterAdapter.unmarshal(connectionImplClassRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            connectionDefinition.connectionImplClass = connectionImplClass;
        } else {
            context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "managedconnectionfactory-class"), new QName("http://java.sun.com/xml/ns/javaee", "config-property"), new QName("http://java.sun.com/xml/ns/javaee", "connectionfactory-interface"), new QName("http://java.sun.com/xml/ns/javaee", "connectionfactory-impl-class"), new QName("http://java.sun.com/xml/ns/javaee", "connection-interface"), new QName("http://java.sun.com/xml/ns/javaee", "connection-impl-class"));
        }
    }
    if (configProperty != null) {
        connectionDefinition.configProperty = configProperty;
    }
    context.afterUnmarshal(connectionDefinition, LifecycleCallback.NONE);
    return connectionDefinition;
}
Also used : CollapsedStringAdapter(javax.xml.bind.annotation.adapters.CollapsedStringAdapter) Attribute(org.metatype.sxc.util.Attribute) QName(javax.xml.namespace.QName) ConfigProperty$JAXB.readConfigProperty(org.apache.openejb.jee.ConfigProperty$JAXB.readConfigProperty) ConfigProperty$JAXB.writeConfigProperty(org.apache.openejb.jee.ConfigProperty$JAXB.writeConfigProperty) ArrayList(java.util.ArrayList) RuntimeContext(org.metatype.sxc.jaxb.RuntimeContext) XoXMLStreamReader(org.metatype.sxc.util.XoXMLStreamReader)

Example 14 with Attribute

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

the class FacesComponent$JAXB method _read.

public static final FacesComponent _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
    // Check for xsi:nil
    if (reader.isXsiNil()) {
        return null;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final FacesComponent facesComponent = new FacesComponent();
    context.beforeUnmarshal(facesComponent, LifecycleCallback.NONE);
    ArrayList<Text> descriptions = null;
    ArrayList<Text> displayNames = null;
    LocalCollection<Icon> icon = null;
    List<FacesFacet> facet = null;
    List<FacesAttribute> attribute1 = null;
    List<FacesProperty> property = null;
    List<FacesComponentExtension> componentExtension = null;
    // Check xsi:type
    final QName xsiType = reader.getXsiType();
    if (xsiType != null) {
        if (("faces-config-componentType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
            return context.unexpectedXsiType(reader, FacesComponent.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, facesComponent);
            facesComponent.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 = facesComponent.icon;
                if (icon != null) {
                    icon.clear();
                } else {
                    icon = new LocalCollection<Icon>();
                }
            }
            icon.add(iconItem);
        } else if (("component-type" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: componentType
            final String componentTypeRaw = elementReader.getElementAsString();
            final String componentType;
            try {
                componentType = Adapters.collapsedStringAdapterAdapter.unmarshal(componentTypeRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            facesComponent.componentType = componentType;
        } else if (("component-class" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: componentClass
            final String componentClassRaw = elementReader.getElementAsString();
            final String componentClass;
            try {
                componentClass = Adapters.collapsedStringAdapterAdapter.unmarshal(componentClassRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            facesComponent.componentClass = componentClass;
        } else if (("facet" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: facet
            final FacesFacet facetItem = readFacesFacet(elementReader, context);
            if (facet == null) {
                facet = facesComponent.facet;
                if (facet != null) {
                    facet.clear();
                } else {
                    facet = new ArrayList<FacesFacet>();
                }
            }
            facet.add(facetItem);
        } 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 = facesComponent.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 = facesComponent.property;
                if (property != null) {
                    property.clear();
                } else {
                    property = new ArrayList<FacesProperty>();
                }
            }
            property.add(propertyItem);
        } else if (("component-extension" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: componentExtension
            final FacesComponentExtension componentExtensionItem = readFacesComponentExtension(elementReader, context);
            if (componentExtension == null) {
                componentExtension = facesComponent.componentExtension;
                if (componentExtension != null) {
                    componentExtension.clear();
                } else {
                    componentExtension = new ArrayList<FacesComponentExtension>();
                }
            }
            componentExtension.add(componentExtensionItem);
        } 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", "component-type"), new QName("http://java.sun.com/xml/ns/javaee", "component-class"), new QName("http://java.sun.com/xml/ns/javaee", "facet"), 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", "component-extension"));
        }
    }
    if (descriptions != null) {
        try {
            facesComponent.setDescriptions(descriptions.toArray(new Text[descriptions.size()]));
        } catch (final Exception e) {
            context.setterError(reader, FacesComponent.class, "setDescriptions", Text[].class, e);
        }
    }
    if (displayNames != null) {
        try {
            facesComponent.setDisplayNames(displayNames.toArray(new Text[displayNames.size()]));
        } catch (final Exception e) {
            context.setterError(reader, FacesComponent.class, "setDisplayNames", Text[].class, e);
        }
    }
    if (icon != null) {
        facesComponent.icon = icon;
    }
    if (facet != null) {
        facesComponent.facet = facet;
    }
    if (attribute1 != null) {
        facesComponent.attribute = attribute1;
    }
    if (property != null) {
        facesComponent.property = property;
    }
    if (componentExtension != null) {
        facesComponent.componentExtension = componentExtension;
    }
    context.afterUnmarshal(facesComponent, LifecycleCallback.NONE);
    return facesComponent;
}
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) FacesComponentExtension$JAXB.readFacesComponentExtension(org.apache.openejb.jee.FacesComponentExtension$JAXB.readFacesComponentExtension) FacesComponentExtension$JAXB.writeFacesComponentExtension(org.apache.openejb.jee.FacesComponentExtension$JAXB.writeFacesComponentExtension) QName(javax.xml.namespace.QName) 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) FacesFacet$JAXB.readFacesFacet(org.apache.openejb.jee.FacesFacet$JAXB.readFacesFacet) FacesFacet$JAXB.writeFacesFacet(org.apache.openejb.jee.FacesFacet$JAXB.writeFacesFacet) 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)

Example 15 with Attribute

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

the class FacesConfig$JAXB method _read.

public static final FacesConfig _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
    // Check for xsi:nil
    if (reader.isXsiNil()) {
        return null;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final FacesConfig facesConfig = new FacesConfig();
    context.beforeUnmarshal(facesConfig, LifecycleCallback.NONE);
    List<FacesApplication> application = null;
    List<FacesOrdering> ordering = null;
    List<FacesAbsoluteOrdering> absoluteOrdering = null;
    List<FacesFactory> factory = null;
    List<FacesComponent> component = null;
    List<FacesConverter> converter = null;
    List<FacesManagedBean> managedBean = null;
    List<String> name = null;
    List<FacesNavigationRule> navigationRule = null;
    List<FacesReferencedBean> referencedBean = null;
    List<FacesRenderKit> renderKit = null;
    List<FacesLifecycle> lifecycle = null;
    List<FacesValidator> validator = null;
    List<FacesBehavior> behavior = null;
    List<FacesExtension> facesConfigExtension = null;
    // Check xsi:type
    final QName xsiType = reader.getXsiType();
    if (xsiType != null) {
        if (("faces-configType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
            return context.unexpectedXsiType(reader, FacesConfig.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, facesConfig);
            facesConfig.id = id;
        } else if (("version" == attribute.getLocalName()) && (("" == attribute.getNamespace()) || (attribute.getNamespace() == null))) {
            // ATTRIBUTE: version
            facesConfig.version = Adapters.collapsedStringAdapterAdapter.unmarshal(attribute.getValue());
        } else if (("metadata-complete" == attribute.getLocalName()) && (("" == attribute.getNamespace()) || (attribute.getNamespace() == null))) {
            // ATTRIBUTE: metadataComplete
            final Boolean metadataComplete = ("1".equals(attribute.getValue()) || "true".equals(attribute.getValue()));
            facesConfig.metadataComplete = metadataComplete;
        } else if (XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI != attribute.getNamespace()) {
            context.unexpectedAttribute(attribute, new QName("", "id"), new QName("", "version"), new QName("", "metadata-complete"));
        }
    }
    // Read elements
    for (final XoXMLStreamReader elementReader : reader.getChildElements()) {
        if (("application" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: application
            final FacesApplication applicationItem = readFacesApplication(elementReader, context);
            if (application == null) {
                application = facesConfig.application;
                if (application != null) {
                    application.clear();
                } else {
                    application = new ArrayList<FacesApplication>();
                }
            }
            application.add(applicationItem);
        } else if (("ordering" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: ordering
            final FacesOrdering orderingItem = readFacesOrdering(elementReader, context);
            if (ordering == null) {
                ordering = facesConfig.ordering;
                if (ordering != null) {
                    ordering.clear();
                } else {
                    ordering = new ArrayList<FacesOrdering>();
                }
            }
            ordering.add(orderingItem);
        } else if (("absolute-ordering" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: absoluteOrdering
            final FacesAbsoluteOrdering absoluteOrderingItem = readFacesAbsoluteOrdering(elementReader, context);
            if (absoluteOrdering == null) {
                absoluteOrdering = facesConfig.absoluteOrdering;
                if (absoluteOrdering != null) {
                    absoluteOrdering.clear();
                } else {
                    absoluteOrdering = new ArrayList<FacesAbsoluteOrdering>();
                }
            }
            absoluteOrdering.add(absoluteOrderingItem);
        } else if (("factory" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: factory
            final FacesFactory factoryItem = readFacesFactory(elementReader, context);
            if (factory == null) {
                factory = facesConfig.factory;
                if (factory != null) {
                    factory.clear();
                } else {
                    factory = new ArrayList<FacesFactory>();
                }
            }
            factory.add(factoryItem);
        } else if (("component" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: component
            final FacesComponent componentItem = readFacesComponent(elementReader, context);
            if (component == null) {
                component = facesConfig.component;
                if (component != null) {
                    component.clear();
                } else {
                    component = new ArrayList<FacesComponent>();
                }
            }
            component.add(componentItem);
        } else if (("converter" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: converter
            final FacesConverter converterItem = readFacesConverter(elementReader, context);
            if (converter == null) {
                converter = facesConfig.converter;
                if (converter != null) {
                    converter.clear();
                } else {
                    converter = new ArrayList<FacesConverter>();
                }
            }
            converter.add(converterItem);
        } else if (("managed-bean" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: managedBean
            final FacesManagedBean managedBeanItem = readFacesManagedBean(elementReader, context);
            if (managedBean == null) {
                managedBean = facesConfig.managedBean;
                if (managedBean != null) {
                    managedBean.clear();
                } else {
                    managedBean = new ArrayList<FacesManagedBean>();
                }
            }
            managedBean.add(managedBeanItem);
        } else if (("name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: name
            String nameItemRaw = null;
            if (!elementReader.isXsiNil()) {
                nameItemRaw = elementReader.getElementAsString();
            }
            final String nameItem;
            try {
                nameItem = Adapters.collapsedStringAdapterAdapter.unmarshal(nameItemRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            if (name == null) {
                name = facesConfig.name;
                if (name != null) {
                    name.clear();
                } else {
                    name = new ArrayList<String>();
                }
            }
            name.add(nameItem);
        } else if (("navigation-rule" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: navigationRule
            final FacesNavigationRule navigationRuleItem = readFacesNavigationRule(elementReader, context);
            if (navigationRule == null) {
                navigationRule = facesConfig.navigationRule;
                if (navigationRule != null) {
                    navigationRule.clear();
                } else {
                    navigationRule = new ArrayList<FacesNavigationRule>();
                }
            }
            navigationRule.add(navigationRuleItem);
        } else if (("referenced-bean" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: referencedBean
            final FacesReferencedBean referencedBeanItem = readFacesReferencedBean(elementReader, context);
            if (referencedBean == null) {
                referencedBean = facesConfig.referencedBean;
                if (referencedBean != null) {
                    referencedBean.clear();
                } else {
                    referencedBean = new ArrayList<FacesReferencedBean>();
                }
            }
            referencedBean.add(referencedBeanItem);
        } else if (("render-kit" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: renderKit
            final FacesRenderKit renderKitItem = readFacesRenderKit(elementReader, context);
            if (renderKit == null) {
                renderKit = facesConfig.renderKit;
                if (renderKit != null) {
                    renderKit.clear();
                } else {
                    renderKit = new ArrayList<FacesRenderKit>();
                }
            }
            renderKit.add(renderKitItem);
        } else if (("lifecycle" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: lifecycle
            final FacesLifecycle lifecycleItem = readFacesLifecycle(elementReader, context);
            if (lifecycle == null) {
                lifecycle = facesConfig.lifecycle;
                if (lifecycle != null) {
                    lifecycle.clear();
                } else {
                    lifecycle = new ArrayList<FacesLifecycle>();
                }
            }
            lifecycle.add(lifecycleItem);
        } else if (("validator" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: validator
            final FacesValidator validatorItem = readFacesValidator(elementReader, context);
            if (validator == null) {
                validator = facesConfig.validator;
                if (validator != null) {
                    validator.clear();
                } else {
                    validator = new ArrayList<FacesValidator>();
                }
            }
            validator.add(validatorItem);
        } else if (("behavior" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: behavior
            final FacesBehavior behaviorItem = readFacesBehavior(elementReader, context);
            if (behavior == null) {
                behavior = facesConfig.behavior;
                if (behavior != null) {
                    behavior.clear();
                } else {
                    behavior = new ArrayList<FacesBehavior>();
                }
            }
            behavior.add(behaviorItem);
        } else if (("faces-config-extension" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: facesConfigExtension
            final FacesExtension facesConfigExtensionItem = readFacesExtension(elementReader, context);
            if (facesConfigExtension == null) {
                facesConfigExtension = facesConfig.facesConfigExtension;
                if (facesConfigExtension != null) {
                    facesConfigExtension.clear();
                } else {
                    facesConfigExtension = new ArrayList<FacesExtension>();
                }
            }
            facesConfigExtension.add(facesConfigExtensionItem);
        } else if ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI()) {
        // just here ATM to not prevent users to get JSF 2.2 feature because we can't read it
        // TODO:  read it if we need it (= classes to add to injectable classes, other file to parse to find them etc...)
        } else {
            context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "application"), new QName("http://java.sun.com/xml/ns/javaee", "ordering"), new QName("http://java.sun.com/xml/ns/javaee", "absolute-ordering"), new QName("http://java.sun.com/xml/ns/javaee", "factory"), new QName("http://java.sun.com/xml/ns/javaee", "component"), new QName("http://java.sun.com/xml/ns/javaee", "converter"), new QName("http://java.sun.com/xml/ns/javaee", "managed-bean"), new QName("http://java.sun.com/xml/ns/javaee", "name"), new QName("http://java.sun.com/xml/ns/javaee", "navigation-rule"), new QName("http://java.sun.com/xml/ns/javaee", "referenced-bean"), new QName("http://java.sun.com/xml/ns/javaee", "render-kit"), new QName("http://java.sun.com/xml/ns/javaee", "lifecycle"), new QName("http://java.sun.com/xml/ns/javaee", "validator"), new QName("http://java.sun.com/xml/ns/javaee", "behavior"), new QName("http://java.sun.com/xml/ns/javaee", "faces-config-extension"));
        }
    }
    if (application != null) {
        facesConfig.application = application;
    }
    if (ordering != null) {
        facesConfig.ordering = ordering;
    }
    if (absoluteOrdering != null) {
        facesConfig.absoluteOrdering = absoluteOrdering;
    }
    if (factory != null) {
        facesConfig.factory = factory;
    }
    if (component != null) {
        facesConfig.component = component;
    }
    if (converter != null) {
        facesConfig.converter = converter;
    }
    if (managedBean != null) {
        facesConfig.managedBean = managedBean;
    }
    if (name != null) {
        facesConfig.name = name;
    }
    if (navigationRule != null) {
        facesConfig.navigationRule = navigationRule;
    }
    if (referencedBean != null) {
        facesConfig.referencedBean = referencedBean;
    }
    if (renderKit != null) {
        facesConfig.renderKit = renderKit;
    }
    if (lifecycle != null) {
        facesConfig.lifecycle = lifecycle;
    }
    if (validator != null) {
        facesConfig.validator = validator;
    }
    if (behavior != null) {
        facesConfig.behavior = behavior;
    }
    if (facesConfigExtension != null) {
        facesConfig.facesConfigExtension = facesConfigExtension;
    }
    context.afterUnmarshal(facesConfig, LifecycleCallback.NONE);
    return facesConfig;
}
Also used : FacesNavigationRule$JAXB.readFacesNavigationRule(org.apache.openejb.jee.FacesNavigationRule$JAXB.readFacesNavigationRule) FacesNavigationRule$JAXB.writeFacesNavigationRule(org.apache.openejb.jee.FacesNavigationRule$JAXB.writeFacesNavigationRule) FacesManagedBean$JAXB.writeFacesManagedBean(org.apache.openejb.jee.FacesManagedBean$JAXB.writeFacesManagedBean) FacesManagedBean$JAXB.readFacesManagedBean(org.apache.openejb.jee.FacesManagedBean$JAXB.readFacesManagedBean) Attribute(org.metatype.sxc.util.Attribute) ArrayList(java.util.ArrayList) FacesApplication$JAXB.readFacesApplication(org.apache.openejb.jee.FacesApplication$JAXB.readFacesApplication) FacesApplication$JAXB.writeFacesApplication(org.apache.openejb.jee.FacesApplication$JAXB.writeFacesApplication) FacesLifecycle$JAXB.writeFacesLifecycle(org.apache.openejb.jee.FacesLifecycle$JAXB.writeFacesLifecycle) FacesLifecycle$JAXB.readFacesLifecycle(org.apache.openejb.jee.FacesLifecycle$JAXB.readFacesLifecycle) FacesReferencedBean$JAXB.writeFacesReferencedBean(org.apache.openejb.jee.FacesReferencedBean$JAXB.writeFacesReferencedBean) FacesReferencedBean$JAXB.readFacesReferencedBean(org.apache.openejb.jee.FacesReferencedBean$JAXB.readFacesReferencedBean) FacesValidator$JAXB.readFacesValidator(org.apache.openejb.jee.FacesValidator$JAXB.readFacesValidator) FacesValidator$JAXB.writeFacesValidator(org.apache.openejb.jee.FacesValidator$JAXB.writeFacesValidator) XoXMLStreamReader(org.metatype.sxc.util.XoXMLStreamReader) FacesRenderKit$JAXB.writeFacesRenderKit(org.apache.openejb.jee.FacesRenderKit$JAXB.writeFacesRenderKit) FacesRenderKit$JAXB.readFacesRenderKit(org.apache.openejb.jee.FacesRenderKit$JAXB.readFacesRenderKit) FacesConverter$JAXB.readFacesConverter(org.apache.openejb.jee.FacesConverter$JAXB.readFacesConverter) FacesConverter$JAXB.writeFacesConverter(org.apache.openejb.jee.FacesConverter$JAXB.writeFacesConverter) QName(javax.xml.namespace.QName) FacesAbsoluteOrdering$JAXB.readFacesAbsoluteOrdering(org.apache.openejb.jee.FacesAbsoluteOrdering$JAXB.readFacesAbsoluteOrdering) FacesAbsoluteOrdering$JAXB.writeFacesAbsoluteOrdering(org.apache.openejb.jee.FacesAbsoluteOrdering$JAXB.writeFacesAbsoluteOrdering) FacesExtension$JAXB.readFacesExtension(org.apache.openejb.jee.FacesExtension$JAXB.readFacesExtension) FacesExtension$JAXB.writeFacesExtension(org.apache.openejb.jee.FacesExtension$JAXB.writeFacesExtension) FacesComponent$JAXB.readFacesComponent(org.apache.openejb.jee.FacesComponent$JAXB.readFacesComponent) FacesComponent$JAXB.writeFacesComponent(org.apache.openejb.jee.FacesComponent$JAXB.writeFacesComponent) FacesOrdering$JAXB.writeFacesOrdering(org.apache.openejb.jee.FacesOrdering$JAXB.writeFacesOrdering) FacesOrdering$JAXB.readFacesOrdering(org.apache.openejb.jee.FacesOrdering$JAXB.readFacesOrdering) FacesFactory$JAXB.writeFacesFactory(org.apache.openejb.jee.FacesFactory$JAXB.writeFacesFactory) FacesFactory$JAXB.readFacesFactory(org.apache.openejb.jee.FacesFactory$JAXB.readFacesFactory) RuntimeContext(org.metatype.sxc.jaxb.RuntimeContext) FacesBehavior$JAXB.writeFacesBehavior(org.apache.openejb.jee.FacesBehavior$JAXB.writeFacesBehavior) FacesBehavior$JAXB.readFacesBehavior(org.apache.openejb.jee.FacesBehavior$JAXB.readFacesBehavior)

Aggregations

QName (javax.xml.namespace.QName)190 RuntimeContext (org.metatype.sxc.jaxb.RuntimeContext)190 Attribute (org.metatype.sxc.util.Attribute)190 XoXMLStreamReader (org.metatype.sxc.util.XoXMLStreamReader)182 CollapsedStringAdapter (javax.xml.bind.annotation.adapters.CollapsedStringAdapter)116 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)69 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