Search in sources :

Example 66 with Icon$JAXB.writeIcon

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

the class Function$JAXB method _read.

public static final Function _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
    // Check for xsi:nil
    if (reader.isXsiNil()) {
        return null;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final Function function = new Function();
    context.beforeUnmarshal(function, LifecycleCallback.NONE);
    ArrayList<Text> descriptions = null;
    ArrayList<Text> displayNames = null;
    LocalCollection<Icon> icon = null;
    List<TldExtension> functionExtension = null;
    // Check xsi:type
    final QName xsiType = reader.getXsiType();
    if (xsiType != null) {
        if (("functionType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
            return context.unexpectedXsiType(reader, Function.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, function);
            function.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 = function.icon;
                if (icon != null) {
                    icon.clear();
                } else {
                    icon = new LocalCollection<Icon>();
                }
            }
            icon.add(iconItem);
        } else if (("name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: name
            final String nameRaw = elementReader.getElementAsString();
            final String name;
            try {
                name = Adapters.collapsedStringAdapterAdapter.unmarshal(nameRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            function.name = name;
        } else if (("function-class" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: functionClass
            final String functionClassRaw = elementReader.getElementAsString();
            final String functionClass;
            try {
                functionClass = Adapters.collapsedStringAdapterAdapter.unmarshal(functionClassRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            function.functionClass = functionClass;
        } else if (("function-signature" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: functionSignature
            final String functionSignatureRaw = elementReader.getElementAsString();
            final String functionSignature;
            try {
                functionSignature = Adapters.collapsedStringAdapterAdapter.unmarshal(functionSignatureRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            function.functionSignature = functionSignature;
        } else if (("example" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: example
            final String exampleRaw = elementReader.getElementAsString();
            final String example;
            try {
                example = Adapters.collapsedStringAdapterAdapter.unmarshal(exampleRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            function.example = example;
        } else if (("function-extension" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: functionExtension
            final TldExtension functionExtensionItem = readTldExtension(elementReader, context);
            if (functionExtension == null) {
                functionExtension = function.functionExtension;
                if (functionExtension != null) {
                    functionExtension.clear();
                } else {
                    functionExtension = new ArrayList<TldExtension>();
                }
            }
            functionExtension.add(functionExtensionItem);
        } 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", "name"), new QName("http://java.sun.com/xml/ns/javaee", "function-class"), new QName("http://java.sun.com/xml/ns/javaee", "function-signature"), new QName("http://java.sun.com/xml/ns/javaee", "example"), new QName("http://java.sun.com/xml/ns/javaee", "function-extension"));
        }
    }
    if (descriptions != null) {
        try {
            function.setDescriptions(descriptions.toArray(new Text[descriptions.size()]));
        } catch (final Exception e) {
            context.setterError(reader, Function.class, "setDescriptions", Text[].class, e);
        }
    }
    if (displayNames != null) {
        try {
            function.setDisplayNames(displayNames.toArray(new Text[displayNames.size()]));
        } catch (final Exception e) {
            context.setterError(reader, Function.class, "setDisplayNames", Text[].class, e);
        }
    }
    if (icon != null) {
        function.icon = icon;
    }
    if (functionExtension != null) {
        function.functionExtension = functionExtension;
    }
    context.afterUnmarshal(function, LifecycleCallback.NONE);
    return function;
}
Also used : CollapsedStringAdapter(javax.xml.bind.annotation.adapters.CollapsedStringAdapter) Attribute(org.metatype.sxc.util.Attribute) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) Text$JAXB.readText(org.apache.openejb.jee.Text$JAXB.readText) Text$JAXB.writeText(org.apache.openejb.jee.Text$JAXB.writeText) TldExtension$JAXB.readTldExtension(org.apache.openejb.jee.TldExtension$JAXB.readTldExtension) TldExtension$JAXB.writeTldExtension(org.apache.openejb.jee.TldExtension$JAXB.writeTldExtension) 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 67 with Icon$JAXB.writeIcon

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

the class Handler$JAXB method _read.

public static final Handler _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
    // Check for xsi:nil
    if (reader.isXsiNil()) {
        return null;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final Handler handler = new Handler();
    context.beforeUnmarshal(handler, LifecycleCallback.NONE);
    ArrayList<Text> descriptions = null;
    ArrayList<Text> displayNames = null;
    LocalCollection<Icon> icon = null;
    List<ParamValue> initParam = null;
    List<QName> soapHeader = null;
    List<String> soapRole = null;
    List<String> portName = null;
    // Check xsi:type
    final QName xsiType = reader.getXsiType();
    if (xsiType != null) {
        if (("handlerType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
            return context.unexpectedXsiType(reader, Handler.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, handler);
            handler.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 = handler.icon;
                if (icon != null) {
                    icon.clear();
                } else {
                    icon = new LocalCollection<Icon>();
                }
            }
            icon.add(iconItem);
        } else if (("handler-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: handlerName
            final String handlerNameRaw = elementReader.getElementAsString();
            final String handlerName;
            try {
                handlerName = Adapters.collapsedStringAdapterAdapter.unmarshal(handlerNameRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            handler.handlerName = handlerName;
        } else if (("handler-class" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: handlerClass
            final String handlerClassRaw = elementReader.getElementAsString();
            final String handlerClass;
            try {
                handlerClass = Adapters.collapsedStringAdapterAdapter.unmarshal(handlerClassRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            handler.handlerClass = handlerClass;
        } else if (("init-param" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: initParam
            final ParamValue initParamItem = readParamValue(elementReader, context);
            if (initParam == null) {
                initParam = handler.initParam;
                if (initParam != null) {
                    initParam.clear();
                } else {
                    initParam = new ArrayList<ParamValue>();
                }
            }
            initParam.add(initParamItem);
        } else if (("soap-header" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: soapHeader
            final QName soapHeaderItem = elementReader.getElementAsQName();
            if (soapHeader == null) {
                soapHeader = handler.soapHeader;
                if (soapHeader != null) {
                    soapHeader.clear();
                } else {
                    soapHeader = new ArrayList<QName>();
                }
            }
            soapHeader.add(soapHeaderItem);
        } else if (("soap-role" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: soapRole
            final String soapRoleItemRaw = elementReader.getElementAsString();
            final String soapRoleItem;
            try {
                soapRoleItem = Adapters.collapsedStringAdapterAdapter.unmarshal(soapRoleItemRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            if (soapRole == null) {
                soapRole = handler.soapRole;
                if (soapRole != null) {
                    soapRole.clear();
                } else {
                    soapRole = new ArrayList<String>();
                }
            }
            soapRole.add(soapRoleItem);
        } else if (("port-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: portName
            final String portNameItemRaw = elementReader.getElementAsString();
            final String portNameItem;
            try {
                portNameItem = Adapters.collapsedStringAdapterAdapter.unmarshal(portNameItemRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            if (portName == null) {
                portName = handler.portName;
                if (portName != null) {
                    portName.clear();
                } else {
                    portName = new ArrayList<String>();
                }
            }
            portName.add(portNameItem);
        } 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", "handler-name"), new QName("http://java.sun.com/xml/ns/javaee", "handler-class"), new QName("http://java.sun.com/xml/ns/javaee", "init-param"), new QName("http://java.sun.com/xml/ns/javaee", "soap-header"), new QName("http://java.sun.com/xml/ns/javaee", "soap-role"), new QName("http://java.sun.com/xml/ns/javaee", "port-name"));
        }
    }
    if (descriptions != null) {
        try {
            handler.setDescriptions(descriptions.toArray(new Text[descriptions.size()]));
        } catch (final Exception e) {
            context.setterError(reader, Handler.class, "setDescriptions", Text[].class, e);
        }
    }
    if (displayNames != null) {
        try {
            handler.setDisplayNames(displayNames.toArray(new Text[displayNames.size()]));
        } catch (final Exception e) {
            context.setterError(reader, Handler.class, "setDisplayNames", Text[].class, e);
        }
    }
    if (icon != null) {
        handler.icon = icon;
    }
    if (initParam != null) {
        handler.initParam = initParam;
    }
    if (soapHeader != null) {
        handler.soapHeader = soapHeader;
    }
    if (soapRole != null) {
        handler.soapRole = soapRole;
    }
    if (portName != null) {
        handler.portName = portName;
    }
    context.afterUnmarshal(handler, LifecycleCallback.NONE);
    return handler;
}
Also used : CollapsedStringAdapter(javax.xml.bind.annotation.adapters.CollapsedStringAdapter) Attribute(org.metatype.sxc.util.Attribute) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) 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) 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 68 with Icon$JAXB.writeIcon

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

the class JspPropertyGroup$JAXB method _read.

public static final JspPropertyGroup _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
    // Check for xsi:nil
    if (reader.isXsiNil()) {
        return null;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final JspPropertyGroup jspPropertyGroup = new JspPropertyGroup();
    context.beforeUnmarshal(jspPropertyGroup, LifecycleCallback.NONE);
    ArrayList<Text> descriptions = null;
    ArrayList<Text> displayNames = null;
    LocalCollection<Icon> icon = null;
    List<String> urlPattern = null;
    List<String> includePrelude = null;
    List<String> includeCoda = null;
    // Check xsi:type
    final QName xsiType = reader.getXsiType();
    if (xsiType != null) {
        if (("jsp-property-groupType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
            return context.unexpectedXsiType(reader, JspPropertyGroup.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, jspPropertyGroup);
            jspPropertyGroup.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 = jspPropertyGroup.icon;
                if (icon != null) {
                    icon.clear();
                } else {
                    icon = new LocalCollection<Icon>();
                }
            }
            icon.add(iconItem);
        } else if (("url-pattern" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: urlPattern
            final String urlPatternItemRaw = elementReader.getElementAsString();
            final String urlPatternItem;
            try {
                urlPatternItem = Adapters.trimStringAdapterAdapter.unmarshal(urlPatternItemRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, TrimStringAdapter.class, String.class, String.class, e);
                continue;
            }
            if (urlPattern == null) {
                urlPattern = jspPropertyGroup.urlPattern;
                if (urlPattern != null) {
                    urlPattern.clear();
                } else {
                    urlPattern = new ArrayList<String>();
                }
            }
            urlPattern.add(urlPatternItem);
        } else if (("el-ignored" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: elIgnored
            final Boolean elIgnored = ("1".equals(elementReader.getElementAsString()) || "true".equals(elementReader.getElementAsString()));
            jspPropertyGroup.elIgnored = elIgnored;
        } else if (("page-encoding" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: pageEncoding
            final String pageEncodingRaw = elementReader.getElementAsString();
            final String pageEncoding;
            try {
                pageEncoding = Adapters.collapsedStringAdapterAdapter.unmarshal(pageEncodingRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            jspPropertyGroup.pageEncoding = pageEncoding;
        } else if (("scripting-invalid" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: scriptingInvalid
            final Boolean scriptingInvalid = ("1".equals(elementReader.getElementAsString()) || "true".equals(elementReader.getElementAsString()));
            jspPropertyGroup.scriptingInvalid = scriptingInvalid;
        } else if (("is-xml" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: isXml
            final Boolean isXml = ("1".equals(elementReader.getElementAsString()) || "true".equals(elementReader.getElementAsString()));
            jspPropertyGroup.isXml = isXml;
        } else if (("include-prelude" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: includePrelude
            final String includePreludeItemRaw = elementReader.getElementAsString();
            final String includePreludeItem;
            try {
                includePreludeItem = Adapters.collapsedStringAdapterAdapter.unmarshal(includePreludeItemRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            if (includePrelude == null) {
                includePrelude = jspPropertyGroup.includePrelude;
                if (includePrelude != null) {
                    includePrelude.clear();
                } else {
                    includePrelude = new ArrayList<String>();
                }
            }
            includePrelude.add(includePreludeItem);
        } else if (("include-coda" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: includeCoda
            final String includeCodaItemRaw = elementReader.getElementAsString();
            final String includeCodaItem;
            try {
                includeCodaItem = Adapters.collapsedStringAdapterAdapter.unmarshal(includeCodaItemRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            if (includeCoda == null) {
                includeCoda = jspPropertyGroup.includeCoda;
                if (includeCoda != null) {
                    includeCoda.clear();
                } else {
                    includeCoda = new ArrayList<String>();
                }
            }
            includeCoda.add(includeCodaItem);
        } else if (("deferred-syntax-allowed-as-literal" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: deferredSyntaxAllowedAsLiteral
            final Boolean deferredSyntaxAllowedAsLiteral = ("1".equals(elementReader.getElementAsString()) || "true".equals(elementReader.getElementAsString()));
            jspPropertyGroup.deferredSyntaxAllowedAsLiteral = deferredSyntaxAllowedAsLiteral;
        } else if (("trim-directive-whitespaces" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: trimDirectiveWhitespaces
            final Boolean trimDirectiveWhitespaces = ("1".equals(elementReader.getElementAsString()) || "true".equals(elementReader.getElementAsString()));
            jspPropertyGroup.trimDirectiveWhitespaces = trimDirectiveWhitespaces;
        } else if (("default-content-type" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: defaultContentType
            final String defaultContentTypeRaw = elementReader.getElementAsString();
            final String defaultContentType;
            try {
                defaultContentType = Adapters.collapsedStringAdapterAdapter.unmarshal(defaultContentTypeRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            jspPropertyGroup.defaultContentType = defaultContentType;
        } else if (("buffer" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: buffer
            final String bufferRaw = elementReader.getElementAsString();
            final String buffer;
            try {
                buffer = Adapters.collapsedStringAdapterAdapter.unmarshal(bufferRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            jspPropertyGroup.buffer = buffer;
        } else if (("error-on-undeclared-namespace" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: errorOnUndeclaredNamespace
            final Boolean errorOnUndeclaredNamespace = ("1".equals(elementReader.getElementAsString()) || "true".equals(elementReader.getElementAsString()));
            jspPropertyGroup.errorOnUndeclaredNamespace = errorOnUndeclaredNamespace;
        } 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", "url-pattern"), new QName("http://java.sun.com/xml/ns/javaee", "el-ignored"), new QName("http://java.sun.com/xml/ns/javaee", "page-encoding"), new QName("http://java.sun.com/xml/ns/javaee", "scripting-invalid"), new QName("http://java.sun.com/xml/ns/javaee", "is-xml"), new QName("http://java.sun.com/xml/ns/javaee", "include-prelude"), new QName("http://java.sun.com/xml/ns/javaee", "include-coda"), new QName("http://java.sun.com/xml/ns/javaee", "deferred-syntax-allowed-as-literal"), new QName("http://java.sun.com/xml/ns/javaee", "trim-directive-whitespaces"), new QName("http://java.sun.com/xml/ns/javaee", "default-content-type"), new QName("http://java.sun.com/xml/ns/javaee", "buffer"), new QName("http://java.sun.com/xml/ns/javaee", "error-on-undeclared-namespace"));
        }
    }
    if (descriptions != null) {
        try {
            jspPropertyGroup.setDescriptions(descriptions.toArray(new Text[descriptions.size()]));
        } catch (final Exception e) {
            context.setterError(reader, JspPropertyGroup.class, "setDescriptions", Text[].class, e);
        }
    }
    if (displayNames != null) {
        try {
            jspPropertyGroup.setDisplayNames(displayNames.toArray(new Text[displayNames.size()]));
        } catch (final Exception e) {
            context.setterError(reader, JspPropertyGroup.class, "setDisplayNames", Text[].class, e);
        }
    }
    if (icon != null) {
        jspPropertyGroup.icon = icon;
    }
    if (urlPattern != null) {
        jspPropertyGroup.urlPattern = urlPattern;
    }
    if (includePrelude != null) {
        jspPropertyGroup.includePrelude = includePrelude;
    }
    if (includeCoda != null) {
        jspPropertyGroup.includeCoda = includeCoda;
    }
    context.afterUnmarshal(jspPropertyGroup, LifecycleCallback.NONE);
    return jspPropertyGroup;
}
Also used : CollapsedStringAdapter(javax.xml.bind.annotation.adapters.CollapsedStringAdapter) Attribute(org.metatype.sxc.util.Attribute) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) Text$JAXB.readText(org.apache.openejb.jee.Text$JAXB.readText) 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 69 with Icon$JAXB.writeIcon

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

the class JspPropertyGroup$JAXB method _write.

public static final void _write(final XoXMLStreamWriter writer, final JspPropertyGroup jspPropertyGroup, RuntimeContext context) throws Exception {
    if (jspPropertyGroup == null) {
        writer.writeXsiNil();
        return;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final String prefix = writer.getUniquePrefix("http://java.sun.com/xml/ns/javaee");
    if (JspPropertyGroup.class != jspPropertyGroup.getClass()) {
        context.unexpectedSubclass(writer, jspPropertyGroup, JspPropertyGroup.class);
        return;
    }
    context.beforeMarshal(jspPropertyGroup, LifecycleCallback.NONE);
    // ATTRIBUTE: id
    final String idRaw = jspPropertyGroup.id;
    if (idRaw != null) {
        String id = null;
        try {
            id = Adapters.collapsedStringAdapterAdapter.marshal(idRaw);
        } catch (final Exception e) {
            context.xmlAdapterError(jspPropertyGroup, "id", CollapsedStringAdapter.class, String.class, String.class, e);
        }
        writer.writeAttribute("", "", "id", id);
    }
    // ELEMENT: descriptions
    Text[] descriptions = null;
    try {
        descriptions = jspPropertyGroup.getDescriptions();
    } catch (final Exception e) {
        context.getterError(jspPropertyGroup, "descriptions", JspPropertyGroup.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(jspPropertyGroup, "descriptions");
            }
        }
    }
    // ELEMENT: displayNames
    Text[] displayNames = null;
    try {
        displayNames = jspPropertyGroup.getDisplayNames();
    } catch (final Exception e) {
        context.getterError(jspPropertyGroup, "displayNames", JspPropertyGroup.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(jspPropertyGroup, "displayNames");
            }
        }
    }
    // ELEMENT: icon
    final LocalCollection<Icon> icon = jspPropertyGroup.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(jspPropertyGroup, "icon");
            }
        }
    }
    // ELEMENT: urlPattern
    final List<String> urlPatternRaw = jspPropertyGroup.urlPattern;
    if (urlPatternRaw != null) {
        for (final String urlPatternItem : urlPatternRaw) {
            String urlPattern = null;
            try {
                urlPattern = Adapters.trimStringAdapterAdapter.marshal(urlPatternItem);
            } catch (final Exception e) {
                context.xmlAdapterError(jspPropertyGroup, "urlPattern", TrimStringAdapter.class, List.class, List.class, e);
            }
            if (urlPattern != null) {
                writer.writeStartElement(prefix, "url-pattern", "http://java.sun.com/xml/ns/javaee");
                writer.writeCharacters(urlPattern);
                writer.writeEndElement();
            } else {
                context.unexpectedNullValue(jspPropertyGroup, "urlPattern");
            }
        }
    }
    // ELEMENT: elIgnored
    final Boolean elIgnored = jspPropertyGroup.elIgnored;
    if (elIgnored != null) {
        writer.writeStartElement(prefix, "el-ignored", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(Boolean.toString(elIgnored));
        writer.writeEndElement();
    }
    // ELEMENT: pageEncoding
    final String pageEncodingRaw = jspPropertyGroup.pageEncoding;
    String pageEncoding = null;
    try {
        pageEncoding = Adapters.collapsedStringAdapterAdapter.marshal(pageEncodingRaw);
    } catch (final Exception e) {
        context.xmlAdapterError(jspPropertyGroup, "pageEncoding", CollapsedStringAdapter.class, String.class, String.class, e);
    }
    if (pageEncoding != null) {
        writer.writeStartElement(prefix, "page-encoding", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(pageEncoding);
        writer.writeEndElement();
    }
    // ELEMENT: scriptingInvalid
    final Boolean scriptingInvalid = jspPropertyGroup.scriptingInvalid;
    if (scriptingInvalid != null) {
        writer.writeStartElement(prefix, "scripting-invalid", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(Boolean.toString(scriptingInvalid));
        writer.writeEndElement();
    }
    // ELEMENT: isXml
    final Boolean isXml = jspPropertyGroup.isXml;
    if (isXml != null) {
        writer.writeStartElement(prefix, "is-xml", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(Boolean.toString(isXml));
        writer.writeEndElement();
    }
    // ELEMENT: includePrelude
    final List<String> includePreludeRaw = jspPropertyGroup.includePrelude;
    if (includePreludeRaw != null) {
        for (final String includePreludeItem : includePreludeRaw) {
            String includePrelude = null;
            try {
                includePrelude = Adapters.collapsedStringAdapterAdapter.marshal(includePreludeItem);
            } catch (final Exception e) {
                context.xmlAdapterError(jspPropertyGroup, "includePrelude", CollapsedStringAdapter.class, List.class, List.class, e);
            }
            if (includePrelude != null) {
                writer.writeStartElement(prefix, "include-prelude", "http://java.sun.com/xml/ns/javaee");
                writer.writeCharacters(includePrelude);
                writer.writeEndElement();
            }
        }
    }
    // ELEMENT: includeCoda
    final List<String> includeCodaRaw = jspPropertyGroup.includeCoda;
    if (includeCodaRaw != null) {
        for (final String includeCodaItem : includeCodaRaw) {
            String includeCoda = null;
            try {
                includeCoda = Adapters.collapsedStringAdapterAdapter.marshal(includeCodaItem);
            } catch (final Exception e) {
                context.xmlAdapterError(jspPropertyGroup, "includeCoda", CollapsedStringAdapter.class, List.class, List.class, e);
            }
            if (includeCoda != null) {
                writer.writeStartElement(prefix, "include-coda", "http://java.sun.com/xml/ns/javaee");
                writer.writeCharacters(includeCoda);
                writer.writeEndElement();
            }
        }
    }
    // ELEMENT: deferredSyntaxAllowedAsLiteral
    final Boolean deferredSyntaxAllowedAsLiteral = jspPropertyGroup.deferredSyntaxAllowedAsLiteral;
    if (deferredSyntaxAllowedAsLiteral != null) {
        writer.writeStartElement(prefix, "deferred-syntax-allowed-as-literal", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(Boolean.toString(deferredSyntaxAllowedAsLiteral));
        writer.writeEndElement();
    }
    // ELEMENT: trimDirectiveWhitespaces
    final Boolean trimDirectiveWhitespaces = jspPropertyGroup.trimDirectiveWhitespaces;
    if (trimDirectiveWhitespaces != null) {
        writer.writeStartElement(prefix, "trim-directive-whitespaces", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(Boolean.toString(trimDirectiveWhitespaces));
        writer.writeEndElement();
    }
    // ELEMENT: defaultContentType
    final String defaultContentTypeRaw = jspPropertyGroup.defaultContentType;
    String defaultContentType = null;
    try {
        defaultContentType = Adapters.collapsedStringAdapterAdapter.marshal(defaultContentTypeRaw);
    } catch (final Exception e) {
        context.xmlAdapterError(jspPropertyGroup, "defaultContentType", CollapsedStringAdapter.class, String.class, String.class, e);
    }
    if (defaultContentType != null) {
        writer.writeStartElement(prefix, "default-content-type", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(defaultContentType);
        writer.writeEndElement();
    }
    // ELEMENT: buffer
    final String bufferRaw = jspPropertyGroup.buffer;
    String buffer = null;
    try {
        buffer = Adapters.collapsedStringAdapterAdapter.marshal(bufferRaw);
    } catch (final Exception e) {
        context.xmlAdapterError(jspPropertyGroup, "buffer", CollapsedStringAdapter.class, String.class, String.class, e);
    }
    if (buffer != null) {
        writer.writeStartElement(prefix, "buffer", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(buffer);
        writer.writeEndElement();
    }
    // ELEMENT: errorOnUndeclaredNamespace
    final Boolean errorOnUndeclaredNamespace = jspPropertyGroup.errorOnUndeclaredNamespace;
    if (errorOnUndeclaredNamespace != null) {
        writer.writeStartElement(prefix, "error-on-undeclared-namespace", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(Boolean.toString(errorOnUndeclaredNamespace));
        writer.writeEndElement();
    }
    context.afterMarshal(jspPropertyGroup, LifecycleCallback.NONE);
}
Also used : 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) ArrayList(java.util.ArrayList) List(java.util.List) 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 70 with Icon$JAXB.writeIcon

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

the class EjbJarInfoBuilder method initEntityBean.

private EnterpriseBeanInfo initEntityBean(final EntityBean e, final Map m) throws OpenEJBException {
    final EntityBeanInfo bean = new EntityBeanInfo();
    final EjbDeployment d = (EjbDeployment) m.get(e.getEjbName());
    if (d == null) {
        throw new OpenEJBException("No deployment information in openejb-jar.xml for bean " + e.getEjbName() + ". Please redeploy the jar");
    }
    bean.ejbDeploymentId = d.getDeploymentId();
    bean.containerId = d.getContainerId();
    final Icon icon = e.getIcon();
    bean.largeIcon = icon == null ? null : icon.getLargeIcon();
    bean.smallIcon = icon == null ? null : icon.getSmallIcon();
    bean.description = e.getDescription();
    bean.displayName = e.getDisplayName();
    bean.ejbClass = e.getEjbClass();
    bean.abstractSchemaName = e.getAbstractSchemaName();
    bean.ejbName = e.getEjbName();
    bean.home = e.getHome();
    bean.remote = e.getRemote();
    bean.localHome = e.getLocalHome();
    bean.local = e.getLocal();
    bean.transactionType = "Container";
    bean.primKeyClass = e.getPrimKeyClass();
    bean.primKeyField = e.getPrimkeyField();
    bean.persistenceType = e.getPersistenceType().toString();
    bean.reentrant = String.valueOf(e.getReentrant());
    bean.properties.putAll(d.getProperties());
    final CmpVersion cmpVersion = e.getCmpVersion();
    if (e.getPersistenceType() == PersistenceType.CONTAINER) {
        if (cmpVersion != null && cmpVersion == CmpVersion.CMP1) {
            bean.cmpVersion = 1;
        } else {
            bean.cmpVersion = 2;
        }
    }
    final List<CmpField> cmpFields = e.getCmpField();
    for (final CmpField cmpField : cmpFields) {
        bean.cmpFieldNames.add(cmpField.getFieldName());
    }
    if (bean.persistenceType.equalsIgnoreCase("Container")) {
        for (final Query q : e.getQuery()) {
            final QueryInfo query = new QueryInfo();
            query.queryStatement = q.getEjbQl().trim();
            final MethodInfo method = new MethodInfo();
            method.ejbName = bean.ejbName;
            method.className = "*";
            final QueryMethod qm = q.getQueryMethod();
            method.methodName = qm.getMethodName();
            if (qm.getMethodParams() != null) {
                method.methodParams = qm.getMethodParams().getMethodParam();
            }
            query.method = method;
            final ResultTypeMapping resultType = q.getResultTypeMapping();
            if (ResultTypeMapping.REMOTE.equals(resultType)) {
                query.remoteResultType = true;
            }
            bean.queries.add(query);
        }
        for (final org.apache.openejb.jee.oejb3.Query q : d.getQuery()) {
            final QueryInfo query = new QueryInfo();
            query.description = q.getDescription();
            query.queryStatement = q.getObjectQl().trim();
            final MethodInfo method = new MethodInfo();
            method.ejbName = bean.ejbName;
            method.className = "*";
            final org.apache.openejb.jee.oejb3.QueryMethod qm = q.getQueryMethod();
            method.methodName = qm.getMethodName();
            if (qm.getMethodParams() != null) {
                method.methodParams = qm.getMethodParams().getMethodParam();
            }
            query.method = method;
            bean.queries.add(query);
        }
    }
    return bean;
}
Also used : OpenEJBException(org.apache.openejb.OpenEJBException) ResultTypeMapping(org.apache.openejb.jee.ResultTypeMapping) Query(org.apache.openejb.jee.Query) QueryMethod(org.apache.openejb.jee.QueryMethod) QueryInfo(org.apache.openejb.assembler.classic.QueryInfo) CmpField(org.apache.openejb.jee.CmpField) EjbDeployment(org.apache.openejb.jee.oejb3.EjbDeployment) MethodInfo(org.apache.openejb.assembler.classic.MethodInfo) InitMethodInfo(org.apache.openejb.assembler.classic.InitMethodInfo) NamedMethodInfo(org.apache.openejb.assembler.classic.NamedMethodInfo) RemoveMethodInfo(org.apache.openejb.assembler.classic.RemoveMethodInfo) EntityBeanInfo(org.apache.openejb.assembler.classic.EntityBeanInfo) Icon(org.apache.openejb.jee.Icon) CmpVersion(org.apache.openejb.jee.CmpVersion)

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