use of org.metatype.sxc.jaxb.RuntimeContext in project tomee by apache.
the class JavaXmlTypeMapping$JAXB method _read.
public static final JavaXmlTypeMapping _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
// Check for xsi:nil
if (reader.isXsiNil()) {
return null;
}
if (context == null) {
context = new RuntimeContext();
}
final JavaXmlTypeMapping javaXmlTypeMapping = new JavaXmlTypeMapping();
context.beforeUnmarshal(javaXmlTypeMapping, LifecycleCallback.NONE);
List<VariableMapping> variableMapping = null;
// Check xsi:type
final QName xsiType = reader.getXsiType();
if (xsiType != null) {
if (("java-xml-type-mappingType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
return context.unexpectedXsiType(reader, JavaXmlTypeMapping.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, javaXmlTypeMapping);
javaXmlTypeMapping.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 (("java-type" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: javaType
final String javaTypeRaw = elementReader.getElementAsString();
final String javaType;
try {
javaType = Adapters.collapsedStringAdapterAdapter.unmarshal(javaTypeRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
javaXmlTypeMapping.javaType = javaType;
} else if (("root-type-qname" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: rootTypeQname
final QName rootTypeQname = elementReader.getElementAsQName();
javaXmlTypeMapping.rootTypeQname = rootTypeQname;
} else if (("anonymous-type-qname" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: anonymousTypeQname
final String anonymousTypeQnameRaw = elementReader.getElementAsString();
final String anonymousTypeQname;
try {
anonymousTypeQname = Adapters.collapsedStringAdapterAdapter.unmarshal(anonymousTypeQnameRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
javaXmlTypeMapping.anonymousTypeQname = anonymousTypeQname;
} else if (("qname-scope" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: qnameScope
final String qnameScopeRaw = elementReader.getElementAsString();
final String qnameScope;
try {
qnameScope = Adapters.collapsedStringAdapterAdapter.unmarshal(qnameScopeRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
javaXmlTypeMapping.qnameScope = qnameScope;
} else if (("variable-mapping" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: variableMapping
final VariableMapping variableMappingItem = readVariableMapping(elementReader, context);
if (variableMapping == null) {
variableMapping = javaXmlTypeMapping.variableMapping;
if (variableMapping != null) {
variableMapping.clear();
} else {
variableMapping = new ArrayList<VariableMapping>();
}
}
variableMapping.add(variableMappingItem);
} else {
context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "java-type"), new QName("http://java.sun.com/xml/ns/javaee", "root-type-qname"), new QName("http://java.sun.com/xml/ns/javaee", "anonymous-type-qname"), new QName("http://java.sun.com/xml/ns/javaee", "qname-scope"), new QName("http://java.sun.com/xml/ns/javaee", "variable-mapping"));
}
}
if (variableMapping != null) {
javaXmlTypeMapping.variableMapping = variableMapping;
}
context.afterUnmarshal(javaXmlTypeMapping, LifecycleCallback.NONE);
return javaXmlTypeMapping;
}
use of org.metatype.sxc.jaxb.RuntimeContext in project tomee by apache.
the class JspConfig$JAXB method _read.
public static final JspConfig _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
// Check for xsi:nil
if (reader.isXsiNil()) {
return null;
}
if (context == null) {
context = new RuntimeContext();
}
final JspConfig jspConfig = new JspConfig();
context.beforeUnmarshal(jspConfig, LifecycleCallback.NONE);
List<Taglib> taglib = null;
List<JspPropertyGroup> jspPropertyGroup = null;
// Check xsi:type
final QName xsiType = reader.getXsiType();
if (xsiType != null) {
if (("jsp-configType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
return context.unexpectedXsiType(reader, JspConfig.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, jspConfig);
jspConfig.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 (("taglib" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: taglib
final Taglib taglibItem = readTaglib(elementReader, context);
if (taglib == null) {
taglib = jspConfig.taglib;
if (taglib != null) {
taglib.clear();
} else {
taglib = new ArrayList<Taglib>();
}
}
taglib.add(taglibItem);
} else if (("jsp-property-group" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: jspPropertyGroup
final JspPropertyGroup jspPropertyGroupItem = readJspPropertyGroup(elementReader, context);
if (jspPropertyGroup == null) {
jspPropertyGroup = jspConfig.jspPropertyGroup;
if (jspPropertyGroup != null) {
jspPropertyGroup.clear();
} else {
jspPropertyGroup = new ArrayList<JspPropertyGroup>();
}
}
jspPropertyGroup.add(jspPropertyGroupItem);
} else {
context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "taglib"), new QName("http://java.sun.com/xml/ns/javaee", "jsp-property-group"));
}
}
if (taglib != null) {
jspConfig.taglib = taglib;
}
if (jspPropertyGroup != null) {
jspConfig.jspPropertyGroup = jspPropertyGroup;
}
context.afterUnmarshal(jspConfig, LifecycleCallback.NONE);
return jspConfig;
}
use of org.metatype.sxc.jaxb.RuntimeContext in project tomee by apache.
the class LifecycleCallback$JAXB method _write.
public static final void _write(final XoXMLStreamWriter writer, final org.apache.openejb.jee.LifecycleCallback lifecycleCallback, RuntimeContext context) throws Exception {
if (lifecycleCallback == null) {
writer.writeXsiNil();
return;
}
if (context == null) {
context = new RuntimeContext();
}
final String prefix = writer.getUniquePrefix("http://java.sun.com/xml/ns/javaee");
if (org.apache.openejb.jee.LifecycleCallback.class != lifecycleCallback.getClass()) {
context.unexpectedSubclass(writer, lifecycleCallback, org.apache.openejb.jee.LifecycleCallback.class);
return;
}
context.beforeMarshal(lifecycleCallback, org.metatype.sxc.jaxb.LifecycleCallback.NONE);
// ELEMENT: lifecycleCallbackClass
final String lifecycleCallbackClassRaw = lifecycleCallback.lifecycleCallbackClass;
String lifecycleCallbackClass = null;
try {
lifecycleCallbackClass = Adapters.collapsedStringAdapterAdapter.marshal(lifecycleCallbackClassRaw);
} catch (final Exception e) {
context.xmlAdapterError(lifecycleCallback, "lifecycleCallbackClass", CollapsedStringAdapter.class, String.class, String.class, e);
}
if (lifecycleCallbackClass != null) {
writer.writeStartElement(prefix, "lifecycle-callback-class", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(lifecycleCallbackClass);
writer.writeEndElement();
}
// ELEMENT: lifecycleCallbackMethod
final String lifecycleCallbackMethodRaw = lifecycleCallback.lifecycleCallbackMethod;
String lifecycleCallbackMethod = null;
try {
lifecycleCallbackMethod = Adapters.collapsedStringAdapterAdapter.marshal(lifecycleCallbackMethodRaw);
} catch (final Exception e) {
context.xmlAdapterError(lifecycleCallback, "lifecycleCallbackMethod", CollapsedStringAdapter.class, String.class, String.class, e);
}
if (lifecycleCallbackMethod != null) {
writer.writeStartElement(prefix, "lifecycle-callback-method", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(lifecycleCallbackMethod);
writer.writeEndElement();
} else {
context.unexpectedNullValue(lifecycleCallback, "lifecycleCallbackMethod");
}
context.afterMarshal(lifecycleCallback, org.metatype.sxc.jaxb.LifecycleCallback.NONE);
}
use of org.metatype.sxc.jaxb.RuntimeContext in project tomee by apache.
the class Listener$JAXB method _write.
public static final void _write(final XoXMLStreamWriter writer, final Listener listener, RuntimeContext context) throws Exception {
if (listener == null) {
writer.writeXsiNil();
return;
}
if (context == null) {
context = new RuntimeContext();
}
final String prefix = writer.getUniquePrefix("http://java.sun.com/xml/ns/javaee");
if (Listener.class != listener.getClass()) {
context.unexpectedSubclass(writer, listener, Listener.class);
return;
}
context.beforeMarshal(listener, LifecycleCallback.NONE);
// ATTRIBUTE: id
final String idRaw = listener.id;
if (idRaw != null) {
String id = null;
try {
id = Adapters.collapsedStringAdapterAdapter.marshal(idRaw);
} catch (final Exception e) {
context.xmlAdapterError(listener, "id", CollapsedStringAdapter.class, String.class, String.class, e);
}
writer.writeAttribute("", "", "id", id);
}
// ELEMENT: descriptions
Text[] descriptions = null;
try {
descriptions = listener.getDescriptions();
} catch (final Exception e) {
context.getterError(listener, "descriptions", Listener.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(listener, "descriptions");
}
}
}
// ELEMENT: displayNames
Text[] displayNames = null;
try {
displayNames = listener.getDisplayNames();
} catch (final Exception e) {
context.getterError(listener, "displayNames", Listener.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(listener, "displayNames");
}
}
}
// ELEMENT: icon
final LocalCollection<Icon> icon = listener.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(listener, "icon");
}
}
}
// ELEMENT: listenerClass
final String listenerClassRaw = listener.listenerClass;
String listenerClass = null;
try {
listenerClass = Adapters.collapsedStringAdapterAdapter.marshal(listenerClassRaw);
} catch (final Exception e) {
context.xmlAdapterError(listener, "listenerClass", CollapsedStringAdapter.class, String.class, String.class, e);
}
if (listenerClass != null) {
writer.writeStartElement(prefix, "listener-class", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(listenerClass);
writer.writeEndElement();
} else {
context.unexpectedNullValue(listener, "listenerClass");
}
context.afterMarshal(listener, LifecycleCallback.NONE);
}
use of org.metatype.sxc.jaxb.RuntimeContext in project tomee by apache.
the class Listener$JAXB method _read.
public static final Listener _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
// Check for xsi:nil
if (reader.isXsiNil()) {
return null;
}
if (context == null) {
context = new RuntimeContext();
}
final Listener listener = new Listener();
context.beforeUnmarshal(listener, LifecycleCallback.NONE);
ArrayList<Text> descriptions = null;
ArrayList<Text> displayNames = null;
LocalCollection<Icon> icon = null;
// Check xsi:type
final QName xsiType = reader.getXsiType();
if (xsiType != null) {
if (("listenerType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
return context.unexpectedXsiType(reader, Listener.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, listener);
listener.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 (("display-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: displayNames
final Text displayNamesItem = readText(elementReader, context);
if (displayNames == null) {
displayNames = new ArrayList<Text>();
}
displayNames.add(displayNamesItem);
} else if (("icon" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: icon
final Icon iconItem = readIcon(elementReader, context);
if (icon == null) {
icon = listener.icon;
if (icon != null) {
icon.clear();
} else {
icon = new LocalCollection<Icon>();
}
}
icon.add(iconItem);
} else if (("listener-class" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: listenerClass
final String listenerClassRaw = elementReader.getElementAsString();
final String listenerClass;
try {
listenerClass = Adapters.collapsedStringAdapterAdapter.unmarshal(listenerClassRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
listener.listenerClass = listenerClass;
} else {
context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "description"), new QName("http://java.sun.com/xml/ns/javaee", "display-name"), new QName("http://java.sun.com/xml/ns/javaee", "icon"), new QName("http://java.sun.com/xml/ns/javaee", "listener-class"));
}
}
if (descriptions != null) {
try {
listener.setDescriptions(descriptions.toArray(new Text[descriptions.size()]));
} catch (final Exception e) {
context.setterError(reader, Listener.class, "setDescriptions", Text[].class, e);
}
}
if (displayNames != null) {
try {
listener.setDisplayNames(displayNames.toArray(new Text[displayNames.size()]));
} catch (final Exception e) {
context.setterError(reader, Listener.class, "setDisplayNames", Text[].class, e);
}
}
if (icon != null) {
listener.icon = icon;
}
context.afterUnmarshal(listener, LifecycleCallback.NONE);
return listener;
}
Aggregations