Search in sources :

Example 96 with RuntimeContext

use of org.metatype.sxc.jaxb.RuntimeContext in project tomee by apache.

the class EjbRelation$JAXB method _write.

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

Example 97 with RuntimeContext

use of org.metatype.sxc.jaxb.RuntimeContext in project tomee by apache.

the class EjbRelationshipRole$JAXB method _write.

public static final void _write(final XoXMLStreamWriter writer, final EjbRelationshipRole ejbRelationshipRole, RuntimeContext context) throws Exception {
    if (ejbRelationshipRole == null) {
        writer.writeXsiNil();
        return;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final String prefix = writer.getUniquePrefix("http://java.sun.com/xml/ns/javaee");
    if (EjbRelationshipRole.class != ejbRelationshipRole.getClass()) {
        context.unexpectedSubclass(writer, ejbRelationshipRole, EjbRelationshipRole.class);
        return;
    }
    context.beforeMarshal(ejbRelationshipRole, LifecycleCallback.NONE);
    // ATTRIBUTE: id
    final String idRaw = ejbRelationshipRole.id;
    if (idRaw != null) {
        String id = null;
        try {
            id = Adapters.collapsedStringAdapterAdapter.marshal(idRaw);
        } catch (final Exception e) {
            context.xmlAdapterError(ejbRelationshipRole, "id", CollapsedStringAdapter.class, String.class, String.class, e);
        }
        writer.writeAttribute("", "", "id", id);
    }
    // ELEMENT: descriptions
    Text[] descriptions = null;
    try {
        descriptions = ejbRelationshipRole.getDescriptions();
    } catch (final Exception e) {
        context.getterError(ejbRelationshipRole, "descriptions", EjbRelationshipRole.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(ejbRelationshipRole, "descriptions");
            }
        }
    }
    // ELEMENT: ejbRelationshipRoleName
    final String ejbRelationshipRoleNameRaw = ejbRelationshipRole.ejbRelationshipRoleName;
    String ejbRelationshipRoleName = null;
    try {
        ejbRelationshipRoleName = Adapters.collapsedStringAdapterAdapter.marshal(ejbRelationshipRoleNameRaw);
    } catch (final Exception e) {
        context.xmlAdapterError(ejbRelationshipRole, "ejbRelationshipRoleName", CollapsedStringAdapter.class, String.class, String.class, e);
    }
    if (ejbRelationshipRoleName != null) {
        writer.writeStartElement(prefix, "ejb-relationship-role-name", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(ejbRelationshipRoleName);
        writer.writeEndElement();
    }
    // ELEMENT: multiplicity
    final Multiplicity multiplicity = ejbRelationshipRole.multiplicity;
    if (multiplicity != null) {
        writer.writeStartElement(prefix, "multiplicity", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(toStringMultiplicity(ejbRelationshipRole, null, context, multiplicity));
        writer.writeEndElement();
    } else {
        context.unexpectedNullValue(ejbRelationshipRole, "multiplicity");
    }
    // ELEMENT: cascadeDelete
    final Empty cascadeDelete = ejbRelationshipRole.cascadeDelete;
    if (cascadeDelete != null) {
        writer.writeStartElement(prefix, "cascade-delete", "http://java.sun.com/xml/ns/javaee");
        writeEmpty(writer, cascadeDelete, context);
        writer.writeEndElement();
    }
    // ELEMENT: relationshipRoleSource
    final RelationshipRoleSource relationshipRoleSource = ejbRelationshipRole.relationshipRoleSource;
    if (relationshipRoleSource != null) {
        writer.writeStartElement(prefix, "relationship-role-source", "http://java.sun.com/xml/ns/javaee");
        writeRelationshipRoleSource(writer, relationshipRoleSource, context);
        writer.writeEndElement();
    } else {
        context.unexpectedNullValue(ejbRelationshipRole, "relationshipRoleSource");
    }
    // ELEMENT: cmrField
    final CmrField cmrField = ejbRelationshipRole.cmrField;
    if (cmrField != null) {
        writer.writeStartElement(prefix, "cmr-field", "http://java.sun.com/xml/ns/javaee");
        writeCmrField(writer, cmrField, context);
        writer.writeEndElement();
    }
    context.afterMarshal(ejbRelationshipRole, LifecycleCallback.NONE);
}
Also used : Empty$JAXB.writeEmpty(org.apache.openejb.jee.Empty$JAXB.writeEmpty) Empty$JAXB.readEmpty(org.apache.openejb.jee.Empty$JAXB.readEmpty) CollapsedStringAdapter(javax.xml.bind.annotation.adapters.CollapsedStringAdapter) Multiplicity$JAXB.parseMultiplicity(org.apache.openejb.jee.Multiplicity$JAXB.parseMultiplicity) Multiplicity$JAXB.toStringMultiplicity(org.apache.openejb.jee.Multiplicity$JAXB.toStringMultiplicity) CmrField$JAXB.readCmrField(org.apache.openejb.jee.CmrField$JAXB.readCmrField) CmrField$JAXB.writeCmrField(org.apache.openejb.jee.CmrField$JAXB.writeCmrField) 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) RelationshipRoleSource$JAXB.readRelationshipRoleSource(org.apache.openejb.jee.RelationshipRoleSource$JAXB.readRelationshipRoleSource) RelationshipRoleSource$JAXB.writeRelationshipRoleSource(org.apache.openejb.jee.RelationshipRoleSource$JAXB.writeRelationshipRoleSource)

Example 98 with RuntimeContext

use of org.metatype.sxc.jaxb.RuntimeContext in project tomee by apache.

the class Empty$JAXB method _read.

public static final Empty _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
    // Check for xsi:nil
    if (reader.isXsiNil()) {
        return null;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final Empty empty = new Empty();
    context.beforeUnmarshal(empty, LifecycleCallback.NONE);
    // Check xsi:type
    final QName xsiType = reader.getXsiType();
    if (xsiType != null) {
        if (("emptyType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
            return context.unexpectedXsiType(reader, Empty.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, empty);
            empty.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()) {
        context.unexpectedElement(elementReader);
    }
    context.afterUnmarshal(empty, LifecycleCallback.NONE);
    return empty;
}
Also used : Attribute(org.metatype.sxc.util.Attribute) QName(javax.xml.namespace.QName) RuntimeContext(org.metatype.sxc.jaxb.RuntimeContext) XoXMLStreamReader(org.metatype.sxc.util.XoXMLStreamReader)

Example 99 with RuntimeContext

use of org.metatype.sxc.jaxb.RuntimeContext in project tomee by apache.

the class Empty$JAXB method _write.

public static final void _write(final XoXMLStreamWriter writer, final Empty empty, RuntimeContext context) throws Exception {
    if (empty == null) {
        writer.writeXsiNil();
        return;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    if (Empty.class != empty.getClass()) {
        context.unexpectedSubclass(writer, empty, Empty.class);
        return;
    }
    context.beforeMarshal(empty, LifecycleCallback.NONE);
    // ATTRIBUTE: id
    final String idRaw = empty.id;
    if (idRaw != null) {
        String id = null;
        try {
            id = Adapters.collapsedStringAdapterAdapter.marshal(idRaw);
        } catch (final Exception e) {
            context.xmlAdapterError(empty, "id", CollapsedStringAdapter.class, String.class, String.class, e);
        }
        writer.writeAttribute("", "", "id", id);
    }
    context.afterMarshal(empty, LifecycleCallback.NONE);
}
Also used : CollapsedStringAdapter(javax.xml.bind.annotation.adapters.CollapsedStringAdapter) RuntimeContext(org.metatype.sxc.jaxb.RuntimeContext)

Example 100 with RuntimeContext

use of org.metatype.sxc.jaxb.RuntimeContext in project tomee by apache.

the class EnvEntry$JAXB method _read.

public static final EnvEntry _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
    // Check for xsi:nil
    if (reader.isXsiNil()) {
        return null;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final EnvEntry envEntry = new EnvEntry();
    context.beforeUnmarshal(envEntry, LifecycleCallback.NONE);
    ArrayList<Text> descriptions = null;
    Set<InjectionTarget> injectionTarget = null;
    // Check xsi:type
    final QName xsiType = reader.getXsiType();
    if (xsiType != null) {
        if (("env-entryType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
            return context.unexpectedXsiType(reader, EnvEntry.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, envEntry);
            envEntry.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 (("env-entry-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: envEntryName
            final String envEntryNameRaw = elementReader.getElementAsString();
            final String envEntryName;
            try {
                envEntryName = Adapters.collapsedStringAdapterAdapter.unmarshal(envEntryNameRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            envEntry.envEntryName = envEntryName;
        } else if (("env-entry-type" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: envEntryType
            final String envEntryTypeRaw = elementReader.getElementAsString();
            final String envEntryType;
            try {
                envEntryType = Adapters.collapsedStringAdapterAdapter.unmarshal(envEntryTypeRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            envEntry.envEntryType = envEntryType;
        } else if (("env-entry-value" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: envEntryValue
            // don't trim
            final String envEntryValueRaw = elementReader.getElementText();
            final String envEntryValue;
            try {
                envEntryValue = Adapters.stringAdapterAdapter.unmarshal(envEntryValueRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, StringAdapter.class, String.class, String.class, e);
                continue;
            }
            envEntry.envEntryValue = envEntryValue;
        } else if (("mapped-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: mappedName
            final String mappedNameRaw = elementReader.getElementAsString();
            final String mappedName;
            try {
                mappedName = Adapters.collapsedStringAdapterAdapter.unmarshal(mappedNameRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            envEntry.mappedName = mappedName;
        } else if (("injection-target" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: injectionTarget
            final InjectionTarget injectionTargetItem = readInjectionTarget(elementReader, context);
            if (injectionTarget == null) {
                injectionTarget = envEntry.injectionTarget;
                if (injectionTarget != null) {
                    injectionTarget.clear();
                } else {
                    injectionTarget = new LinkedHashSet<InjectionTarget>();
                }
            }
            injectionTarget.add(injectionTargetItem);
        } else if (("lookup-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: lookupName
            final String lookupNameRaw = elementReader.getElementAsString();
            final String lookupName;
            try {
                lookupName = Adapters.collapsedStringAdapterAdapter.unmarshal(lookupNameRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            envEntry.lookupName = lookupName;
        } else {
            context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "description"), new QName("http://java.sun.com/xml/ns/javaee", "env-entry-name"), new QName("http://java.sun.com/xml/ns/javaee", "env-entry-type"), new QName("http://java.sun.com/xml/ns/javaee", "env-entry-value"), new QName("http://java.sun.com/xml/ns/javaee", "mapped-name"), new QName("http://java.sun.com/xml/ns/javaee", "injection-target"), new QName("http://java.sun.com/xml/ns/javaee", "lookup-name"));
        }
    }
    if (descriptions != null) {
        try {
            envEntry.setDescriptions(descriptions.toArray(new Text[descriptions.size()]));
        } catch (final Exception e) {
            context.setterError(reader, EnvEntry.class, "setDescriptions", Text[].class, e);
        }
    }
    if (injectionTarget != null) {
        envEntry.injectionTarget = injectionTarget;
    }
    context.afterUnmarshal(envEntry, LifecycleCallback.NONE);
    return envEntry;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) CollapsedStringAdapter(javax.xml.bind.annotation.adapters.CollapsedStringAdapter) 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) InjectionTarget$JAXB.writeInjectionTarget(org.apache.openejb.jee.InjectionTarget$JAXB.writeInjectionTarget) InjectionTarget$JAXB.readInjectionTarget(org.apache.openejb.jee.InjectionTarget$JAXB.readInjectionTarget) RuntimeContext(org.metatype.sxc.jaxb.RuntimeContext) XoXMLStreamReader(org.metatype.sxc.util.XoXMLStreamReader)

Aggregations

RuntimeContext (org.metatype.sxc.jaxb.RuntimeContext)380 CollapsedStringAdapter (javax.xml.bind.annotation.adapters.CollapsedStringAdapter)300 QName (javax.xml.namespace.QName)202 Attribute (org.metatype.sxc.util.Attribute)190 XoXMLStreamReader (org.metatype.sxc.util.XoXMLStreamReader)182 Text$JAXB.readText (org.apache.openejb.jee.Text$JAXB.readText)155 Text$JAXB.writeText (org.apache.openejb.jee.Text$JAXB.writeText)154 ArrayList (java.util.ArrayList)91 Icon$JAXB.readIcon (org.apache.openejb.jee.Icon$JAXB.readIcon)74 Icon$JAXB.writeIcon (org.apache.openejb.jee.Icon$JAXB.writeIcon)74 JAXBObject (org.metatype.sxc.jaxb.JAXBObject)39 List (java.util.List)22 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