Search in sources :

Example 16 with Text$JAXB.writeText

use of org.apache.openejb.jee.Text$JAXB.writeText in project tomee by apache.

the class ExcludeList$JAXB method _read.

public static final ExcludeList _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
    // Check for xsi:nil
    if (reader.isXsiNil()) {
        return null;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final ExcludeList excludeList = new ExcludeList();
    context.beforeUnmarshal(excludeList, LifecycleCallback.NONE);
    ArrayList<Text> descriptions = null;
    List<Method> method = null;
    // Check xsi:type
    final QName xsiType = reader.getXsiType();
    if (xsiType != null) {
        if (("exclude-listType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
            return context.unexpectedXsiType(reader, ExcludeList.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, excludeList);
            excludeList.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 (("method" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: method
            final Method methodItem = readMethod(elementReader, context);
            if (method == null) {
                method = excludeList.method;
                if (method != null) {
                    method.clear();
                } else {
                    method = new ArrayList<Method>();
                }
            }
            method.add(methodItem);
        } else {
            context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "description"), new QName("http://java.sun.com/xml/ns/javaee", "method"));
        }
    }
    if (descriptions != null) {
        try {
            excludeList.setDescriptions(descriptions.toArray(new Text[descriptions.size()]));
        } catch (final Exception e) {
            context.setterError(reader, ExcludeList.class, "setDescriptions", Text[].class, e);
        }
    }
    if (method != null) {
        excludeList.method = method;
    }
    context.afterUnmarshal(excludeList, LifecycleCallback.NONE);
    return excludeList;
}
Also used : Attribute(org.metatype.sxc.util.Attribute) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) Text$JAXB.readText(org.apache.openejb.jee.Text$JAXB.readText) Text$JAXB.writeText(org.apache.openejb.jee.Text$JAXB.writeText) Method$JAXB.readMethod(org.apache.openejb.jee.Method$JAXB.readMethod) Method$JAXB.writeMethod(org.apache.openejb.jee.Method$JAXB.writeMethod) RuntimeContext(org.metatype.sxc.jaxb.RuntimeContext) XoXMLStreamReader(org.metatype.sxc.util.XoXMLStreamReader)

Example 17 with Text$JAXB.writeText

use of org.apache.openejb.jee.Text$JAXB.writeText in project tomee by apache.

the class ExcludeList$JAXB method _write.

public static final void _write(final XoXMLStreamWriter writer, final ExcludeList excludeList, RuntimeContext context) throws Exception {
    if (excludeList == null) {
        writer.writeXsiNil();
        return;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final String prefix = writer.getUniquePrefix("http://java.sun.com/xml/ns/javaee");
    if (ExcludeList.class != excludeList.getClass()) {
        context.unexpectedSubclass(writer, excludeList, ExcludeList.class);
        return;
    }
    context.beforeMarshal(excludeList, LifecycleCallback.NONE);
    // ATTRIBUTE: id
    final String idRaw = excludeList.id;
    if (idRaw != null) {
        String id = null;
        try {
            id = Adapters.collapsedStringAdapterAdapter.marshal(idRaw);
        } catch (final Exception e) {
            context.xmlAdapterError(excludeList, "id", CollapsedStringAdapter.class, String.class, String.class, e);
        }
        writer.writeAttribute("", "", "id", id);
    }
    // ELEMENT: descriptions
    Text[] descriptions = null;
    try {
        descriptions = excludeList.getDescriptions();
    } catch (final Exception e) {
        context.getterError(excludeList, "descriptions", ExcludeList.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(excludeList, "descriptions");
            }
        }
    }
    // ELEMENT: method
    final List<Method> method = excludeList.method;
    if (method != null) {
        for (final Method methodItem : method) {
            if (methodItem != null) {
                writer.writeStartElement(prefix, "method", "http://java.sun.com/xml/ns/javaee");
                writeMethod(writer, methodItem, context);
                writer.writeEndElement();
            } else {
                context.unexpectedNullValue(excludeList, "method");
            }
        }
    }
    context.afterMarshal(excludeList, 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) Method$JAXB.readMethod(org.apache.openejb.jee.Method$JAXB.readMethod) Method$JAXB.writeMethod(org.apache.openejb.jee.Method$JAXB.writeMethod) RuntimeContext(org.metatype.sxc.jaxb.RuntimeContext)

Example 18 with Text$JAXB.writeText

use of org.apache.openejb.jee.Text$JAXB.writeText 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 19 with Text$JAXB.writeText

use of org.apache.openejb.jee.Text$JAXB.writeText 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 20 with Text$JAXB.writeText

use of org.apache.openejb.jee.Text$JAXB.writeText in project tomee by apache.

the class DataSource$JAXB method _read.

public static final DataSource _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
    // Check for xsi:nil
    if (reader.isXsiNil()) {
        return null;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final DataSource dataSource = new DataSource();
    context.beforeUnmarshal(dataSource, LifecycleCallback.NONE);
    ArrayList<Text> descriptions = null;
    List<Property> property = null;
    // Check xsi:type
    final QName xsiType = reader.getXsiType();
    if (xsiType != null) {
        if (("data-sourceType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
            return context.unexpectedXsiType(reader, DataSource.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, dataSource);
            dataSource.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 (("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;
            }
            dataSource.name = name;
        } else if (("class-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: className
            final String classNameRaw = elementReader.getElementAsString();
            final String className;
            try {
                className = Adapters.collapsedStringAdapterAdapter.unmarshal(classNameRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            dataSource.className = className;
        } else if (("server-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: serverName
            final String serverNameRaw = elementReader.getElementAsString();
            final String serverName;
            try {
                serverName = Adapters.collapsedStringAdapterAdapter.unmarshal(serverNameRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            dataSource.serverName = serverName;
        } else if (("port-number" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: portNumber
            final Integer portNumber = Integer.valueOf(elementReader.getElementAsString());
            dataSource.portNumber = portNumber;
        } else if (("database-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: databaseName
            final String databaseNameRaw = elementReader.getElementAsString();
            final String databaseName;
            try {
                databaseName = Adapters.collapsedStringAdapterAdapter.unmarshal(databaseNameRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            dataSource.databaseName = databaseName;
        } else if (("url" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: url
            final String urlRaw = elementReader.getElementAsString();
            final String url;
            try {
                url = Adapters.collapsedStringAdapterAdapter.unmarshal(urlRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            dataSource.url = url;
        } else if (("user" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: user
            final String userRaw = elementReader.getElementAsString();
            final String user;
            try {
                user = Adapters.collapsedStringAdapterAdapter.unmarshal(userRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            dataSource.user = user;
        } else if (("password" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: password
            final String passwordRaw = elementReader.getElementAsString();
            final String password;
            try {
                password = Adapters.collapsedStringAdapterAdapter.unmarshal(passwordRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            dataSource.password = password;
        } else if (("property" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: property
            final Property propertyItem = readProperty(elementReader, context);
            if (property == null) {
                property = dataSource.property;
                if (property != null) {
                    property.clear();
                } else {
                    property = new ArrayList<Property>();
                }
            }
            property.add(propertyItem);
        } else if (("login-timeout" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: loginTimeout
            final Integer loginTimeout = Integer.valueOf(elementReader.getElementAsString());
            dataSource.loginTimeout = loginTimeout;
        } else if (("transactional" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: transactional
            final Boolean transactional = ("1".equals(elementReader.getElementAsString()) || "true".equals(elementReader.getElementAsString()));
            dataSource.transactional = transactional;
        } else if (("isolation-level" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: isolationLevel
            final IsolationLevel isolationLevel = parseIsolationLevel(elementReader, context, elementReader.getElementAsString());
            if (isolationLevel != null) {
                dataSource.isolationLevel = isolationLevel;
            }
        } else if (("initial-pool-size" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: initialPoolSize
            final Integer initialPoolSize = Integer.valueOf(elementReader.getElementAsString());
            dataSource.initialPoolSize = initialPoolSize;
        } else if (("max-pool-size" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: maxPoolSize
            final Integer maxPoolSize = Integer.valueOf(elementReader.getElementAsString());
            dataSource.maxPoolSize = maxPoolSize;
        } else if (("min-pool-size" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: minPoolSize
            final Integer minPoolSize = Integer.valueOf(elementReader.getElementAsString());
            dataSource.minPoolSize = minPoolSize;
        } else if (("max-idle-time" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: maxIdleTime
            final Integer maxIdleTime = Integer.valueOf(elementReader.getElementAsString());
            dataSource.maxIdleTime = maxIdleTime;
        } else if (("max-statements" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: maxStatements
            final Integer maxStatements = Integer.valueOf(elementReader.getElementAsString());
            dataSource.maxStatements = maxStatements;
        } else {
            context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "description"), new QName("http://java.sun.com/xml/ns/javaee", "name"), new QName("http://java.sun.com/xml/ns/javaee", "class-name"), new QName("http://java.sun.com/xml/ns/javaee", "server-name"), new QName("http://java.sun.com/xml/ns/javaee", "port-number"), new QName("http://java.sun.com/xml/ns/javaee", "database-name"), new QName("http://java.sun.com/xml/ns/javaee", "url"), new QName("http://java.sun.com/xml/ns/javaee", "user"), new QName("http://java.sun.com/xml/ns/javaee", "password"), new QName("http://java.sun.com/xml/ns/javaee", "property"), new QName("http://java.sun.com/xml/ns/javaee", "login-timeout"), new QName("http://java.sun.com/xml/ns/javaee", "transactional"), new QName("http://java.sun.com/xml/ns/javaee", "isolation-level"), new QName("http://java.sun.com/xml/ns/javaee", "initial-pool-size"), new QName("http://java.sun.com/xml/ns/javaee", "max-pool-size"), new QName("http://java.sun.com/xml/ns/javaee", "min-pool-size"), new QName("http://java.sun.com/xml/ns/javaee", "max-idle-time"), new QName("http://java.sun.com/xml/ns/javaee", "max-statements"));
        }
    }
    if (descriptions != null) {
        try {
            dataSource.setDescriptions(descriptions.toArray(new Text[descriptions.size()]));
        } catch (final Exception e) {
            context.setterError(reader, DataSource.class, "setDescriptions", Text[].class, e);
        }
    }
    if (property != null) {
        dataSource.property = property;
    }
    context.afterUnmarshal(dataSource, LifecycleCallback.NONE);
    return dataSource;
}
Also used : IsolationLevel$JAXB.toStringIsolationLevel(org.apache.openejb.jee.IsolationLevel$JAXB.toStringIsolationLevel) IsolationLevel$JAXB.parseIsolationLevel(org.apache.openejb.jee.IsolationLevel$JAXB.parseIsolationLevel) 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) RuntimeContext(org.metatype.sxc.jaxb.RuntimeContext) Property$JAXB.writeProperty(org.apache.openejb.jee.Property$JAXB.writeProperty) Property$JAXB.readProperty(org.apache.openejb.jee.Property$JAXB.readProperty) XoXMLStreamReader(org.metatype.sxc.util.XoXMLStreamReader)

Aggregations

Text$JAXB.readText (org.apache.openejb.jee.Text$JAXB.readText)155 RuntimeContext (org.metatype.sxc.jaxb.RuntimeContext)155 Text$JAXB.writeText (org.apache.openejb.jee.Text$JAXB.writeText)154 CollapsedStringAdapter (javax.xml.bind.annotation.adapters.CollapsedStringAdapter)126 QName (javax.xml.namespace.QName)80 Attribute (org.metatype.sxc.util.Attribute)78 XoXMLStreamReader (org.metatype.sxc.util.XoXMLStreamReader)78 Icon$JAXB.readIcon (org.apache.openejb.jee.Icon$JAXB.readIcon)70 Icon$JAXB.writeIcon (org.apache.openejb.jee.Icon$JAXB.writeIcon)70 ArrayList (java.util.ArrayList)56 InjectionTarget$JAXB.readInjectionTarget (org.apache.openejb.jee.InjectionTarget$JAXB.readInjectionTarget)18 InjectionTarget$JAXB.writeInjectionTarget (org.apache.openejb.jee.InjectionTarget$JAXB.writeInjectionTarget)18 DataSource$JAXB.readDataSource (org.apache.openejb.jee.DataSource$JAXB.readDataSource)14 DataSource$JAXB.writeDataSource (org.apache.openejb.jee.DataSource$JAXB.writeDataSource)14 EjbLocalRef$JAXB.readEjbLocalRef (org.apache.openejb.jee.EjbLocalRef$JAXB.readEjbLocalRef)14 EjbLocalRef$JAXB.writeEjbLocalRef (org.apache.openejb.jee.EjbLocalRef$JAXB.writeEjbLocalRef)14 EjbRef$JAXB.readEjbRef (org.apache.openejb.jee.EjbRef$JAXB.readEjbRef)14 EjbRef$JAXB.writeEjbRef (org.apache.openejb.jee.EjbRef$JAXB.writeEjbRef)14 EnvEntry$JAXB.readEnvEntry (org.apache.openejb.jee.EnvEntry$JAXB.readEnvEntry)14 EnvEntry$JAXB.writeEnvEntry (org.apache.openejb.jee.EnvEntry$JAXB.writeEnvEntry)14