Search in sources :

Example 41 with Attribute

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

the class FacesFacet$JAXB method _read.

public static final FacesFacet _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
    // Check for xsi:nil
    if (reader.isXsiNil()) {
        return null;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final FacesFacet facesFacet = new FacesFacet();
    context.beforeUnmarshal(facesFacet, LifecycleCallback.NONE);
    ArrayList<Text> descriptions = null;
    ArrayList<Text> displayNames = null;
    LocalCollection<Icon> icon = null;
    List<FacesFacetExtension> facetExtension = null;
    // Check xsi:type
    final QName xsiType = reader.getXsiType();
    if (xsiType != null) {
        if (("faces-config-facetType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
            return context.unexpectedXsiType(reader, FacesFacet.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, facesFacet);
            facesFacet.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 = facesFacet.icon;
                if (icon != null) {
                    icon.clear();
                } else {
                    icon = new LocalCollection<Icon>();
                }
            }
            icon.add(iconItem);
        } else if (("facet-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: facetName
            final String facetNameRaw = elementReader.getElementAsString();
            final String facetName;
            try {
                facetName = Adapters.collapsedStringAdapterAdapter.unmarshal(facetNameRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            facesFacet.facetName = facetName;
        } else if (("facet-extension" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: facetExtension
            final FacesFacetExtension facetExtensionItem = readFacesFacetExtension(elementReader, context);
            if (facetExtension == null) {
                facetExtension = facesFacet.facetExtension;
                if (facetExtension != null) {
                    facetExtension.clear();
                } else {
                    facetExtension = new ArrayList<FacesFacetExtension>();
                }
            }
            facetExtension.add(facetExtensionItem);
        } 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", "facet-name"), new QName("http://java.sun.com/xml/ns/javaee", "facet-extension"));
        }
    }
    if (descriptions != null) {
        try {
            facesFacet.setDescriptions(descriptions.toArray(new Text[descriptions.size()]));
        } catch (final Exception e) {
            context.setterError(reader, FacesFacet.class, "setDescriptions", Text[].class, e);
        }
    }
    if (displayNames != null) {
        try {
            facesFacet.setDisplayNames(displayNames.toArray(new Text[displayNames.size()]));
        } catch (final Exception e) {
            context.setterError(reader, FacesFacet.class, "setDisplayNames", Text[].class, e);
        }
    }
    if (icon != null) {
        facesFacet.icon = icon;
    }
    if (facetExtension != null) {
        facesFacet.facetExtension = facetExtension;
    }
    context.afterUnmarshal(facesFacet, LifecycleCallback.NONE);
    return facesFacet;
}
Also used : FacesFacetExtension$JAXB.readFacesFacetExtension(org.apache.openejb.jee.FacesFacetExtension$JAXB.readFacesFacetExtension) FacesFacetExtension$JAXB.writeFacesFacetExtension(org.apache.openejb.jee.FacesFacetExtension$JAXB.writeFacesFacetExtension) 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)

Example 42 with Attribute

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

the class FacesFacetExtension$JAXB method _read.

public static final FacesFacetExtension _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
    // Check for xsi:nil
    if (reader.isXsiNil()) {
        return null;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final FacesFacetExtension facesFacetExtension = new FacesFacetExtension();
    context.beforeUnmarshal(facesFacetExtension, LifecycleCallback.NONE);
    List<Object> any = null;
    // Check xsi:type
    final QName xsiType = reader.getXsiType();
    if (xsiType != null) {
        if (("faces-config-facet-extensionType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
            return context.unexpectedXsiType(reader, FacesFacetExtension.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, facesFacetExtension);
            facesFacetExtension.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 = facesFacetExtension.any;
            if (any != null) {
                any.clear();
            } else {
                any = new ArrayList<Object>();
            }
        }
        any.add(context.readXmlAny(elementReader, Object.class, true));
    }
    if (any != null) {
        facesFacetExtension.any = any;
    }
    context.afterUnmarshal(facesFacetExtension, LifecycleCallback.NONE);
    return facesFacetExtension;
}
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 43 with Attribute

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

the class FacesFactory$JAXB method _read.

public static final FacesFactory _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
    // Check for xsi:nil
    if (reader.isXsiNil()) {
        return null;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final FacesFactory facesFactory = new FacesFactory();
    context.beforeUnmarshal(facesFactory, LifecycleCallback.NONE);
    List<String> applicationFactory = null;
    List<String> exceptionHandlerFactory = null;
    List<String> externalContextFactory = null;
    List<String> facesContextFactory = null;
    List<String> partialViewContextFactory = null;
    List<String> lifecycleFactory = null;
    List<String> viewDeclarationLanguageFactory = null;
    List<String> tagHandlerDelegateFactory = null;
    List<String> renderKitFactory = null;
    List<String> visitContextFactory = null;
    List<FacesFactoryExtension> factoryExtension = null;
    // Check xsi:type
    final QName xsiType = reader.getXsiType();
    if (xsiType != null) {
        if (("faces-config-factoryType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
            return context.unexpectedXsiType(reader, FacesFactory.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, facesFactory);
            facesFactory.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 (("application-factory" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: applicationFactory
            final String applicationFactoryItemRaw = elementReader.getElementAsString();
            final String applicationFactoryItem;
            try {
                applicationFactoryItem = Adapters.collapsedStringAdapterAdapter.unmarshal(applicationFactoryItemRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            if (applicationFactory == null) {
                applicationFactory = facesFactory.applicationFactory;
                if (applicationFactory != null) {
                    applicationFactory.clear();
                } else {
                    applicationFactory = new ArrayList<String>();
                }
            }
            applicationFactory.add(applicationFactoryItem);
        } else if (("exception-handler-factory" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: exceptionHandlerFactory
            final String exceptionHandlerFactoryItemRaw = elementReader.getElementAsString();
            final String exceptionHandlerFactoryItem;
            try {
                exceptionHandlerFactoryItem = Adapters.collapsedStringAdapterAdapter.unmarshal(exceptionHandlerFactoryItemRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            if (exceptionHandlerFactory == null) {
                exceptionHandlerFactory = facesFactory.exceptionHandlerFactory;
                if (exceptionHandlerFactory != null) {
                    exceptionHandlerFactory.clear();
                } else {
                    exceptionHandlerFactory = new ArrayList<String>();
                }
            }
            exceptionHandlerFactory.add(exceptionHandlerFactoryItem);
        } else if (("external-context-factory" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: externalContextFactory
            final String externalContextFactoryItemRaw = elementReader.getElementAsString();
            final String externalContextFactoryItem;
            try {
                externalContextFactoryItem = Adapters.collapsedStringAdapterAdapter.unmarshal(externalContextFactoryItemRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            if (externalContextFactory == null) {
                externalContextFactory = facesFactory.externalContextFactory;
                if (externalContextFactory != null) {
                    externalContextFactory.clear();
                } else {
                    externalContextFactory = new ArrayList<String>();
                }
            }
            externalContextFactory.add(externalContextFactoryItem);
        } else if (("faces-context-factory" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: facesContextFactory
            final String facesContextFactoryItemRaw = elementReader.getElementAsString();
            final String facesContextFactoryItem;
            try {
                facesContextFactoryItem = Adapters.collapsedStringAdapterAdapter.unmarshal(facesContextFactoryItemRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            if (facesContextFactory == null) {
                facesContextFactory = facesFactory.facesContextFactory;
                if (facesContextFactory != null) {
                    facesContextFactory.clear();
                } else {
                    facesContextFactory = new ArrayList<String>();
                }
            }
            facesContextFactory.add(facesContextFactoryItem);
        } else if (("partial-view-context-factory" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: partialViewContextFactory
            final String partialViewContextFactoryItemRaw = elementReader.getElementAsString();
            final String partialViewContextFactoryItem;
            try {
                partialViewContextFactoryItem = Adapters.collapsedStringAdapterAdapter.unmarshal(partialViewContextFactoryItemRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            if (partialViewContextFactory == null) {
                partialViewContextFactory = facesFactory.partialViewContextFactory;
                if (partialViewContextFactory != null) {
                    partialViewContextFactory.clear();
                } else {
                    partialViewContextFactory = new ArrayList<String>();
                }
            }
            partialViewContextFactory.add(partialViewContextFactoryItem);
        } else if (("lifecycle-factory" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: lifecycleFactory
            final String lifecycleFactoryItemRaw = elementReader.getElementAsString();
            final String lifecycleFactoryItem;
            try {
                lifecycleFactoryItem = Adapters.collapsedStringAdapterAdapter.unmarshal(lifecycleFactoryItemRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            if (lifecycleFactory == null) {
                lifecycleFactory = facesFactory.lifecycleFactory;
                if (lifecycleFactory != null) {
                    lifecycleFactory.clear();
                } else {
                    lifecycleFactory = new ArrayList<String>();
                }
            }
            lifecycleFactory.add(lifecycleFactoryItem);
        } else if (("view-declaration-language-factory" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: viewDeclarationLanguageFactory
            final String viewDeclarationLanguageFactoryItemRaw = elementReader.getElementAsString();
            final String viewDeclarationLanguageFactoryItem;
            try {
                viewDeclarationLanguageFactoryItem = Adapters.collapsedStringAdapterAdapter.unmarshal(viewDeclarationLanguageFactoryItemRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            if (viewDeclarationLanguageFactory == null) {
                viewDeclarationLanguageFactory = facesFactory.viewDeclarationLanguageFactory;
                if (viewDeclarationLanguageFactory != null) {
                    viewDeclarationLanguageFactory.clear();
                } else {
                    viewDeclarationLanguageFactory = new ArrayList<String>();
                }
            }
            viewDeclarationLanguageFactory.add(viewDeclarationLanguageFactoryItem);
        } else if (("tag-handler-delegate-factory" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: tagHandlerDelegateFactory
            final String tagHandlerDelegateFactoryItemRaw = elementReader.getElementAsString();
            final String tagHandlerDelegateFactoryItem;
            try {
                tagHandlerDelegateFactoryItem = Adapters.collapsedStringAdapterAdapter.unmarshal(tagHandlerDelegateFactoryItemRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            if (tagHandlerDelegateFactory == null) {
                tagHandlerDelegateFactory = facesFactory.tagHandlerDelegateFactory;
                if (tagHandlerDelegateFactory != null) {
                    tagHandlerDelegateFactory.clear();
                } else {
                    tagHandlerDelegateFactory = new ArrayList<String>();
                }
            }
            tagHandlerDelegateFactory.add(tagHandlerDelegateFactoryItem);
        } else if (("render-kit-factory" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: renderKitFactory
            final String renderKitFactoryItemRaw = elementReader.getElementAsString();
            final String renderKitFactoryItem;
            try {
                renderKitFactoryItem = Adapters.collapsedStringAdapterAdapter.unmarshal(renderKitFactoryItemRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            if (renderKitFactory == null) {
                renderKitFactory = facesFactory.renderKitFactory;
                if (renderKitFactory != null) {
                    renderKitFactory.clear();
                } else {
                    renderKitFactory = new ArrayList<String>();
                }
            }
            renderKitFactory.add(renderKitFactoryItem);
        } else if (("visit-context-factory" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: visitContextFactory
            final String visitContextFactoryItemRaw = elementReader.getElementAsString();
            final String visitContextFactoryItem;
            try {
                visitContextFactoryItem = Adapters.collapsedStringAdapterAdapter.unmarshal(visitContextFactoryItemRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            if (visitContextFactory == null) {
                visitContextFactory = facesFactory.visitContextFactory;
                if (visitContextFactory != null) {
                    visitContextFactory.clear();
                } else {
                    visitContextFactory = new ArrayList<String>();
                }
            }
            visitContextFactory.add(visitContextFactoryItem);
        } else if (("factory-extension" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: factoryExtension
            final FacesFactoryExtension factoryExtensionItem = readFacesFactoryExtension(elementReader, context);
            if (factoryExtension == null) {
                factoryExtension = facesFactory.factoryExtension;
                if (factoryExtension != null) {
                    factoryExtension.clear();
                } else {
                    factoryExtension = new ArrayList<FacesFactoryExtension>();
                }
            }
            factoryExtension.add(factoryExtensionItem);
        } 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", "application-factory"), new QName("http://java.sun.com/xml/ns/javaee", "exception-handler-factory"), new QName("http://java.sun.com/xml/ns/javaee", "external-context-factory"), new QName("http://java.sun.com/xml/ns/javaee", "faces-context-factory"), new QName("http://java.sun.com/xml/ns/javaee", "partial-view-context-factory"), new QName("http://java.sun.com/xml/ns/javaee", "lifecycle-factory"), new QName("http://java.sun.com/xml/ns/javaee", "view-declaration-language-factory"), new QName("http://java.sun.com/xml/ns/javaee", "tag-handler-delegate-factory"), new QName("http://java.sun.com/xml/ns/javaee", "render-kit-factory"), new QName("http://java.sun.com/xml/ns/javaee", "visit-context-factory"), new QName("http://java.sun.com/xml/ns/javaee", "factory-extension"));
        }
    }
    if (applicationFactory != null) {
        facesFactory.applicationFactory = applicationFactory;
    }
    if (exceptionHandlerFactory != null) {
        facesFactory.exceptionHandlerFactory = exceptionHandlerFactory;
    }
    if (externalContextFactory != null) {
        facesFactory.externalContextFactory = externalContextFactory;
    }
    if (facesContextFactory != null) {
        facesFactory.facesContextFactory = facesContextFactory;
    }
    if (partialViewContextFactory != null) {
        facesFactory.partialViewContextFactory = partialViewContextFactory;
    }
    if (lifecycleFactory != null) {
        facesFactory.lifecycleFactory = lifecycleFactory;
    }
    if (viewDeclarationLanguageFactory != null) {
        facesFactory.viewDeclarationLanguageFactory = viewDeclarationLanguageFactory;
    }
    if (tagHandlerDelegateFactory != null) {
        facesFactory.tagHandlerDelegateFactory = tagHandlerDelegateFactory;
    }
    if (renderKitFactory != null) {
        facesFactory.renderKitFactory = renderKitFactory;
    }
    if (visitContextFactory != null) {
        facesFactory.visitContextFactory = visitContextFactory;
    }
    if (factoryExtension != null) {
        facesFactory.factoryExtension = factoryExtension;
    }
    context.afterUnmarshal(facesFactory, LifecycleCallback.NONE);
    return facesFactory;
}
Also used : CollapsedStringAdapter(javax.xml.bind.annotation.adapters.CollapsedStringAdapter) Attribute(org.metatype.sxc.util.Attribute) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) FacesFactoryExtension$JAXB.writeFacesFactoryExtension(org.apache.openejb.jee.FacesFactoryExtension$JAXB.writeFacesFactoryExtension) FacesFactoryExtension$JAXB.readFacesFactoryExtension(org.apache.openejb.jee.FacesFactoryExtension$JAXB.readFacesFactoryExtension) RuntimeContext(org.metatype.sxc.jaxb.RuntimeContext) XoXMLStreamReader(org.metatype.sxc.util.XoXMLStreamReader)

Example 44 with Attribute

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

the class FacesLifecycle$JAXB method _read.

public static final FacesLifecycle _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
    // Check for xsi:nil
    if (reader.isXsiNil()) {
        return null;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final FacesLifecycle facesLifecycle = new FacesLifecycle();
    context.beforeUnmarshal(facesLifecycle, LifecycleCallback.NONE);
    List<String> phaseListener = null;
    List<FacesLifecycleExtension> lifecycleExtension = null;
    // Check xsi:type
    final QName xsiType = reader.getXsiType();
    if (xsiType != null) {
        if (("faces-config-lifecycleType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
            return context.unexpectedXsiType(reader, FacesLifecycle.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, facesLifecycle);
            facesLifecycle.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 (("phase-listener" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: phaseListener
            final String phaseListenerItemRaw = elementReader.getElementAsString();
            final String phaseListenerItem;
            try {
                phaseListenerItem = Adapters.collapsedStringAdapterAdapter.unmarshal(phaseListenerItemRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            if (phaseListener == null) {
                phaseListener = facesLifecycle.phaseListener;
                if (phaseListener != null) {
                    phaseListener.clear();
                } else {
                    phaseListener = new ArrayList<String>();
                }
            }
            phaseListener.add(phaseListenerItem);
        } else if (("lifecycle-extension" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: lifecycleExtension
            final FacesLifecycleExtension lifecycleExtensionItem = readFacesLifecycleExtension(elementReader, context);
            if (lifecycleExtension == null) {
                lifecycleExtension = facesLifecycle.lifecycleExtension;
                if (lifecycleExtension != null) {
                    lifecycleExtension.clear();
                } else {
                    lifecycleExtension = new ArrayList<FacesLifecycleExtension>();
                }
            }
            lifecycleExtension.add(lifecycleExtensionItem);
        } 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", "phase-listener"), new QName("http://java.sun.com/xml/ns/javaee", "lifecycle-extension"));
        }
    }
    if (phaseListener != null) {
        facesLifecycle.phaseListener = phaseListener;
    }
    if (lifecycleExtension != null) {
        facesLifecycle.lifecycleExtension = lifecycleExtension;
    }
    context.afterUnmarshal(facesLifecycle, LifecycleCallback.NONE);
    return facesLifecycle;
}
Also used : CollapsedStringAdapter(javax.xml.bind.annotation.adapters.CollapsedStringAdapter) Attribute(org.metatype.sxc.util.Attribute) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) FacesLifecycleExtension$JAXB.writeFacesLifecycleExtension(org.apache.openejb.jee.FacesLifecycleExtension$JAXB.writeFacesLifecycleExtension) FacesLifecycleExtension$JAXB.readFacesLifecycleExtension(org.apache.openejb.jee.FacesLifecycleExtension$JAXB.readFacesLifecycleExtension) RuntimeContext(org.metatype.sxc.jaxb.RuntimeContext) XoXMLStreamReader(org.metatype.sxc.util.XoXMLStreamReader)

Example 45 with Attribute

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

the class FacesListEntries$JAXB method _read.

public static final FacesListEntries _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
    // Check for xsi:nil
    if (reader.isXsiNil()) {
        return null;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final FacesListEntries facesListEntries = new FacesListEntries();
    context.beforeUnmarshal(facesListEntries, LifecycleCallback.NONE);
    List<Object> nullValueOrValue = null;
    // Check xsi:type
    final QName xsiType = reader.getXsiType();
    if (xsiType != null) {
        if (("faces-config-list-entriesType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
            return context.unexpectedXsiType(reader, FacesListEntries.class);
        }
    }
    // Read attributes
    for (final Attribute attribute : reader.getAttributes()) {
        if (("id" == attribute.getLocalName()) && (("" == attribute.getNamespace()) || (attribute.getNamespace() == null))) {
            // ATTRIBUTE: id
            final java.lang.String id = Adapters.collapsedStringAdapterAdapter.unmarshal(attribute.getValue());
            context.addXmlId(reader, id, facesListEntries);
            facesListEntries.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 (("value-class" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: valueClass
            final java.lang.String valueClassRaw = elementReader.getElementAsString();
            final java.lang.String valueClass;
            try {
                valueClass = Adapters.collapsedStringAdapterAdapter.unmarshal(valueClassRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, java.lang.String.class, java.lang.String.class, e);
                continue;
            }
            facesListEntries.valueClass = valueClass;
        } else if (("value" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: nullValueOrValue
            final java.lang.String nullValueOrValueItem = elementReader.getElementAsString();
            if (nullValueOrValue == null) {
                nullValueOrValue = facesListEntries.nullValueOrValue;
                if (nullValueOrValue != null) {
                    nullValueOrValue.clear();
                } else {
                    nullValueOrValue = new ArrayList<Object>();
                }
            }
            nullValueOrValue.add(nullValueOrValueItem);
        } else if (("null-value" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: nullValueOrValue
            final org.apache.openejb.jee.FacesNullValue nullValueOrValueItem1 = readFacesNullValue(elementReader, context);
            if (nullValueOrValue == null) {
                nullValueOrValue = facesListEntries.nullValueOrValue;
                if (nullValueOrValue != null) {
                    nullValueOrValue.clear();
                } else {
                    nullValueOrValue = new ArrayList<Object>();
                }
            }
            nullValueOrValue.add(nullValueOrValueItem1);
        } else {
            context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "value-class"), new QName("http://java.sun.com/xml/ns/javaee", "value"), new QName("http://java.sun.com/xml/ns/javaee", "null-value"));
        }
    }
    if (nullValueOrValue != null) {
        facesListEntries.nullValueOrValue = nullValueOrValue;
    }
    context.afterUnmarshal(facesListEntries, LifecycleCallback.NONE);
    return facesListEntries;
}
Also used : CollapsedStringAdapter(javax.xml.bind.annotation.adapters.CollapsedStringAdapter) Attribute(org.metatype.sxc.util.Attribute) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) JAXBObject(org.metatype.sxc.jaxb.JAXBObject) RuntimeContext(org.metatype.sxc.jaxb.RuntimeContext) XoXMLStreamReader(org.metatype.sxc.util.XoXMLStreamReader)

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