Search in sources :

Example 51 with Text$JAXB.readText

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

the class Query$JAXB method _write.

public static final void _write(final XoXMLStreamWriter writer, final Query query, RuntimeContext context) throws Exception {
    if (query == null) {
        writer.writeXsiNil();
        return;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final String prefix = writer.getUniquePrefix("http://java.sun.com/xml/ns/javaee");
    if (Query.class != query.getClass()) {
        context.unexpectedSubclass(writer, query, Query.class);
        return;
    }
    context.beforeMarshal(query, LifecycleCallback.NONE);
    // ATTRIBUTE: id
    final String idRaw = query.id;
    if (idRaw != null) {
        String id = null;
        try {
            id = Adapters.collapsedStringAdapterAdapter.marshal(idRaw);
        } catch (final Exception e) {
            context.xmlAdapterError(query, "id", CollapsedStringAdapter.class, String.class, String.class, e);
        }
        writer.writeAttribute("", "", "id", id);
    }
    // ELEMENT: description
    final Text description = query.description;
    if (description != null) {
        writer.writeStartElement(prefix, "description", "http://java.sun.com/xml/ns/javaee");
        writeText(writer, description, context);
        writer.writeEndElement();
    }
    // ELEMENT: queryMethod
    final QueryMethod queryMethod = query.queryMethod;
    if (queryMethod != null) {
        writer.writeStartElement(prefix, "query-method", "http://java.sun.com/xml/ns/javaee");
        writeQueryMethod(writer, queryMethod, context);
        writer.writeEndElement();
    } else {
        context.unexpectedNullValue(query, "queryMethod");
    }
    // ELEMENT: resultTypeMapping
    final ResultTypeMapping resultTypeMapping = query.resultTypeMapping;
    if (resultTypeMapping != null) {
        writer.writeStartElement(prefix, "result-type-mapping", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(toStringResultTypeMapping(query, null, context, resultTypeMapping));
        writer.writeEndElement();
    }
    // ELEMENT: ejbQl
    final String ejbQlRaw = query.ejbQl;
    String ejbQl = null;
    try {
        ejbQl = Adapters.collapsedStringAdapterAdapter.marshal(ejbQlRaw);
    } catch (final Exception e) {
        context.xmlAdapterError(query, "ejbQl", CollapsedStringAdapter.class, String.class, String.class, e);
    }
    if (ejbQl != null) {
        writer.writeStartElement(prefix, "ejb-ql", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(ejbQl);
        writer.writeEndElement();
    } else {
        context.unexpectedNullValue(query, "ejbQl");
    }
    context.afterMarshal(query, LifecycleCallback.NONE);
}
Also used : ResultTypeMapping$JAXB.toStringResultTypeMapping(org.apache.openejb.jee.ResultTypeMapping$JAXB.toStringResultTypeMapping) ResultTypeMapping$JAXB.parseResultTypeMapping(org.apache.openejb.jee.ResultTypeMapping$JAXB.parseResultTypeMapping) CollapsedStringAdapter(javax.xml.bind.annotation.adapters.CollapsedStringAdapter) QueryMethod$JAXB.writeQueryMethod(org.apache.openejb.jee.QueryMethod$JAXB.writeQueryMethod) QueryMethod$JAXB.readQueryMethod(org.apache.openejb.jee.QueryMethod$JAXB.readQueryMethod) 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)

Example 52 with Text$JAXB.readText

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

the class Query$JAXB method _read.

public static final Query _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
    // Check for xsi:nil
    if (reader.isXsiNil()) {
        return null;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final Query query = new Query();
    context.beforeUnmarshal(query, LifecycleCallback.NONE);
    // Check xsi:type
    final QName xsiType = reader.getXsiType();
    if (xsiType != null) {
        if (("queryType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
            return context.unexpectedXsiType(reader, Query.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, query);
            query.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: description
            final Text description = readText(elementReader, context);
            query.description = description;
        } else if (("query-method" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: queryMethod
            final QueryMethod queryMethod = readQueryMethod(elementReader, context);
            query.queryMethod = queryMethod;
        } else if (("result-type-mapping" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: resultTypeMapping
            final ResultTypeMapping resultTypeMapping = parseResultTypeMapping(elementReader, context, elementReader.getElementAsString());
            if (resultTypeMapping != null) {
                query.resultTypeMapping = resultTypeMapping;
            }
        } else if (("ejb-ql" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: ejbQl
            final String ejbQlRaw = elementReader.getElementAsString();
            final String ejbQl;
            try {
                ejbQl = Adapters.collapsedStringAdapterAdapter.unmarshal(ejbQlRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            query.ejbQl = ejbQl;
        } else {
            context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "description"), new QName("http://java.sun.com/xml/ns/javaee", "query-method"), new QName("http://java.sun.com/xml/ns/javaee", "result-type-mapping"), new QName("http://java.sun.com/xml/ns/javaee", "ejb-ql"));
        }
    }
    context.afterUnmarshal(query, LifecycleCallback.NONE);
    return query;
}
Also used : ResultTypeMapping$JAXB.toStringResultTypeMapping(org.apache.openejb.jee.ResultTypeMapping$JAXB.toStringResultTypeMapping) ResultTypeMapping$JAXB.parseResultTypeMapping(org.apache.openejb.jee.ResultTypeMapping$JAXB.parseResultTypeMapping) Attribute(org.metatype.sxc.util.Attribute) QName(javax.xml.namespace.QName) QueryMethod$JAXB.writeQueryMethod(org.apache.openejb.jee.QueryMethod$JAXB.writeQueryMethod) QueryMethod$JAXB.readQueryMethod(org.apache.openejb.jee.QueryMethod$JAXB.readQueryMethod) 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) XoXMLStreamReader(org.metatype.sxc.util.XoXMLStreamReader)

Example 53 with Text$JAXB.readText

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

the class RelationshipRoleSource$JAXB method _write.

public static final void _write(final XoXMLStreamWriter writer, final RelationshipRoleSource relationshipRoleSource, RuntimeContext context) throws Exception {
    if (relationshipRoleSource == null) {
        writer.writeXsiNil();
        return;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final String prefix = writer.getUniquePrefix("http://java.sun.com/xml/ns/javaee");
    if (RelationshipRoleSource.class != relationshipRoleSource.getClass()) {
        context.unexpectedSubclass(writer, relationshipRoleSource, RelationshipRoleSource.class);
        return;
    }
    context.beforeMarshal(relationshipRoleSource, LifecycleCallback.NONE);
    // ATTRIBUTE: id
    final String idRaw = relationshipRoleSource.id;
    if (idRaw != null) {
        String id = null;
        try {
            id = Adapters.collapsedStringAdapterAdapter.marshal(idRaw);
        } catch (final Exception e) {
            context.xmlAdapterError(relationshipRoleSource, "id", CollapsedStringAdapter.class, String.class, String.class, e);
        }
        writer.writeAttribute("", "", "id", id);
    }
    // ELEMENT: descriptions
    Text[] descriptions = null;
    try {
        descriptions = relationshipRoleSource.getDescriptions();
    } catch (final Exception e) {
        context.getterError(relationshipRoleSource, "descriptions", RelationshipRoleSource.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(relationshipRoleSource, "descriptions");
            }
        }
    }
    // ELEMENT: ejbName
    final String ejbNameRaw = relationshipRoleSource.ejbName;
    String ejbName = null;
    try {
        ejbName = Adapters.collapsedStringAdapterAdapter.marshal(ejbNameRaw);
    } catch (final Exception e) {
        context.xmlAdapterError(relationshipRoleSource, "ejbName", CollapsedStringAdapter.class, String.class, String.class, e);
    }
    if (ejbName != null) {
        writer.writeStartElement(prefix, "ejb-name", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(ejbName);
        writer.writeEndElement();
    } else {
        context.unexpectedNullValue(relationshipRoleSource, "ejbName");
    }
    context.afterMarshal(relationshipRoleSource, 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) RuntimeContext(org.metatype.sxc.jaxb.RuntimeContext)

Example 54 with Text$JAXB.readText

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

the class RelationshipRoleSource$JAXB method _read.

public static final RelationshipRoleSource _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
    // Check for xsi:nil
    if (reader.isXsiNil()) {
        return null;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final RelationshipRoleSource relationshipRoleSource = new RelationshipRoleSource();
    context.beforeUnmarshal(relationshipRoleSource, LifecycleCallback.NONE);
    ArrayList<Text> descriptions = null;
    // Check xsi:type
    final QName xsiType = reader.getXsiType();
    if (xsiType != null) {
        if (("relationship-role-sourceType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
            return context.unexpectedXsiType(reader, RelationshipRoleSource.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, relationshipRoleSource);
            relationshipRoleSource.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 (("ejb-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: ejbName
            final String ejbNameRaw = elementReader.getElementAsString();
            final String ejbName;
            try {
                ejbName = Adapters.collapsedStringAdapterAdapter.unmarshal(ejbNameRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            relationshipRoleSource.ejbName = ejbName;
        } else {
            context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "description"), new QName("http://java.sun.com/xml/ns/javaee", "ejb-name"));
        }
    }
    if (descriptions != null) {
        try {
            relationshipRoleSource.setDescriptions(descriptions.toArray(new Text[descriptions.size()]));
        } catch (final Exception e) {
            context.setterError(reader, RelationshipRoleSource.class, "setDescriptions", Text[].class, e);
        }
    }
    context.afterUnmarshal(relationshipRoleSource, LifecycleCallback.NONE);
    return relationshipRoleSource;
}
Also used : Attribute(org.metatype.sxc.util.Attribute) QName(javax.xml.namespace.QName) 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) XoXMLStreamReader(org.metatype.sxc.util.XoXMLStreamReader)

Example 55 with Text$JAXB.readText

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

the class Relationships$JAXB method _write.

public static final void _write(final XoXMLStreamWriter writer, final Relationships relationships, RuntimeContext context) throws Exception {
    if (relationships == null) {
        writer.writeXsiNil();
        return;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final String prefix = writer.getUniquePrefix("http://java.sun.com/xml/ns/javaee");
    if (Relationships.class != relationships.getClass()) {
        context.unexpectedSubclass(writer, relationships, Relationships.class);
        return;
    }
    context.beforeMarshal(relationships, LifecycleCallback.NONE);
    // ATTRIBUTE: id
    final String idRaw = relationships.id;
    if (idRaw != null) {
        String id = null;
        try {
            id = Adapters.collapsedStringAdapterAdapter.marshal(idRaw);
        } catch (final Exception e) {
            context.xmlAdapterError(relationships, "id", CollapsedStringAdapter.class, String.class, String.class, e);
        }
        writer.writeAttribute("", "", "id", id);
    }
    // ELEMENT: descriptions
    Text[] descriptions = null;
    try {
        descriptions = relationships.getDescriptions();
    } catch (final Exception e) {
        context.getterError(relationships, "descriptions", Relationships.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(relationships, "descriptions");
            }
        }
    }
    // ELEMENT: ejbRelation
    final List<EjbRelation> ejbRelation = relationships.ejbRelation;
    if (ejbRelation != null) {
        for (final EjbRelation ejbRelationItem : ejbRelation) {
            if (ejbRelationItem != null) {
                writer.writeStartElement(prefix, "ejb-relation", "http://java.sun.com/xml/ns/javaee");
                writeEjbRelation(writer, ejbRelationItem, context);
                writer.writeEndElement();
            } else {
                context.unexpectedNullValue(relationships, "ejbRelation");
            }
        }
    }
    context.afterMarshal(relationships, LifecycleCallback.NONE);
}
Also used : CollapsedStringAdapter(javax.xml.bind.annotation.adapters.CollapsedStringAdapter) EjbRelation$JAXB.writeEjbRelation(org.apache.openejb.jee.EjbRelation$JAXB.writeEjbRelation) EjbRelation$JAXB.readEjbRelation(org.apache.openejb.jee.EjbRelation$JAXB.readEjbRelation) 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)

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