use of org.apache.openejb.jee.Text$JAXB.readText in project tomee by apache.
the class Relationships$JAXB method _read.
public static final Relationships _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
// Check for xsi:nil
if (reader.isXsiNil()) {
return null;
}
if (context == null) {
context = new RuntimeContext();
}
final Relationships relationships = new Relationships();
context.beforeUnmarshal(relationships, LifecycleCallback.NONE);
ArrayList<Text> descriptions = null;
List<EjbRelation> ejbRelation = null;
// Check xsi:type
final QName xsiType = reader.getXsiType();
if (xsiType != null) {
if (("relationshipsType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
return context.unexpectedXsiType(reader, Relationships.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, relationships);
relationships.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" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: ejbRelation
final EjbRelation ejbRelationItem = readEjbRelation(elementReader, context);
if (ejbRelation == null) {
ejbRelation = relationships.ejbRelation;
if (ejbRelation != null) {
ejbRelation.clear();
} else {
ejbRelation = new ArrayList<EjbRelation>();
}
}
ejbRelation.add(ejbRelationItem);
} 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"));
}
}
if (descriptions != null) {
try {
relationships.setDescriptions(descriptions.toArray(new Text[descriptions.size()]));
} catch (final Exception e) {
context.setterError(reader, Relationships.class, "setDescriptions", Text[].class, e);
}
}
if (ejbRelation != null) {
relationships.ejbRelation = ejbRelation;
}
context.afterUnmarshal(relationships, LifecycleCallback.NONE);
return relationships;
}
use of org.apache.openejb.jee.Text$JAXB.readText in project tomee by apache.
the class RequiredConfigProperty$JAXB method _read.
public static final RequiredConfigProperty _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
// Check for xsi:nil
if (reader.isXsiNil()) {
return null;
}
if (context == null) {
context = new RuntimeContext();
}
final RequiredConfigProperty requiredConfigProperty = new RequiredConfigProperty();
context.beforeUnmarshal(requiredConfigProperty, LifecycleCallback.NONE);
ArrayList<Text> descriptions = null;
// Check xsi:type
final QName xsiType = reader.getXsiType();
if (xsiType != null) {
if (("required-config-propertyType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
return context.unexpectedXsiType(reader, RequiredConfigProperty.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, requiredConfigProperty);
requiredConfigProperty.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 (("config-property-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: configPropertyName
final String configPropertyNameRaw = elementReader.getElementAsString();
final String configPropertyName;
try {
configPropertyName = Adapters.collapsedStringAdapterAdapter.unmarshal(configPropertyNameRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
requiredConfigProperty.configPropertyName = configPropertyName;
} else {
context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "description"), new QName("http://java.sun.com/xml/ns/javaee", "config-property-name"));
}
}
if (descriptions != null) {
try {
requiredConfigProperty.setDescriptions(descriptions.toArray(new Text[descriptions.size()]));
} catch (final Exception e) {
context.setterError(reader, RequiredConfigProperty.class, "setDescriptions", Text[].class, e);
}
}
context.afterUnmarshal(requiredConfigProperty, LifecycleCallback.NONE);
return requiredConfigProperty;
}
use of org.apache.openejb.jee.Text$JAXB.readText in project tomee by apache.
the class ResourceEnvRef$JAXB method _write.
public static final void _write(final XoXMLStreamWriter writer, final ResourceEnvRef resourceEnvRef, RuntimeContext context) throws Exception {
if (resourceEnvRef == null) {
writer.writeXsiNil();
return;
}
if (context == null) {
context = new RuntimeContext();
}
final String prefix = writer.getUniquePrefix("http://java.sun.com/xml/ns/javaee");
if (ResourceEnvRef.class != resourceEnvRef.getClass()) {
context.unexpectedSubclass(writer, resourceEnvRef, ResourceEnvRef.class);
return;
}
context.beforeMarshal(resourceEnvRef, LifecycleCallback.NONE);
// ATTRIBUTE: id
final String idRaw = resourceEnvRef.id;
if (idRaw != null) {
String id = null;
try {
id = Adapters.collapsedStringAdapterAdapter.marshal(idRaw);
} catch (final Exception e) {
context.xmlAdapterError(resourceEnvRef, "id", CollapsedStringAdapter.class, String.class, String.class, e);
}
writer.writeAttribute("", "", "id", id);
}
// ELEMENT: descriptions
Text[] descriptions = null;
try {
descriptions = resourceEnvRef.getDescriptions();
} catch (final Exception e) {
context.getterError(resourceEnvRef, "descriptions", ResourceEnvRef.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(resourceEnvRef, "descriptions");
}
}
}
// ELEMENT: resourceEnvRefName
final String resourceEnvRefNameRaw = resourceEnvRef.resourceEnvRefName;
String resourceEnvRefName = null;
try {
resourceEnvRefName = Adapters.collapsedStringAdapterAdapter.marshal(resourceEnvRefNameRaw);
} catch (final Exception e) {
context.xmlAdapterError(resourceEnvRef, "resourceEnvRefName", CollapsedStringAdapter.class, String.class, String.class, e);
}
if (resourceEnvRefName != null) {
writer.writeStartElement(prefix, "resource-env-ref-name", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(resourceEnvRefName);
writer.writeEndElement();
} else {
context.unexpectedNullValue(resourceEnvRef, "resourceEnvRefName");
}
// ELEMENT: resourceEnvRefType
final String resourceEnvRefTypeRaw = resourceEnvRef.resourceEnvRefType;
String resourceEnvRefType = null;
try {
resourceEnvRefType = Adapters.collapsedStringAdapterAdapter.marshal(resourceEnvRefTypeRaw);
} catch (final Exception e) {
context.xmlAdapterError(resourceEnvRef, "resourceEnvRefType", CollapsedStringAdapter.class, String.class, String.class, e);
}
if (resourceEnvRefType != null) {
writer.writeStartElement(prefix, "resource-env-ref-type", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(resourceEnvRefType);
writer.writeEndElement();
}
// ELEMENT: mappedName
final String mappedNameRaw = resourceEnvRef.mappedName;
String mappedName = null;
try {
mappedName = Adapters.collapsedStringAdapterAdapter.marshal(mappedNameRaw);
} catch (final Exception e) {
context.xmlAdapterError(resourceEnvRef, "mappedName", CollapsedStringAdapter.class, String.class, String.class, e);
}
if (mappedName != null) {
writer.writeStartElement(prefix, "mapped-name", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(mappedName);
writer.writeEndElement();
}
// ELEMENT: injectionTarget
final Set<InjectionTarget> injectionTarget = resourceEnvRef.injectionTarget;
if (injectionTarget != null) {
for (final InjectionTarget injectionTargetItem : injectionTarget) {
if (injectionTargetItem != null) {
writer.writeStartElement(prefix, "injection-target", "http://java.sun.com/xml/ns/javaee");
writeInjectionTarget(writer, injectionTargetItem, context);
writer.writeEndElement();
} else {
context.unexpectedNullValue(resourceEnvRef, "injectionTarget");
}
}
}
// ELEMENT: lookupName
final String lookupNameRaw = resourceEnvRef.lookupName;
String lookupName = null;
try {
lookupName = Adapters.collapsedStringAdapterAdapter.marshal(lookupNameRaw);
} catch (final Exception e) {
context.xmlAdapterError(resourceEnvRef, "lookupName", CollapsedStringAdapter.class, String.class, String.class, e);
}
if (lookupName != null) {
writer.writeStartElement(prefix, "lookup-name", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(lookupName);
writer.writeEndElement();
}
context.afterMarshal(resourceEnvRef, LifecycleCallback.NONE);
}
use of org.apache.openejb.jee.Text$JAXB.readText in project tomee by apache.
the class ResourceRef$JAXB method _write.
public static final void _write(final XoXMLStreamWriter writer, final ResourceRef resourceRef, RuntimeContext context) throws Exception {
if (resourceRef == null) {
writer.writeXsiNil();
return;
}
if (context == null) {
context = new RuntimeContext();
}
final String prefix = writer.getUniquePrefix("http://java.sun.com/xml/ns/javaee");
if (ResourceRef.class != resourceRef.getClass()) {
context.unexpectedSubclass(writer, resourceRef, ResourceRef.class);
return;
}
context.beforeMarshal(resourceRef, LifecycleCallback.NONE);
// ATTRIBUTE: id
final String idRaw = resourceRef.id;
if (idRaw != null) {
String id = null;
try {
id = Adapters.collapsedStringAdapterAdapter.marshal(idRaw);
} catch (final Exception e) {
context.xmlAdapterError(resourceRef, "id", CollapsedStringAdapter.class, String.class, String.class, e);
}
writer.writeAttribute("", "", "id", id);
}
// ELEMENT: descriptions
Text[] descriptions = null;
try {
descriptions = resourceRef.getDescriptions();
} catch (final Exception e) {
context.getterError(resourceRef, "descriptions", ResourceRef.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(resourceRef, "descriptions");
}
}
}
// ELEMENT: resRefName
final String resRefNameRaw = resourceRef.resRefName;
String resRefName = null;
try {
resRefName = Adapters.collapsedStringAdapterAdapter.marshal(resRefNameRaw);
} catch (final Exception e) {
context.xmlAdapterError(resourceRef, "resRefName", CollapsedStringAdapter.class, String.class, String.class, e);
}
if (resRefName != null) {
writer.writeStartElement(prefix, "res-ref-name", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(resRefName);
writer.writeEndElement();
} else {
context.unexpectedNullValue(resourceRef, "resRefName");
}
// ELEMENT: resType
final String resTypeRaw = resourceRef.resType;
String resType = null;
try {
resType = Adapters.collapsedStringAdapterAdapter.marshal(resTypeRaw);
} catch (final Exception e) {
context.xmlAdapterError(resourceRef, "resType", CollapsedStringAdapter.class, String.class, String.class, e);
}
if (resType != null) {
writer.writeStartElement(prefix, "res-type", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(resType);
writer.writeEndElement();
}
// ELEMENT: resAuth
final ResAuth resAuth = resourceRef.resAuth;
if (resAuth != null) {
writer.writeStartElement(prefix, "res-auth", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(toStringResAuth(resourceRef, null, context, resAuth));
writer.writeEndElement();
}
// ELEMENT: resSharingScope
final ResSharingScope resSharingScope = resourceRef.resSharingScope;
if (resSharingScope != null) {
writer.writeStartElement(prefix, "res-sharing-scope", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(toStringResSharingScope(resourceRef, null, context, resSharingScope));
writer.writeEndElement();
}
// ELEMENT: mappedName
final String mappedNameRaw = resourceRef.mappedName;
String mappedName = null;
try {
mappedName = Adapters.collapsedStringAdapterAdapter.marshal(mappedNameRaw);
} catch (final Exception e) {
context.xmlAdapterError(resourceRef, "mappedName", CollapsedStringAdapter.class, String.class, String.class, e);
}
if (mappedName != null) {
writer.writeStartElement(prefix, "mapped-name", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(mappedName);
writer.writeEndElement();
}
// ELEMENT: injectionTarget
final Set<InjectionTarget> injectionTarget = resourceRef.injectionTarget;
if (injectionTarget != null) {
for (final InjectionTarget injectionTargetItem : injectionTarget) {
if (injectionTargetItem != null) {
writer.writeStartElement(prefix, "injection-target", "http://java.sun.com/xml/ns/javaee");
writeInjectionTarget(writer, injectionTargetItem, context);
writer.writeEndElement();
} else {
context.unexpectedNullValue(resourceRef, "injectionTarget");
}
}
}
// ELEMENT: lookupName
final String lookupNameRaw = resourceRef.lookupName;
String lookupName = null;
try {
lookupName = Adapters.collapsedStringAdapterAdapter.marshal(lookupNameRaw);
} catch (final Exception e) {
context.xmlAdapterError(resourceRef, "lookupName", CollapsedStringAdapter.class, String.class, String.class, e);
}
if (lookupName != null) {
writer.writeStartElement(prefix, "lookup-name", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(lookupName);
writer.writeEndElement();
}
context.afterMarshal(resourceRef, LifecycleCallback.NONE);
}
use of org.apache.openejb.jee.Text$JAXB.readText in project tomee by apache.
the class RunAs$JAXB method _write.
public static final void _write(final XoXMLStreamWriter writer, final RunAs runAs, RuntimeContext context) throws Exception {
if (runAs == null) {
writer.writeXsiNil();
return;
}
if (context == null) {
context = new RuntimeContext();
}
final String prefix = writer.getUniquePrefix("http://java.sun.com/xml/ns/javaee");
if (RunAs.class != runAs.getClass()) {
context.unexpectedSubclass(writer, runAs, RunAs.class);
return;
}
context.beforeMarshal(runAs, LifecycleCallback.NONE);
// ATTRIBUTE: id
final String idRaw = runAs.id;
if (idRaw != null) {
String id = null;
try {
id = Adapters.collapsedStringAdapterAdapter.marshal(idRaw);
} catch (final Exception e) {
context.xmlAdapterError(runAs, "id", CollapsedStringAdapter.class, String.class, String.class, e);
}
writer.writeAttribute("", "", "id", id);
}
// ELEMENT: descriptions
Text[] descriptions = null;
try {
descriptions = runAs.getDescriptions();
} catch (final Exception e) {
context.getterError(runAs, "descriptions", RunAs.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(runAs, "descriptions");
}
}
}
// ELEMENT: roleName
final String roleNameRaw = runAs.roleName;
String roleName = null;
try {
roleName = Adapters.collapsedStringAdapterAdapter.marshal(roleNameRaw);
} catch (final Exception e) {
context.xmlAdapterError(runAs, "roleName", CollapsedStringAdapter.class, String.class, String.class, e);
}
if (roleName != null) {
writer.writeStartElement(prefix, "role-name", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(roleName);
writer.writeEndElement();
} else {
context.unexpectedNullValue(runAs, "roleName");
}
context.afterMarshal(runAs, LifecycleCallback.NONE);
}
Aggregations