use of org.metatype.sxc.jaxb.RuntimeContext in project tomee by apache.
the class Handler$JAXB method _write.
public static final void _write(final XoXMLStreamWriter writer, final Handler handler, RuntimeContext context) throws Exception {
if (handler == null) {
writer.writeXsiNil();
return;
}
if (context == null) {
context = new RuntimeContext();
}
final String prefix = writer.getUniquePrefix("http://java.sun.com/xml/ns/javaee");
if (Handler.class != handler.getClass()) {
context.unexpectedSubclass(writer, handler, Handler.class);
return;
}
context.beforeMarshal(handler, LifecycleCallback.NONE);
// ATTRIBUTE: id
final String idRaw = handler.id;
if (idRaw != null) {
String id = null;
try {
id = Adapters.collapsedStringAdapterAdapter.marshal(idRaw);
} catch (final Exception e) {
context.xmlAdapterError(handler, "id", CollapsedStringAdapter.class, String.class, String.class, e);
}
writer.writeAttribute("", "", "id", id);
}
// ELEMENT: descriptions
Text[] descriptions = null;
try {
descriptions = handler.getDescriptions();
} catch (final Exception e) {
context.getterError(handler, "descriptions", Handler.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(handler, "descriptions");
}
}
}
// ELEMENT: displayNames
Text[] displayNames = null;
try {
displayNames = handler.getDisplayNames();
} catch (final Exception e) {
context.getterError(handler, "displayNames", Handler.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(handler, "displayNames");
}
}
}
// ELEMENT: icon
final LocalCollection<Icon> icon = handler.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();
}
}
}
// ELEMENT: handlerName
final String handlerNameRaw = handler.handlerName;
String handlerName = null;
try {
handlerName = Adapters.collapsedStringAdapterAdapter.marshal(handlerNameRaw);
} catch (final Exception e) {
context.xmlAdapterError(handler, "handlerName", CollapsedStringAdapter.class, String.class, String.class, e);
}
if (handlerName != null) {
writer.writeStartElement(prefix, "handler-name", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(handlerName);
writer.writeEndElement();
} else {
context.unexpectedNullValue(handler, "handlerName");
}
// ELEMENT: handlerClass
final String handlerClassRaw = handler.handlerClass;
String handlerClass = null;
try {
handlerClass = Adapters.collapsedStringAdapterAdapter.marshal(handlerClassRaw);
} catch (final Exception e) {
context.xmlAdapterError(handler, "handlerClass", CollapsedStringAdapter.class, String.class, String.class, e);
}
if (handlerClass != null) {
writer.writeStartElement(prefix, "handler-class", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(handlerClass);
writer.writeEndElement();
} else {
context.unexpectedNullValue(handler, "handlerClass");
}
// ELEMENT: initParam
final List<ParamValue> initParam = handler.initParam;
if (initParam != null) {
for (final ParamValue initParamItem : initParam) {
if (initParamItem != null) {
writer.writeStartElement(prefix, "init-param", "http://java.sun.com/xml/ns/javaee");
writeParamValue(writer, initParamItem, context);
writer.writeEndElement();
}
}
}
// ELEMENT: soapHeader
final List<QName> soapHeader = handler.soapHeader;
if (soapHeader != null) {
for (final QName soapHeaderItem : soapHeader) {
if (soapHeaderItem != null) {
writer.writeStartElement(prefix, "soap-header", "http://java.sun.com/xml/ns/javaee");
writer.writeQName(soapHeaderItem);
writer.writeEndElement();
}
}
}
// ELEMENT: soapRole
final List<String> soapRoleRaw = handler.soapRole;
if (soapRoleRaw != null) {
for (final String soapRoleItem : soapRoleRaw) {
String soapRole = null;
try {
soapRole = Adapters.collapsedStringAdapterAdapter.marshal(soapRoleItem);
} catch (final Exception e) {
context.xmlAdapterError(handler, "soapRole", CollapsedStringAdapter.class, List.class, List.class, e);
}
if (soapRole != null) {
writer.writeStartElement(prefix, "soap-role", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(soapRole);
writer.writeEndElement();
}
}
}
// ELEMENT: portName
final List<String> portNameRaw = handler.portName;
if (portNameRaw != null) {
for (final String portNameItem : portNameRaw) {
String portName = null;
try {
portName = Adapters.collapsedStringAdapterAdapter.marshal(portNameItem);
} catch (final Exception e) {
context.xmlAdapterError(handler, "portName", CollapsedStringAdapter.class, List.class, List.class, e);
}
if (portName != null) {
writer.writeStartElement(prefix, "port-name", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(portName);
writer.writeEndElement();
} else {
context.unexpectedNullValue(handler, "portName");
}
}
}
context.afterMarshal(handler, LifecycleCallback.NONE);
}
use of org.metatype.sxc.jaxb.RuntimeContext in project tomee by apache.
the class HandlerChain$JAXB method _read.
public static final HandlerChain _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
// Check for xsi:nil
if (reader.isXsiNil()) {
return null;
}
if (context == null) {
context = new RuntimeContext();
}
final HandlerChain handlerChain = new HandlerChain();
context.beforeUnmarshal(handlerChain, LifecycleCallback.NONE);
List<String> protocolBindings = null;
List<Handler> handler = null;
// Check xsi:type
final QName xsiType = reader.getXsiType();
if (xsiType != null) {
if (("handler-chainType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
return context.unexpectedXsiType(reader, HandlerChain.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, handlerChain);
handlerChain.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 (("service-name-pattern" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: serviceNamePattern
final String serviceNamePatternRaw = elementReader.getElementAsString();
final QName serviceNamePattern;
try {
serviceNamePattern = Adapters.handlerChainsStringQNameAdapterAdapter.unmarshal(serviceNamePatternRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, HandlerChainsStringQNameAdapter.class, QName.class, QName.class, e);
continue;
}
handlerChain.serviceNamePattern = serviceNamePattern;
} else if (("port-name-pattern" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: portNamePattern
final String portNamePatternRaw = elementReader.getElementAsString();
final QName portNamePattern;
try {
portNamePattern = Adapters.handlerChainsStringQNameAdapterAdapter.unmarshal(portNamePatternRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, HandlerChainsStringQNameAdapter.class, QName.class, QName.class, e);
continue;
}
handlerChain.portNamePattern = portNamePattern;
} else if (("protocol-bindings" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: protocolBindings
for (final String protocolBindingsItem : elementReader.getElementAsXmlList()) {
final String protocolBindingsItem1;
try {
protocolBindingsItem1 = Adapters.collapsedStringAdapterAdapter.unmarshal(protocolBindingsItem);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
if (protocolBindings == null) {
protocolBindings = handlerChain.protocolBindings;
if (protocolBindings != null) {
protocolBindings.clear();
} else {
protocolBindings = new ArrayList<String>();
}
}
protocolBindings.add(protocolBindingsItem1);
}
} else if (("handler" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: handler
final Handler handlerItem = readHandler(elementReader, context);
if (handler == null) {
handler = handlerChain.handler;
if (handler != null) {
handler.clear();
} else {
handler = new ArrayList<Handler>();
}
}
handler.add(handlerItem);
} else {
context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "service-name-pattern"), new QName("http://java.sun.com/xml/ns/javaee", "port-name-pattern"), new QName("http://java.sun.com/xml/ns/javaee", "protocol-bindings"), new QName("http://java.sun.com/xml/ns/javaee", "handler"));
}
}
if (protocolBindings != null) {
handlerChain.protocolBindings = protocolBindings;
}
if (handler != null) {
handlerChain.handler = handler;
}
context.afterUnmarshal(handlerChain, LifecycleCallback.NONE);
return handlerChain;
}
use of org.metatype.sxc.jaxb.RuntimeContext in project tomee by apache.
the class HandlerChain$JAXB method _write.
public static final void _write(final XoXMLStreamWriter writer, final HandlerChain handlerChain, RuntimeContext context) throws Exception {
if (handlerChain == null) {
writer.writeXsiNil();
return;
}
if (context == null) {
context = new RuntimeContext();
}
final String prefix = writer.getUniquePrefix("http://java.sun.com/xml/ns/javaee");
if (HandlerChain.class != handlerChain.getClass()) {
context.unexpectedSubclass(writer, handlerChain, HandlerChain.class);
return;
}
context.beforeMarshal(handlerChain, LifecycleCallback.NONE);
// ATTRIBUTE: id
final String idRaw = handlerChain.id;
if (idRaw != null) {
String id = null;
try {
id = Adapters.collapsedStringAdapterAdapter.marshal(idRaw);
} catch (final Exception e) {
context.xmlAdapterError(handlerChain, "id", CollapsedStringAdapter.class, String.class, String.class, e);
}
writer.writeAttribute("", "", "id", id);
}
// ELEMENT: serviceNamePattern
final QName serviceNamePatternRaw = handlerChain.serviceNamePattern;
String serviceNamePattern = null;
try {
serviceNamePattern = Adapters.handlerChainsStringQNameAdapterAdapter.marshal(serviceNamePatternRaw);
} catch (final Exception e) {
context.xmlAdapterError(handlerChain, "serviceNamePattern", HandlerChainsStringQNameAdapter.class, QName.class, QName.class, e);
}
if (serviceNamePattern != null) {
writer.writeStartElement(prefix, "service-name-pattern", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(serviceNamePattern);
writer.writeEndElement();
}
// ELEMENT: portNamePattern
final QName portNamePatternRaw = handlerChain.portNamePattern;
String portNamePattern = null;
try {
portNamePattern = Adapters.handlerChainsStringQNameAdapterAdapter.marshal(portNamePatternRaw);
} catch (final Exception e) {
context.xmlAdapterError(handlerChain, "portNamePattern", HandlerChainsStringQNameAdapter.class, QName.class, QName.class, e);
}
if (portNamePattern != null) {
writer.writeStartElement(prefix, "port-name-pattern", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(portNamePattern);
writer.writeEndElement();
}
// ELEMENT: protocolBindings
final List<String> protocolBindingsRaw = handlerChain.protocolBindings;
if (protocolBindingsRaw != null) {
writer.writeStartElement(prefix, "protocol-bindings", "http://java.sun.com/xml/ns/javaee");
boolean protocolBindingsFirst = true;
for (final String protocolBindingsItem : protocolBindingsRaw) {
String protocolBindings = null;
try {
protocolBindings = Adapters.collapsedStringAdapterAdapter.marshal(protocolBindingsItem);
} catch (final Exception e) {
context.xmlAdapterError(handlerChain, "protocolBindings", CollapsedStringAdapter.class, List.class, List.class, e);
}
if (protocolBindings != null) {
if (!protocolBindingsFirst) {
writer.writeCharacters(" ");
}
protocolBindingsFirst = false;
writer.writeCharacters(protocolBindings);
}
}
writer.writeEndElement();
}
// ELEMENT: handler
final List<Handler> handler = handlerChain.handler;
if (handler != null) {
for (final Handler handlerItem : handler) {
if (handlerItem != null) {
writer.writeStartElement(prefix, "handler", "http://java.sun.com/xml/ns/javaee");
writeHandler(writer, handlerItem, context);
writer.writeEndElement();
} else {
context.unexpectedNullValue(handlerChain, "handler");
}
}
}
context.afterMarshal(handlerChain, LifecycleCallback.NONE);
}
use of org.metatype.sxc.jaxb.RuntimeContext in project tomee by apache.
the class Icon$JAXB method _read.
public static final Icon _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
// Check for xsi:nil
if (reader.isXsiNil()) {
return null;
}
if (context == null) {
context = new RuntimeContext();
}
final Icon icon = new Icon();
context.beforeUnmarshal(icon, LifecycleCallback.NONE);
// Check xsi:type
final QName xsiType = reader.getXsiType();
if (xsiType != null) {
if (("iconType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
return context.unexpectedXsiType(reader, Icon.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, icon);
icon.id = id;
} else if (("lang" == attribute.getLocalName()) && ("http://www.w3.org/XML/1998/namespace" == attribute.getNamespace())) {
// ATTRIBUTE: lang
icon.lang = Adapters.collapsedStringAdapterAdapter.unmarshal(attribute.getValue());
} else if (XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI != attribute.getNamespace()) {
context.unexpectedAttribute(attribute, new QName("", "id"), new QName("http://www.w3.org/XML/1998/namespace", "lang"));
}
}
// Read elements
for (final XoXMLStreamReader elementReader : reader.getChildElements()) {
if (("small-icon" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: smallIcon
final String smallIconRaw = elementReader.getElementAsString();
final String smallIcon;
try {
smallIcon = Adapters.collapsedStringAdapterAdapter.unmarshal(smallIconRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
icon.smallIcon = smallIcon;
} else if (("large-icon" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: largeIcon
final String largeIconRaw = elementReader.getElementAsString();
final String largeIcon;
try {
largeIcon = Adapters.collapsedStringAdapterAdapter.unmarshal(largeIconRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
icon.largeIcon = largeIcon;
} else {
context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "small-icon"), new QName("http://java.sun.com/xml/ns/javaee", "large-icon"));
}
}
context.afterUnmarshal(icon, LifecycleCallback.NONE);
return icon;
}
use of org.metatype.sxc.jaxb.RuntimeContext in project tomee by apache.
the class InboundResourceadapter$JAXB method _read.
public static final InboundResourceadapter _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
// Check for xsi:nil
if (reader.isXsiNil()) {
return null;
}
if (context == null) {
context = new RuntimeContext();
}
final InboundResourceadapter inboundResourceadapter = new InboundResourceadapter();
context.beforeUnmarshal(inboundResourceadapter, LifecycleCallback.NONE);
// Check xsi:type
final QName xsiType = reader.getXsiType();
if (xsiType != null) {
if (("inbound-resourceadapterType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
return context.unexpectedXsiType(reader, InboundResourceadapter.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, inboundResourceadapter);
inboundResourceadapter.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 (("messageadapter" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: messageAdapter
final MessageAdapter messageAdapter = readMessageAdapter(elementReader, context);
inboundResourceadapter.messageAdapter = messageAdapter;
} else {
context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "messageadapter"));
}
}
context.afterUnmarshal(inboundResourceadapter, LifecycleCallback.NONE);
return inboundResourceadapter;
}
Aggregations