use of org.apache.openejb.jee.Text$JAXB.writeText 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);
}
use of org.apache.openejb.jee.Text$JAXB.writeText 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;
}
use of org.apache.openejb.jee.Text$JAXB.writeText 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);
}
use of org.apache.openejb.jee.Text$JAXB.writeText 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;
}
use of org.apache.openejb.jee.Text$JAXB.writeText 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);
}
Aggregations