Search in sources :

Example 41 with XoXMLStreamReader

use of org.metatype.sxc.util.XoXMLStreamReader 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 42 with XoXMLStreamReader

use of org.metatype.sxc.util.XoXMLStreamReader 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 43 with XoXMLStreamReader

use of org.metatype.sxc.util.XoXMLStreamReader 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 44 with XoXMLStreamReader

use of org.metatype.sxc.util.XoXMLStreamReader 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)

Example 45 with XoXMLStreamReader

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

the class FacesLocaleConfig$JAXB method _read.

public static final FacesLocaleConfig _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
    // Check for xsi:nil
    if (reader.isXsiNil()) {
        return null;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final FacesLocaleConfig facesLocaleConfig = new FacesLocaleConfig();
    context.beforeUnmarshal(facesLocaleConfig, LifecycleCallback.NONE);
    List<FacesSupportedLocale> supportedLocale = null;
    // Check xsi:type
    final QName xsiType = reader.getXsiType();
    if (xsiType != null) {
        if (("faces-config-locale-configType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
            return context.unexpectedXsiType(reader, FacesLocaleConfig.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, facesLocaleConfig);
            facesLocaleConfig.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 (("default-locale" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: defaultLocale
            final FacesDefaultLocale defaultLocale = readFacesDefaultLocale(elementReader, context);
            facesLocaleConfig.defaultLocale = defaultLocale;
        } else if (("supported-locale" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: supportedLocale
            final FacesSupportedLocale supportedLocaleItem = readFacesSupportedLocale(elementReader, context);
            if (supportedLocale == null) {
                supportedLocale = facesLocaleConfig.supportedLocale;
                if (supportedLocale != null) {
                    supportedLocale.clear();
                } else {
                    supportedLocale = new ArrayList<FacesSupportedLocale>();
                }
            }
            supportedLocale.add(supportedLocaleItem);
        } else {
            context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "default-locale"), new QName("http://java.sun.com/xml/ns/javaee", "supported-locale"));
        }
    }
    if (supportedLocale != null) {
        facesLocaleConfig.supportedLocale = supportedLocale;
    }
    context.afterUnmarshal(facesLocaleConfig, LifecycleCallback.NONE);
    return facesLocaleConfig;
}
Also used : FacesSupportedLocale$JAXB.writeFacesSupportedLocale(org.apache.openejb.jee.FacesSupportedLocale$JAXB.writeFacesSupportedLocale) FacesSupportedLocale$JAXB.readFacesSupportedLocale(org.apache.openejb.jee.FacesSupportedLocale$JAXB.readFacesSupportedLocale) FacesDefaultLocale$JAXB.writeFacesDefaultLocale(org.apache.openejb.jee.FacesDefaultLocale$JAXB.writeFacesDefaultLocale) FacesDefaultLocale$JAXB.readFacesDefaultLocale(org.apache.openejb.jee.FacesDefaultLocale$JAXB.readFacesDefaultLocale) Attribute(org.metatype.sxc.util.Attribute) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) 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