Search in sources :

Example 11 with Icon$JAXB.readIcon

use of org.apache.openejb.jee.Icon$JAXB.readIcon in project tomee by apache.

the class Servlet$JAXB method _write.

public static final void _write(final XoXMLStreamWriter writer, final Servlet servlet, RuntimeContext context) throws Exception {
    if (servlet == null) {
        writer.writeXsiNil();
        return;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final String prefix = writer.getUniquePrefix("http://java.sun.com/xml/ns/javaee");
    if (Servlet.class != servlet.getClass()) {
        context.unexpectedSubclass(writer, servlet, Servlet.class);
        return;
    }
    context.beforeMarshal(servlet, LifecycleCallback.NONE);
    // ATTRIBUTE: id
    final String idRaw = servlet.id;
    if (idRaw != null) {
        String id = null;
        try {
            id = Adapters.collapsedStringAdapterAdapter.marshal(idRaw);
        } catch (final Exception e) {
            context.xmlAdapterError(servlet, "id", CollapsedStringAdapter.class, String.class, String.class, e);
        }
        writer.writeAttribute("", "", "id", id);
    }
    // ELEMENT: descriptions
    Text[] descriptions = null;
    try {
        descriptions = servlet.getDescriptions();
    } catch (final Exception e) {
        context.getterError(servlet, "descriptions", Servlet.class, "getDescriptions", e);
    }
    if (descriptions != null) {
        for (final Text descriptionsItem : descriptions) {
            if (descriptionsItem != null) {
                writer.writeStartElement(prefix, "description", "http://java.sun.com/xml/ns/javaee");
                writeText(writer, descriptionsItem, context);
                writer.writeEndElement();
            } else {
                context.unexpectedNullValue(servlet, "descriptions");
            }
        }
    }
    // ELEMENT: displayNames
    Text[] displayNames = null;
    try {
        displayNames = servlet.getDisplayNames();
    } catch (final Exception e) {
        context.getterError(servlet, "displayNames", Servlet.class, "getDisplayNames", e);
    }
    if (displayNames != null) {
        for (final Text displayNamesItem : displayNames) {
            if (displayNamesItem != null) {
                writer.writeStartElement(prefix, "display-name", "http://java.sun.com/xml/ns/javaee");
                writeText(writer, displayNamesItem, context);
                writer.writeEndElement();
            } else {
                context.unexpectedNullValue(servlet, "displayNames");
            }
        }
    }
    // ELEMENT: icon
    final LocalCollection<Icon> icon = servlet.icon;
    if (icon != null) {
        for (final Icon iconItem : icon) {
            if (iconItem != null) {
                writer.writeStartElement(prefix, "icon", "http://java.sun.com/xml/ns/javaee");
                writeIcon(writer, iconItem, context);
                writer.writeEndElement();
            } else {
                context.unexpectedNullValue(servlet, "icon");
            }
        }
    }
    // ELEMENT: servletName
    final String servletNameRaw = servlet.servletName;
    String servletName = null;
    try {
        servletName = Adapters.collapsedStringAdapterAdapter.marshal(servletNameRaw);
    } catch (final Exception e) {
        context.xmlAdapterError(servlet, "servletName", CollapsedStringAdapter.class, String.class, String.class, e);
    }
    if (servletName != null) {
        writer.writeStartElement(prefix, "servlet-name", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(servletName);
        writer.writeEndElement();
    } else {
        context.unexpectedNullValue(servlet, "servletName");
    }
    // ELEMENT: servletClass
    final String servletClassRaw = servlet.servletClass;
    String servletClass = null;
    try {
        servletClass = Adapters.collapsedStringAdapterAdapter.marshal(servletClassRaw);
    } catch (final Exception e) {
        context.xmlAdapterError(servlet, "servletClass", CollapsedStringAdapter.class, String.class, String.class, e);
    }
    if (servletClass != null) {
        writer.writeStartElement(prefix, "servlet-class", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(servletClass);
        writer.writeEndElement();
    }
    // ELEMENT: jspFile
    final String jspFileRaw = servlet.jspFile;
    String jspFile = null;
    try {
        jspFile = Adapters.collapsedStringAdapterAdapter.marshal(jspFileRaw);
    } catch (final Exception e) {
        context.xmlAdapterError(servlet, "jspFile", CollapsedStringAdapter.class, String.class, String.class, e);
    }
    if (jspFile != null) {
        writer.writeStartElement(prefix, "jsp-file", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(jspFile);
        writer.writeEndElement();
    }
    // ELEMENT: initParam
    final List<ParamValue> initParam = servlet.initParam;
    if (initParam != null) {
        for (final ParamValue initParamItem : initParam) {
            if (initParamItem != null) {
                writer.writeStartElement(prefix, "init-param", "http://java.sun.com/xml/ns/javaee");
                writeParamValue(writer, initParamItem, context);
                writer.writeEndElement();
            }
        }
    }
    // ELEMENT: loadOnStartup
    final Integer loadOnStartupRaw = servlet.loadOnStartup;
    String loadOnStartup = null;
    try {
        loadOnStartup = Adapters.loadOnStartupAdapterAdapter.marshal(loadOnStartupRaw);
    } catch (final Exception e) {
        context.xmlAdapterError(servlet, "loadOnStartup", LoadOnStartupAdapter.class, Integer.class, Integer.class, e);
    }
    if (loadOnStartup != null) {
        writer.writeStartElement(prefix, "load-on-startup", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(loadOnStartup);
        writer.writeEndElement();
    }
    // ELEMENT: enabled
    final Boolean enabled = servlet.enabled;
    if (enabled != null) {
        writer.writeStartElement(prefix, "enabled", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(Boolean.toString(enabled));
        writer.writeEndElement();
    }
    // ELEMENT: asyncSupported
    final Boolean asyncSupported = servlet.asyncSupported;
    if (asyncSupported != null) {
        writer.writeStartElement(prefix, "async-supported", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(Boolean.toString(asyncSupported));
        writer.writeEndElement();
    }
    // ELEMENT: runAs
    final RunAs runAs = servlet.runAs;
    if (runAs != null) {
        writer.writeStartElement(prefix, "run-as", "http://java.sun.com/xml/ns/javaee");
        writeRunAs(writer, runAs, context);
        writer.writeEndElement();
    }
    // ELEMENT: securityRoleRef
    final List<SecurityRoleRef> securityRoleRef = servlet.securityRoleRef;
    if (securityRoleRef != null) {
        for (final SecurityRoleRef securityRoleRefItem : securityRoleRef) {
            if (securityRoleRefItem != null) {
                writer.writeStartElement(prefix, "security-role-ref", "http://java.sun.com/xml/ns/javaee");
                writeSecurityRoleRef(writer, securityRoleRefItem, context);
                writer.writeEndElement();
            }
        }
    }
    // ELEMENT: multipartConfig
    final MultipartConfig multipartConfig = servlet.multipartConfig;
    if (multipartConfig != null) {
        writer.writeStartElement(prefix, "multipart-config", "http://java.sun.com/xml/ns/javaee");
        writeMultipartConfig(writer, multipartConfig, context);
        writer.writeEndElement();
    }
    context.afterMarshal(servlet, LifecycleCallback.NONE);
}
Also used : CollapsedStringAdapter(javax.xml.bind.annotation.adapters.CollapsedStringAdapter) RunAs$JAXB.writeRunAs(org.apache.openejb.jee.RunAs$JAXB.writeRunAs) RunAs$JAXB.readRunAs(org.apache.openejb.jee.RunAs$JAXB.readRunAs) ParamValue$JAXB.readParamValue(org.apache.openejb.jee.ParamValue$JAXB.readParamValue) ParamValue$JAXB.writeParamValue(org.apache.openejb.jee.ParamValue$JAXB.writeParamValue) Text$JAXB.readText(org.apache.openejb.jee.Text$JAXB.readText) Text$JAXB.writeText(org.apache.openejb.jee.Text$JAXB.writeText) SecurityRoleRef$JAXB.writeSecurityRoleRef(org.apache.openejb.jee.SecurityRoleRef$JAXB.writeSecurityRoleRef) SecurityRoleRef$JAXB.readSecurityRoleRef(org.apache.openejb.jee.SecurityRoleRef$JAXB.readSecurityRoleRef) MultipartConfig$JAXB.readMultipartConfig(org.apache.openejb.jee.MultipartConfig$JAXB.readMultipartConfig) MultipartConfig$JAXB.writeMultipartConfig(org.apache.openejb.jee.MultipartConfig$JAXB.writeMultipartConfig) 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)

Example 12 with Icon$JAXB.readIcon

use of org.apache.openejb.jee.Icon$JAXB.readIcon in project tomee by apache.

the class FacesManagedProperty$JAXB method _read.

public static final FacesManagedProperty _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
    // Check for xsi:nil
    if (reader.isXsiNil()) {
        return null;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final FacesManagedProperty facesManagedProperty = new FacesManagedProperty();
    context.beforeUnmarshal(facesManagedProperty, LifecycleCallback.NONE);
    ArrayList<Text> descriptions = null;
    ArrayList<Text> displayNames = null;
    LocalCollection<Icon> icon = null;
    // Check xsi:type
    final QName xsiType = reader.getXsiType();
    if (xsiType != null) {
        if (("faces-config-managed-propertyType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
            return context.unexpectedXsiType(reader, FacesManagedProperty.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, facesManagedProperty);
            facesManagedProperty.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 = facesManagedProperty.icon;
                if (icon != null) {
                    icon.clear();
                } else {
                    icon = new LocalCollection<Icon>();
                }
            }
            icon.add(iconItem);
        } else if (("property-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: propertyName
            final String propertyNameRaw = elementReader.getElementAsString();
            final String propertyName;
            try {
                propertyName = Adapters.collapsedStringAdapterAdapter.unmarshal(propertyNameRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            facesManagedProperty.propertyName = propertyName;
        } else if (("property-class" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: propertyClass
            final String propertyClassRaw = elementReader.getElementAsString();
            final String propertyClass;
            try {
                propertyClass = Adapters.collapsedStringAdapterAdapter.unmarshal(propertyClassRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            facesManagedProperty.propertyClass = propertyClass;
        } else if (("map-entries" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: mapEntries
            final FacesMapEntries mapEntries = readFacesMapEntries(elementReader, context);
            facesManagedProperty.mapEntries = mapEntries;
        } else if (("null-value" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: nullValue
            final FacesNullValue nullValue = readFacesNullValue(elementReader, context);
            facesManagedProperty.nullValue = nullValue;
        } else if (("value" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: value
            final String valueRaw = elementReader.getElementAsString();
            final String value;
            try {
                value = Adapters.collapsedStringAdapterAdapter.unmarshal(valueRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            facesManagedProperty.value = value;
        } else if (("list-entries" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: listEntries
            final FacesListEntries listEntries = readFacesListEntries(elementReader, context);
            facesManagedProperty.listEntries = listEntries;
        } 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", "property-name"), new QName("http://java.sun.com/xml/ns/javaee", "property-class"), new QName("http://java.sun.com/xml/ns/javaee", "map-entries"), new QName("http://java.sun.com/xml/ns/javaee", "null-value"), new QName("http://java.sun.com/xml/ns/javaee", "value"), new QName("http://java.sun.com/xml/ns/javaee", "list-entries"));
        }
    }
    if (descriptions != null) {
        try {
            facesManagedProperty.setDescriptions(descriptions.toArray(new Text[descriptions.size()]));
        } catch (final Exception e) {
            context.setterError(reader, FacesManagedProperty.class, "setDescriptions", Text[].class, e);
        }
    }
    if (displayNames != null) {
        try {
            facesManagedProperty.setDisplayNames(displayNames.toArray(new Text[displayNames.size()]));
        } catch (final Exception e) {
            context.setterError(reader, FacesManagedProperty.class, "setDisplayNames", Text[].class, e);
        }
    }
    if (icon != null) {
        facesManagedProperty.icon = icon;
    }
    context.afterUnmarshal(facesManagedProperty, LifecycleCallback.NONE);
    return facesManagedProperty;
}
Also used : FacesMapEntries$JAXB.readFacesMapEntries(org.apache.openejb.jee.FacesMapEntries$JAXB.readFacesMapEntries) FacesMapEntries$JAXB.writeFacesMapEntries(org.apache.openejb.jee.FacesMapEntries$JAXB.writeFacesMapEntries) CollapsedStringAdapter(javax.xml.bind.annotation.adapters.CollapsedStringAdapter) Attribute(org.metatype.sxc.util.Attribute) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) Text$JAXB.readText(org.apache.openejb.jee.Text$JAXB.readText) Text$JAXB.writeText(org.apache.openejb.jee.Text$JAXB.writeText) FacesListEntries$JAXB.writeFacesListEntries(org.apache.openejb.jee.FacesListEntries$JAXB.writeFacesListEntries) FacesListEntries$JAXB.readFacesListEntries(org.apache.openejb.jee.FacesListEntries$JAXB.readFacesListEntries) Icon$JAXB.readIcon(org.apache.openejb.jee.Icon$JAXB.readIcon) Icon$JAXB.writeIcon(org.apache.openejb.jee.Icon$JAXB.writeIcon) FacesNullValue$JAXB.writeFacesNullValue(org.apache.openejb.jee.FacesNullValue$JAXB.writeFacesNullValue) FacesNullValue$JAXB.readFacesNullValue(org.apache.openejb.jee.FacesNullValue$JAXB.readFacesNullValue) RuntimeContext(org.metatype.sxc.jaxb.RuntimeContext) XoXMLStreamReader(org.metatype.sxc.util.XoXMLStreamReader)

Example 13 with Icon$JAXB.readIcon

use of org.apache.openejb.jee.Icon$JAXB.readIcon in project tomee by apache.

the class FacesNavigationCase$JAXB method _read.

public static final FacesNavigationCase _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
    // Check for xsi:nil
    if (reader.isXsiNil()) {
        return null;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final FacesNavigationCase facesNavigationCase = new FacesNavigationCase();
    context.beforeUnmarshal(facesNavigationCase, LifecycleCallback.NONE);
    ArrayList<Text> descriptions = null;
    ArrayList<Text> displayNames = null;
    LocalCollection<Icon> icon = null;
    // Check xsi:type
    final QName xsiType = reader.getXsiType();
    if (xsiType != null) {
        if (("faces-config-navigation-caseType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
            return context.unexpectedXsiType(reader, FacesNavigationCase.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, facesNavigationCase);
            facesNavigationCase.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 = facesNavigationCase.icon;
                if (icon != null) {
                    icon.clear();
                } else {
                    icon = new LocalCollection<Icon>();
                }
            }
            icon.add(iconItem);
        } else if (("from-action" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: fromAction
            final FacesFromAction fromAction = readFacesFromAction(elementReader, context);
            facesNavigationCase.fromAction = fromAction;
        } else if (("from-outcome" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: fromOutcome
            final String fromOutcomeRaw = elementReader.getElementAsString();
            final String fromOutcome;
            try {
                fromOutcome = Adapters.collapsedStringAdapterAdapter.unmarshal(fromOutcomeRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            facesNavigationCase.fromOutcome = fromOutcome;
        } else if (("if" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: _if
            final String _ifRaw = elementReader.getElementAsString();
            final String _if;
            try {
                _if = Adapters.collapsedStringAdapterAdapter.unmarshal(_ifRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            facesNavigationCase._if = _if;
        } else if (("to-view-id" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: toViewId
            final String toViewIdRaw = elementReader.getElementAsString();
            final String toViewId;
            try {
                toViewId = Adapters.collapsedStringAdapterAdapter.unmarshal(toViewIdRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            facesNavigationCase.toViewId = toViewId;
        } else if (("redirect" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: redirect
            final FacesRedirect redirect = readFacesRedirect(elementReader, context);
            facesNavigationCase.redirect = redirect;
        } 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", "from-action"), new QName("http://java.sun.com/xml/ns/javaee", "from-outcome"), new QName("http://java.sun.com/xml/ns/javaee", "if"), new QName("http://java.sun.com/xml/ns/javaee", "to-view-id"), new QName("http://java.sun.com/xml/ns/javaee", "redirect"));
        }
    }
    if (descriptions != null) {
        try {
            facesNavigationCase.setDescriptions(descriptions.toArray(new Text[descriptions.size()]));
        } catch (final Exception e) {
            context.setterError(reader, FacesNavigationCase.class, "setDescriptions", Text[].class, e);
        }
    }
    if (displayNames != null) {
        try {
            facesNavigationCase.setDisplayNames(displayNames.toArray(new Text[displayNames.size()]));
        } catch (final Exception e) {
            context.setterError(reader, FacesNavigationCase.class, "setDisplayNames", Text[].class, e);
        }
    }
    if (icon != null) {
        facesNavigationCase.icon = icon;
    }
    context.afterUnmarshal(facesNavigationCase, LifecycleCallback.NONE);
    return facesNavigationCase;
}
Also used : FacesFromAction$JAXB.readFacesFromAction(org.apache.openejb.jee.FacesFromAction$JAXB.readFacesFromAction) FacesFromAction$JAXB.writeFacesFromAction(org.apache.openejb.jee.FacesFromAction$JAXB.writeFacesFromAction) CollapsedStringAdapter(javax.xml.bind.annotation.adapters.CollapsedStringAdapter) Attribute(org.metatype.sxc.util.Attribute) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) Text$JAXB.readText(org.apache.openejb.jee.Text$JAXB.readText) Text$JAXB.writeText(org.apache.openejb.jee.Text$JAXB.writeText) FacesRedirect$JAXB.writeFacesRedirect(org.apache.openejb.jee.FacesRedirect$JAXB.writeFacesRedirect) FacesRedirect$JAXB.readFacesRedirect(org.apache.openejb.jee.FacesRedirect$JAXB.readFacesRedirect) 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 14 with Icon$JAXB.readIcon

use of org.apache.openejb.jee.Icon$JAXB.readIcon in project tomee by apache.

the class FacesProperty$JAXB method _write.

public static final void _write(final XoXMLStreamWriter writer, final FacesProperty facesProperty, RuntimeContext context) throws Exception {
    if (facesProperty == null) {
        writer.writeXsiNil();
        return;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final String prefix = writer.getUniquePrefix("http://java.sun.com/xml/ns/javaee");
    if (FacesProperty.class != facesProperty.getClass()) {
        context.unexpectedSubclass(writer, facesProperty, FacesProperty.class);
        return;
    }
    context.beforeMarshal(facesProperty, LifecycleCallback.NONE);
    // ATTRIBUTE: id
    final String idRaw = facesProperty.id;
    if (idRaw != null) {
        String id = null;
        try {
            id = Adapters.collapsedStringAdapterAdapter.marshal(idRaw);
        } catch (final Exception e) {
            context.xmlAdapterError(facesProperty, "id", CollapsedStringAdapter.class, String.class, String.class, e);
        }
        writer.writeAttribute("", "", "id", id);
    }
    // ELEMENT: descriptions
    Text[] descriptions = null;
    try {
        descriptions = facesProperty.getDescriptions();
    } catch (final Exception e) {
        context.getterError(facesProperty, "descriptions", FacesProperty.class, "getDescriptions", e);
    }
    if (descriptions != null) {
        for (final Text descriptionsItem : descriptions) {
            if (descriptionsItem != null) {
                writer.writeStartElement(prefix, "description", "http://java.sun.com/xml/ns/javaee");
                writeText(writer, descriptionsItem, context);
                writer.writeEndElement();
            } else {
                context.unexpectedNullValue(facesProperty, "descriptions");
            }
        }
    }
    // ELEMENT: displayNames
    Text[] displayNames = null;
    try {
        displayNames = facesProperty.getDisplayNames();
    } catch (final Exception e) {
        context.getterError(facesProperty, "displayNames", FacesProperty.class, "getDisplayNames", e);
    }
    if (displayNames != null) {
        for (final Text displayNamesItem : displayNames) {
            if (displayNamesItem != null) {
                writer.writeStartElement(prefix, "display-name", "http://java.sun.com/xml/ns/javaee");
                writeText(writer, displayNamesItem, context);
                writer.writeEndElement();
            } else {
                context.unexpectedNullValue(facesProperty, "displayNames");
            }
        }
    }
    // ELEMENT: icon
    final LocalCollection<Icon> icon = facesProperty.icon;
    if (icon != null) {
        for (final Icon iconItem : icon) {
            if (iconItem != null) {
                writer.writeStartElement(prefix, "icon", "http://java.sun.com/xml/ns/javaee");
                writeIcon(writer, iconItem, context);
                writer.writeEndElement();
            } else {
                context.unexpectedNullValue(facesProperty, "icon");
            }
        }
    }
    // ELEMENT: propertyName
    final String propertyNameRaw = facesProperty.propertyName;
    String propertyName = null;
    try {
        propertyName = Adapters.collapsedStringAdapterAdapter.marshal(propertyNameRaw);
    } catch (final Exception e) {
        context.xmlAdapterError(facesProperty, "propertyName", CollapsedStringAdapter.class, String.class, String.class, e);
    }
    if (propertyName != null) {
        writer.writeStartElement(prefix, "property-name", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(propertyName);
        writer.writeEndElement();
    } else {
        context.unexpectedNullValue(facesProperty, "propertyName");
    }
    // ELEMENT: propertyClass
    final String propertyClassRaw = facesProperty.propertyClass;
    String propertyClass = null;
    try {
        propertyClass = Adapters.collapsedStringAdapterAdapter.marshal(propertyClassRaw);
    } catch (final Exception e) {
        context.xmlAdapterError(facesProperty, "propertyClass", CollapsedStringAdapter.class, String.class, String.class, e);
    }
    if (propertyClass != null) {
        writer.writeStartElement(prefix, "property-class", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(propertyClass);
        writer.writeEndElement();
    } else {
        context.unexpectedNullValue(facesProperty, "propertyClass");
    }
    // ELEMENT: defaultValue
    final String defaultValueRaw = facesProperty.defaultValue;
    String defaultValue = null;
    try {
        defaultValue = Adapters.collapsedStringAdapterAdapter.marshal(defaultValueRaw);
    } catch (final Exception e) {
        context.xmlAdapterError(facesProperty, "defaultValue", CollapsedStringAdapter.class, String.class, String.class, e);
    }
    if (defaultValue != null) {
        writer.writeStartElement(prefix, "default-value", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(defaultValue);
        writer.writeEndElement();
    }
    // ELEMENT: suggestedValue
    final String suggestedValueRaw = facesProperty.suggestedValue;
    String suggestedValue = null;
    try {
        suggestedValue = Adapters.collapsedStringAdapterAdapter.marshal(suggestedValueRaw);
    } catch (final Exception e) {
        context.xmlAdapterError(facesProperty, "suggestedValue", CollapsedStringAdapter.class, String.class, String.class, e);
    }
    if (suggestedValue != null) {
        writer.writeStartElement(prefix, "suggested-value", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(suggestedValue);
        writer.writeEndElement();
    }
    // ELEMENT: propertyExtension
    final List<FacesPropertyExtension> propertyExtension = facesProperty.propertyExtension;
    if (propertyExtension != null) {
        for (final FacesPropertyExtension propertyExtensionItem : propertyExtension) {
            if (propertyExtensionItem != null) {
                writer.writeStartElement(prefix, "property-extension", "http://java.sun.com/xml/ns/javaee");
                writeFacesPropertyExtension(writer, propertyExtensionItem, context);
                writer.writeEndElement();
            }
        }
    }
    context.afterMarshal(facesProperty, LifecycleCallback.NONE);
}
Also used : FacesPropertyExtension$JAXB.writeFacesPropertyExtension(org.apache.openejb.jee.FacesPropertyExtension$JAXB.writeFacesPropertyExtension) FacesPropertyExtension$JAXB.readFacesPropertyExtension(org.apache.openejb.jee.FacesPropertyExtension$JAXB.readFacesPropertyExtension) CollapsedStringAdapter(javax.xml.bind.annotation.adapters.CollapsedStringAdapter) 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)

Example 15 with Icon$JAXB.readIcon

use of org.apache.openejb.jee.Icon$JAXB.readIcon in project tomee by apache.

the class FacesValidator$JAXB method _read.

public static final FacesValidator _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
    // Check for xsi:nil
    if (reader.isXsiNil()) {
        return null;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final FacesValidator facesValidator = new FacesValidator();
    context.beforeUnmarshal(facesValidator, LifecycleCallback.NONE);
    ArrayList<Text> descriptions = null;
    ArrayList<Text> displayNames = null;
    LocalCollection<Icon> icon = null;
    List<FacesAttribute> attribute1 = null;
    List<FacesProperty> property = null;
    List<FacesValidatorExtension> validatorExtension = null;
    // Check xsi:type
    final QName xsiType = reader.getXsiType();
    if (xsiType != null) {
        if (("faces-config-validatorType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
            return context.unexpectedXsiType(reader, FacesValidator.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, facesValidator);
            facesValidator.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 = facesValidator.icon;
                if (icon != null) {
                    icon.clear();
                } else {
                    icon = new LocalCollection<Icon>();
                }
            }
            icon.add(iconItem);
        } else if (("validator-id" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: validatorId
            final String validatorIdRaw = elementReader.getElementAsString();
            final String validatorId;
            try {
                validatorId = Adapters.collapsedStringAdapterAdapter.unmarshal(validatorIdRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            facesValidator.validatorId = validatorId;
        } else if (("validator-class" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: validatorClass
            final String validatorClassRaw = elementReader.getElementAsString();
            final String validatorClass;
            try {
                validatorClass = Adapters.collapsedStringAdapterAdapter.unmarshal(validatorClassRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            facesValidator.validatorClass = validatorClass;
        } 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 = facesValidator.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 = facesValidator.property;
                if (property != null) {
                    property.clear();
                } else {
                    property = new ArrayList<FacesProperty>();
                }
            }
            property.add(propertyItem);
        } else if (("validator-extension" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: validatorExtension
            final FacesValidatorExtension validatorExtensionItem = readFacesValidatorExtension(elementReader, context);
            if (validatorExtension == null) {
                validatorExtension = facesValidator.validatorExtension;
                if (validatorExtension != null) {
                    validatorExtension.clear();
                } else {
                    validatorExtension = new ArrayList<FacesValidatorExtension>();
                }
            }
            validatorExtension.add(validatorExtensionItem);
        } 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", "validator-id"), new QName("http://java.sun.com/xml/ns/javaee", "validator-class"), new QName("http://java.sun.com/xml/ns/javaee", "attribute"), new QName("http://java.sun.com/xml/ns/javaee", "property"), new QName("http://java.sun.com/xml/ns/javaee", "validator-extension"));
        }
    }
    if (descriptions != null) {
        try {
            facesValidator.setDescriptions(descriptions.toArray(new Text[descriptions.size()]));
        } catch (final Exception e) {
            context.setterError(reader, FacesValidator.class, "setDescriptions", Text[].class, e);
        }
    }
    if (displayNames != null) {
        try {
            facesValidator.setDisplayNames(displayNames.toArray(new Text[displayNames.size()]));
        } catch (final Exception e) {
            context.setterError(reader, FacesValidator.class, "setDisplayNames", Text[].class, e);
        }
    }
    if (icon != null) {
        facesValidator.icon = icon;
    }
    if (attribute1 != null) {
        facesValidator.attribute = attribute1;
    }
    if (property != null) {
        facesValidator.property = property;
    }
    if (validatorExtension != null) {
        facesValidator.validatorExtension = validatorExtension;
    }
    context.afterUnmarshal(facesValidator, LifecycleCallback.NONE);
    return facesValidator;
}
Also used : FacesValidatorExtension$JAXB.readFacesValidatorExtension(org.apache.openejb.jee.FacesValidatorExtension$JAXB.readFacesValidatorExtension) FacesValidatorExtension$JAXB.writeFacesValidatorExtension(org.apache.openejb.jee.FacesValidatorExtension$JAXB.writeFacesValidatorExtension) CollapsedStringAdapter(javax.xml.bind.annotation.adapters.CollapsedStringAdapter) FacesAttribute$JAXB.readFacesAttribute(org.apache.openejb.jee.FacesAttribute$JAXB.readFacesAttribute) FacesAttribute$JAXB.writeFacesAttribute(org.apache.openejb.jee.FacesAttribute$JAXB.writeFacesAttribute) Attribute(org.metatype.sxc.util.Attribute) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) FacesAttribute$JAXB.readFacesAttribute(org.apache.openejb.jee.FacesAttribute$JAXB.readFacesAttribute) FacesAttribute$JAXB.writeFacesAttribute(org.apache.openejb.jee.FacesAttribute$JAXB.writeFacesAttribute) Text$JAXB.readText(org.apache.openejb.jee.Text$JAXB.readText) Text$JAXB.writeText(org.apache.openejb.jee.Text$JAXB.writeText) Icon$JAXB.readIcon(org.apache.openejb.jee.Icon$JAXB.readIcon) Icon$JAXB.writeIcon(org.apache.openejb.jee.Icon$JAXB.writeIcon) RuntimeContext(org.metatype.sxc.jaxb.RuntimeContext) FacesProperty$JAXB.readFacesProperty(org.apache.openejb.jee.FacesProperty$JAXB.readFacesProperty) FacesProperty$JAXB.writeFacesProperty(org.apache.openejb.jee.FacesProperty$JAXB.writeFacesProperty) XoXMLStreamReader(org.metatype.sxc.util.XoXMLStreamReader)

Aggregations

Icon$JAXB.readIcon (org.apache.openejb.jee.Icon$JAXB.readIcon)74 Icon$JAXB.writeIcon (org.apache.openejb.jee.Icon$JAXB.writeIcon)74 RuntimeContext (org.metatype.sxc.jaxb.RuntimeContext)74 Text$JAXB.readText (org.apache.openejb.jee.Text$JAXB.readText)70 Text$JAXB.writeText (org.apache.openejb.jee.Text$JAXB.writeText)70 CollapsedStringAdapter (javax.xml.bind.annotation.adapters.CollapsedStringAdapter)69 ArrayList (java.util.ArrayList)40 QName (javax.xml.namespace.QName)40 Attribute (org.metatype.sxc.util.Attribute)37 XoXMLStreamReader (org.metatype.sxc.util.XoXMLStreamReader)37 DataSource$JAXB.readDataSource (org.apache.openejb.jee.DataSource$JAXB.readDataSource)12 DataSource$JAXB.writeDataSource (org.apache.openejb.jee.DataSource$JAXB.writeDataSource)12 EjbLocalRef$JAXB.readEjbLocalRef (org.apache.openejb.jee.EjbLocalRef$JAXB.readEjbLocalRef)12 EjbLocalRef$JAXB.writeEjbLocalRef (org.apache.openejb.jee.EjbLocalRef$JAXB.writeEjbLocalRef)12 EjbRef$JAXB.readEjbRef (org.apache.openejb.jee.EjbRef$JAXB.readEjbRef)12 EjbRef$JAXB.writeEjbRef (org.apache.openejb.jee.EjbRef$JAXB.writeEjbRef)12 EnvEntry$JAXB.readEnvEntry (org.apache.openejb.jee.EnvEntry$JAXB.readEnvEntry)12 EnvEntry$JAXB.writeEnvEntry (org.apache.openejb.jee.EnvEntry$JAXB.writeEnvEntry)12 MessageDestinationRef$JAXB.readMessageDestinationRef (org.apache.openejb.jee.MessageDestinationRef$JAXB.readMessageDestinationRef)12 MessageDestinationRef$JAXB.writeMessageDestinationRef (org.apache.openejb.jee.MessageDestinationRef$JAXB.writeMessageDestinationRef)12