use of org.apache.openejb.jee.Text$JAXB.writeText in project tomee by apache.
the class EjbJar$JAXB method _write.
public static final void _write(final XoXMLStreamWriter writer, final EjbJar ejbJar, RuntimeContext context) throws Exception {
if (ejbJar == null) {
writer.writeXsiNil();
return;
}
if (context == null) {
context = new RuntimeContext();
}
final String prefix = writer.getUniquePrefix("http://java.sun.com/xml/ns/javaee");
if (EjbJar.class != ejbJar.getClass()) {
context.unexpectedSubclass(writer, ejbJar, EjbJar.class);
return;
}
context.beforeMarshal(ejbJar, LifecycleCallback.NONE);
// ATTRIBUTE: id
final String idRaw = ejbJar.id;
if (idRaw != null) {
String id = null;
try {
id = Adapters.collapsedStringAdapterAdapter.marshal(idRaw);
} catch (final Exception e) {
context.xmlAdapterError(ejbJar, "id", CollapsedStringAdapter.class, String.class, String.class, e);
}
writer.writeAttribute("", "", "id", id);
}
// ATTRIBUTE: metadataComplete
final Boolean metadataComplete = ejbJar.metadataComplete;
if (metadataComplete != null) {
writer.writeAttribute("", "", "metadata-complete", Boolean.toString(metadataComplete));
}
// ATTRIBUTE: version
final String versionRaw = ejbJar.version;
if (versionRaw != null) {
String version = null;
try {
version = Adapters.collapsedStringAdapterAdapter.marshal(versionRaw);
} catch (final Exception e) {
context.xmlAdapterError(ejbJar, "version", CollapsedStringAdapter.class, String.class, String.class, e);
}
writer.writeAttribute("", "", "version", version);
}
// ELEMENT: moduleName
final String moduleNameRaw = ejbJar.moduleName;
String moduleName = null;
try {
moduleName = Adapters.collapsedStringAdapterAdapter.marshal(moduleNameRaw);
} catch (final Exception e) {
context.xmlAdapterError(ejbJar, "moduleName", CollapsedStringAdapter.class, String.class, String.class, e);
}
if (moduleName != null) {
writer.writeStartElement(prefix, "module-name", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(moduleName);
writer.writeEndElement();
}
// ELEMENT: descriptions
Text[] descriptions = null;
try {
descriptions = ejbJar.getDescriptions();
} catch (final Exception e) {
context.getterError(ejbJar, "descriptions", EjbJar.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(ejbJar, "descriptions");
}
}
}
// ELEMENT: displayNames
Text[] displayNames = null;
try {
displayNames = ejbJar.getDisplayNames();
} catch (final Exception e) {
context.getterError(ejbJar, "displayNames", EjbJar.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(ejbJar, "displayNames");
}
}
}
// ELEMENT: icon
final LocalCollection<Icon> icon = ejbJar.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(ejbJar, "icon");
}
}
}
// ELEMENT: enterpriseBeans
EnterpriseBean[] enterpriseBeans = null;
try {
enterpriseBeans = ejbJar.getEnterpriseBeans();
} catch (final Exception e) {
context.getterError(ejbJar, "enterpriseBeans", EjbJar.class, "getEnterpriseBeans", e);
}
writer.writeStartElement(prefix, "enterprise-beans", "http://java.sun.com/xml/ns/javaee");
if (enterpriseBeans != null) {
for (final EnterpriseBean enterpriseBeansItem : enterpriseBeans) {
if (enterpriseBeansItem instanceof org.apache.openejb.jee.EntityBean) {
final org.apache.openejb.jee.EntityBean EntityBean = ((org.apache.openejb.jee.EntityBean) enterpriseBeansItem);
writer.writeStartElement(prefix, "entity", "http://java.sun.com/xml/ns/javaee");
writeEntityBean(writer, EntityBean, context);
writer.writeEndElement();
} else if (enterpriseBeansItem instanceof org.apache.openejb.jee.SessionBean) {
final org.apache.openejb.jee.SessionBean SessionBean = ((org.apache.openejb.jee.SessionBean) enterpriseBeansItem);
writer.writeStartElement(prefix, "session", "http://java.sun.com/xml/ns/javaee");
writeSessionBean(writer, SessionBean, context);
writer.writeEndElement();
} else if (enterpriseBeansItem instanceof org.apache.openejb.jee.MessageDrivenBean) {
final org.apache.openejb.jee.MessageDrivenBean MessageDrivenBean = ((org.apache.openejb.jee.MessageDrivenBean) enterpriseBeansItem);
writer.writeStartElement(prefix, "message-driven", "http://java.sun.com/xml/ns/javaee");
writeMessageDrivenBean(writer, MessageDrivenBean, context);
writer.writeEndElement();
} else if (enterpriseBeansItem == null) {
context.unexpectedNullValue(ejbJar, "enterpriseBeans");
} else {
context.unexpectedElementType(writer, ejbJar, "enterpriseBeans", enterpriseBeansItem, org.apache.openejb.jee.EntityBean.class, org.apache.openejb.jee.SessionBean.class, org.apache.openejb.jee.MessageDrivenBean.class);
}
}
}
writer.writeEndElement();
// ELEMENT: interceptors
final Interceptors interceptors = ejbJar.interceptors;
if (interceptors != null) {
writer.writeStartElement(prefix, "interceptors", "http://java.sun.com/xml/ns/javaee");
writeInterceptors(writer, interceptors, context);
writer.writeEndElement();
}
// ELEMENT: relationships
final Relationships relationships = ejbJar.relationships;
if (relationships != null) {
writer.writeStartElement(prefix, "relationships", "http://java.sun.com/xml/ns/javaee");
writeRelationships(writer, relationships, context);
writer.writeEndElement();
}
// ELEMENT: assemblyDescriptor
final AssemblyDescriptor assemblyDescriptor = ejbJar.assemblyDescriptor;
if (assemblyDescriptor != null) {
writer.writeStartElement(prefix, "assembly-descriptor", "http://java.sun.com/xml/ns/javaee");
writeAssemblyDescriptor(writer, assemblyDescriptor, context);
writer.writeEndElement();
}
// ELEMENT: ejbClientJar
final String ejbClientJarRaw = ejbJar.ejbClientJar;
String ejbClientJar = null;
try {
ejbClientJar = Adapters.collapsedStringAdapterAdapter.marshal(ejbClientJarRaw);
} catch (final Exception e) {
context.xmlAdapterError(ejbJar, "ejbClientJar", CollapsedStringAdapter.class, String.class, String.class, e);
}
if (ejbClientJar != null) {
writer.writeStartElement(prefix, "ejb-client-jar", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(ejbClientJar);
writer.writeEndElement();
}
context.afterMarshal(ejbJar, LifecycleCallback.NONE);
}
use of org.apache.openejb.jee.Text$JAXB.writeText in project tomee by apache.
the class EjbLocalRef$JAXB method _read.
public static final EjbLocalRef _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
// Check for xsi:nil
if (reader.isXsiNil()) {
return null;
}
if (context == null) {
context = new RuntimeContext();
}
final EjbLocalRef ejbLocalRef = new EjbLocalRef();
context.beforeUnmarshal(ejbLocalRef, LifecycleCallback.NONE);
ArrayList<Text> descriptions = null;
Set<InjectionTarget> injectionTarget = null;
// Check xsi:type
final QName xsiType = reader.getXsiType();
if (xsiType != null) {
if (("ejb-local-refType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
return context.unexpectedXsiType(reader, EjbLocalRef.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, ejbLocalRef);
ejbLocalRef.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-ref-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: ejbRefName
final String ejbRefNameRaw = elementReader.getElementAsString();
final String ejbRefName;
try {
ejbRefName = Adapters.collapsedStringAdapterAdapter.unmarshal(ejbRefNameRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
ejbLocalRef.ejbRefName = ejbRefName;
} else if (("ejb-ref-type" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: ejbRefType
final EjbRefType ejbRefType = parseEjbRefType(elementReader, context, elementReader.getElementAsString());
if (ejbRefType != null) {
ejbLocalRef.ejbRefType = ejbRefType;
}
} else if (("local-home" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: localHome
final String localHomeRaw = elementReader.getElementAsString();
final String localHome;
try {
localHome = Adapters.collapsedStringAdapterAdapter.unmarshal(localHomeRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
ejbLocalRef.localHome = localHome;
} else if (("local" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: local
final String localRaw = elementReader.getElementAsString();
final String local;
try {
local = Adapters.collapsedStringAdapterAdapter.unmarshal(localRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
ejbLocalRef.local = local;
} else if (("ejb-link" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: ejbLink
final String ejbLinkRaw = elementReader.getElementAsString();
final String ejbLink;
try {
ejbLink = Adapters.collapsedStringAdapterAdapter.unmarshal(ejbLinkRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
ejbLocalRef.ejbLink = ejbLink;
} 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;
}
ejbLocalRef.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 = ejbLocalRef.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;
}
ejbLocalRef.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", "ejb-ref-name"), new QName("http://java.sun.com/xml/ns/javaee", "ejb-ref-type"), new QName("http://java.sun.com/xml/ns/javaee", "local-home"), new QName("http://java.sun.com/xml/ns/javaee", "local"), new QName("http://java.sun.com/xml/ns/javaee", "ejb-link"), 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 {
ejbLocalRef.setDescriptions(descriptions.toArray(new Text[descriptions.size()]));
} catch (final Exception e) {
context.setterError(reader, EjbLocalRef.class, "setDescriptions", Text[].class, e);
}
}
if (injectionTarget != null) {
ejbLocalRef.injectionTarget = injectionTarget;
}
context.afterUnmarshal(ejbLocalRef, LifecycleCallback.NONE);
return ejbLocalRef;
}
use of org.apache.openejb.jee.Text$JAXB.writeText in project tomee by apache.
the class EjbRef$JAXB method _read.
public static final EjbRef _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
// Check for xsi:nil
if (reader.isXsiNil()) {
return null;
}
if (context == null) {
context = new RuntimeContext();
}
final EjbRef ejbRef = new EjbRef();
context.beforeUnmarshal(ejbRef, LifecycleCallback.NONE);
ArrayList<Text> descriptions = null;
Set<InjectionTarget> injectionTarget = null;
// Check xsi:type
final QName xsiType = reader.getXsiType();
if (xsiType != null) {
if (("ejb-refType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
return context.unexpectedXsiType(reader, EjbRef.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, ejbRef);
ejbRef.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-ref-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: ejbRefName
final String ejbRefNameRaw = elementReader.getElementAsString();
final String ejbRefName;
try {
ejbRefName = Adapters.collapsedStringAdapterAdapter.unmarshal(ejbRefNameRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
ejbRef.ejbRefName = ejbRefName;
} else if (("ejb-ref-type" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: ejbRefType
final EjbRefType ejbRefType = parseEjbRefType(elementReader, context, elementReader.getElementAsString());
if (ejbRefType != null) {
ejbRef.ejbRefType = ejbRefType;
}
} else if (("home" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: home
final String homeRaw = elementReader.getElementAsString();
final String home;
try {
home = Adapters.collapsedStringAdapterAdapter.unmarshal(homeRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
ejbRef.home = home;
} else if (("remote" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: remote
final String remoteRaw = elementReader.getElementAsString();
final String remote;
try {
remote = Adapters.collapsedStringAdapterAdapter.unmarshal(remoteRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
ejbRef.remote = remote;
} else if (("ejb-link" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: ejbLink
final String ejbLinkRaw = elementReader.getElementAsString();
final String ejbLink;
try {
ejbLink = Adapters.collapsedStringAdapterAdapter.unmarshal(ejbLinkRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
ejbRef.ejbLink = ejbLink;
} 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;
}
ejbRef.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 = ejbRef.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;
}
ejbRef.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", "ejb-ref-name"), new QName("http://java.sun.com/xml/ns/javaee", "ejb-ref-type"), new QName("http://java.sun.com/xml/ns/javaee", "home"), new QName("http://java.sun.com/xml/ns/javaee", "remote"), new QName("http://java.sun.com/xml/ns/javaee", "ejb-link"), 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 {
ejbRef.setDescriptions(descriptions.toArray(new Text[descriptions.size()]));
} catch (final Exception e) {
context.setterError(reader, EjbRef.class, "setDescriptions", Text[].class, e);
}
}
if (injectionTarget != null) {
ejbRef.injectionTarget = injectionTarget;
}
context.afterUnmarshal(ejbRef, LifecycleCallback.NONE);
return ejbRef;
}
use of org.apache.openejb.jee.Text$JAXB.writeText in project tomee by apache.
the class EjbRelation$JAXB method _read.
public static final EjbRelation _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
// Check for xsi:nil
if (reader.isXsiNil()) {
return null;
}
if (context == null) {
context = new RuntimeContext();
}
final EjbRelation ejbRelation = new EjbRelation();
context.beforeUnmarshal(ejbRelation, LifecycleCallback.NONE);
ArrayList<Text> descriptions = null;
List<EjbRelationshipRole> ejbRelationshipRole = null;
// Check xsi:type
final QName xsiType = reader.getXsiType();
if (xsiType != null) {
if (("ejb-relationType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
return context.unexpectedXsiType(reader, EjbRelation.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, ejbRelation);
ejbRelation.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-relation-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: ejbRelationName
final String ejbRelationNameRaw = elementReader.getElementAsString();
final String ejbRelationName;
try {
ejbRelationName = Adapters.collapsedStringAdapterAdapter.unmarshal(ejbRelationNameRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
ejbRelation.ejbRelationName = ejbRelationName;
} else if (("ejb-relationship-role" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: ejbRelationshipRole
final EjbRelationshipRole ejbRelationshipRoleItem = readEjbRelationshipRole(elementReader, context);
if (ejbRelationshipRole == null) {
ejbRelationshipRole = ejbRelation.ejbRelationshipRole;
if (ejbRelationshipRole != null) {
ejbRelationshipRole.clear();
} else {
ejbRelationshipRole = new ArrayList<EjbRelationshipRole>();
}
}
ejbRelationshipRole.add(ejbRelationshipRoleItem);
} else {
context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "description"), new QName("http://java.sun.com/xml/ns/javaee", "ejb-relation-name"), new QName("http://java.sun.com/xml/ns/javaee", "ejb-relationship-role"));
}
}
if (descriptions != null) {
try {
ejbRelation.setDescriptions(descriptions.toArray(new Text[descriptions.size()]));
} catch (final Exception e) {
context.setterError(reader, EjbRelation.class, "setDescriptions", Text[].class, e);
}
}
if (ejbRelationshipRole != null) {
ejbRelation.ejbRelationshipRole = ejbRelationshipRole;
}
context.afterUnmarshal(ejbRelation, LifecycleCallback.NONE);
return ejbRelation;
}
use of org.apache.openejb.jee.Text$JAXB.writeText in project tomee by apache.
the class EjbRelationshipRole$JAXB method _read.
public static final EjbRelationshipRole _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
// Check for xsi:nil
if (reader.isXsiNil()) {
return null;
}
if (context == null) {
context = new RuntimeContext();
}
final EjbRelationshipRole ejbRelationshipRole = new EjbRelationshipRole();
context.beforeUnmarshal(ejbRelationshipRole, LifecycleCallback.NONE);
ArrayList<Text> descriptions = null;
// Check xsi:type
final QName xsiType = reader.getXsiType();
if (xsiType != null) {
if (("ejb-relationship-roleType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
return context.unexpectedXsiType(reader, EjbRelationshipRole.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, ejbRelationshipRole);
ejbRelationshipRole.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-relationship-role-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: ejbRelationshipRoleName
final String ejbRelationshipRoleNameRaw = elementReader.getElementAsString();
final String ejbRelationshipRoleName;
try {
ejbRelationshipRoleName = Adapters.collapsedStringAdapterAdapter.unmarshal(ejbRelationshipRoleNameRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
ejbRelationshipRole.ejbRelationshipRoleName = ejbRelationshipRoleName;
} else if (("multiplicity" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: multiplicity
final Multiplicity multiplicity = parseMultiplicity(elementReader, context, elementReader.getElementAsString());
if (multiplicity != null) {
ejbRelationshipRole.multiplicity = multiplicity;
}
} else if (("cascade-delete" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: cascadeDelete
final Empty cascadeDelete = readEmpty(elementReader, context);
ejbRelationshipRole.cascadeDelete = cascadeDelete;
} else if (("relationship-role-source" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: relationshipRoleSource
final RelationshipRoleSource relationshipRoleSource = readRelationshipRoleSource(elementReader, context);
ejbRelationshipRole.relationshipRoleSource = relationshipRoleSource;
} else if (("cmr-field" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: cmrField
final CmrField cmrField = readCmrField(elementReader, context);
ejbRelationshipRole.cmrField = cmrField;
} else {
context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "description"), new QName("http://java.sun.com/xml/ns/javaee", "ejb-relationship-role-name"), new QName("http://java.sun.com/xml/ns/javaee", "multiplicity"), new QName("http://java.sun.com/xml/ns/javaee", "cascade-delete"), new QName("http://java.sun.com/xml/ns/javaee", "relationship-role-source"), new QName("http://java.sun.com/xml/ns/javaee", "cmr-field"));
}
}
if (descriptions != null) {
try {
ejbRelationshipRole.setDescriptions(descriptions.toArray(new Text[descriptions.size()]));
} catch (final Exception e) {
context.setterError(reader, EjbRelationshipRole.class, "setDescriptions", Text[].class, e);
}
}
context.afterUnmarshal(ejbRelationshipRole, LifecycleCallback.NONE);
return ejbRelationshipRole;
}
Aggregations