use of org.metatype.sxc.util.XoXMLStreamReader in project tomee by apache.
the class MethodPermission$JAXB method _read.
public static final MethodPermission _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
// Check for xsi:nil
if (reader.isXsiNil()) {
return null;
}
if (context == null) {
context = new RuntimeContext();
}
final MethodPermission methodPermission = new MethodPermission();
context.beforeUnmarshal(methodPermission, LifecycleCallback.NONE);
ArrayList<Text> descriptions = null;
List<String> roleName = null;
List<Method> method = null;
// Check xsi:type
final QName xsiType = reader.getXsiType();
if (xsiType != null) {
if (("method-permissionType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
return context.unexpectedXsiType(reader, MethodPermission.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, methodPermission);
methodPermission.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 (("role-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: roleName
final String roleNameItemRaw = elementReader.getElementAsString();
final String roleNameItem;
try {
roleNameItem = Adapters.collapsedStringAdapterAdapter.unmarshal(roleNameItemRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
if (roleName == null) {
roleName = methodPermission.roleName;
if (roleName != null) {
roleName.clear();
} else {
roleName = new ArrayList<String>();
}
}
roleName.add(roleNameItem);
} else if (("unchecked" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: unchecked
final Empty unchecked = readEmpty(elementReader, context);
methodPermission.unchecked = unchecked;
} else if (("method" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: method
final Method methodItem = readMethod(elementReader, context);
if (method == null) {
method = methodPermission.method;
if (method != null) {
method.clear();
} else {
method = new ArrayList<Method>();
}
}
method.add(methodItem);
} else {
context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "description"), new QName("http://java.sun.com/xml/ns/javaee", "role-name"), new QName("http://java.sun.com/xml/ns/javaee", "unchecked"), new QName("http://java.sun.com/xml/ns/javaee", "method"));
}
}
if (descriptions != null) {
try {
methodPermission.setDescriptions(descriptions.toArray(new Text[descriptions.size()]));
} catch (final Exception e) {
context.setterError(reader, MethodPermission.class, "setDescriptions", Text[].class, e);
}
}
if (roleName != null) {
methodPermission.roleName = roleName;
}
if (method != null) {
methodPermission.method = method;
}
context.afterUnmarshal(methodPermission, LifecycleCallback.NONE);
return methodPermission;
}
use of org.metatype.sxc.util.XoXMLStreamReader in project tomee by apache.
the class MultipartConfig$JAXB method _read.
public static final MultipartConfig _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
// Check for xsi:nil
if (reader.isXsiNil()) {
return null;
}
if (context == null) {
context = new RuntimeContext();
}
final MultipartConfig multipartConfig = new MultipartConfig();
context.beforeUnmarshal(multipartConfig, LifecycleCallback.NONE);
// Check xsi:type
final QName xsiType = reader.getXsiType();
if (xsiType != null) {
if (("multipart-configType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
return context.unexpectedXsiType(reader, MultipartConfig.class);
}
}
// Read attributes
for (final Attribute attribute : reader.getAttributes()) {
if (XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI != attribute.getNamespace()) {
context.unexpectedAttribute(attribute);
}
}
// Read elements
for (final XoXMLStreamReader elementReader : reader.getChildElements()) {
if (("location" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: location
final String locationRaw = elementReader.getElementAsString();
final String location;
try {
location = Adapters.collapsedStringAdapterAdapter.unmarshal(locationRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
multipartConfig.location = location;
} else if (("max-file-size" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: maxFileSize
final Long maxFileSize = Long.valueOf(elementReader.getElementAsString());
multipartConfig.maxFileSize = maxFileSize;
} else if (("max-request-size" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: maxRequestSize
final Long maxRequestSize = Long.valueOf(elementReader.getElementAsString());
multipartConfig.maxRequestSize = maxRequestSize;
} else if (("file-size-threshold" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: fileSizeThreshold
final Integer fileSizeThreshold = Integer.valueOf(elementReader.getElementAsString());
multipartConfig.fileSizeThreshold = fileSizeThreshold;
} else {
context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "location"), new QName("http://java.sun.com/xml/ns/javaee", "max-file-size"), new QName("http://java.sun.com/xml/ns/javaee", "max-request-size"), new QName("http://java.sun.com/xml/ns/javaee", "file-size-threshold"));
}
}
context.afterUnmarshal(multipartConfig, LifecycleCallback.NONE);
return multipartConfig;
}
use of org.metatype.sxc.util.XoXMLStreamReader in project tomee by apache.
the class PersistenceContextRef$JAXB method _read.
public static final PersistenceContextRef _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
// Check for xsi:nil
if (reader.isXsiNil()) {
return null;
}
if (context == null) {
context = new RuntimeContext();
}
final PersistenceContextRef persistenceContextRef = new PersistenceContextRef();
context.beforeUnmarshal(persistenceContextRef, LifecycleCallback.NONE);
ArrayList<Text> descriptions = null;
List<Property> persistenceProperty = null;
Set<InjectionTarget> injectionTarget = null;
// Check xsi:type
final QName xsiType = reader.getXsiType();
if (xsiType != null) {
if (("persistence-context-refType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
return context.unexpectedXsiType(reader, PersistenceContextRef.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, persistenceContextRef);
persistenceContextRef.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 (("persistence-context-ref-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: persistenceContextRefName
final String persistenceContextRefNameRaw = elementReader.getElementAsString();
final String persistenceContextRefName;
try {
persistenceContextRefName = Adapters.collapsedStringAdapterAdapter.unmarshal(persistenceContextRefNameRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
persistenceContextRef.persistenceContextRefName = persistenceContextRefName;
} else if (("persistence-unit-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: persistenceUnitName
final String persistenceUnitNameRaw = elementReader.getElementAsString();
final String persistenceUnitName;
try {
persistenceUnitName = Adapters.collapsedStringAdapterAdapter.unmarshal(persistenceUnitNameRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
persistenceContextRef.persistenceUnitName = persistenceUnitName;
} else if (("persistence-context-type" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: persistenceContextType
final PersistenceContextType persistenceContextType = parsePersistenceContextType(elementReader, context, elementReader.getElementAsString());
if (persistenceContextType != null) {
persistenceContextRef.persistenceContextType = persistenceContextType;
}
} else if (("persistence-context-synchronization" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: persistenceContextType
final PersistenceContextSynchronization synchronization = parsePersistenceContextSynchronization(elementReader, context, elementReader.getElementAsString());
if (synchronization != null) {
persistenceContextRef.persistenceContextSynchronization = synchronization;
}
} else if (("persistence-property" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: persistenceProperty
final Property persistencePropertyItem = readProperty(elementReader, context);
if (persistenceProperty == null) {
persistenceProperty = persistenceContextRef.persistenceProperty;
if (persistenceProperty != null) {
persistenceProperty.clear();
} else {
persistenceProperty = new ArrayList<Property>();
}
}
persistenceProperty.add(persistencePropertyItem);
} 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;
}
persistenceContextRef.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 = persistenceContextRef.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;
}
persistenceContextRef.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", "persistence-context-ref-name"), new QName("http://java.sun.com/xml/ns/javaee", "persistence-unit-name"), new QName("http://java.sun.com/xml/ns/javaee", "persistence-context-type"), new QName("http://java.sun.com/xml/ns/javaee", "persistence-property"), 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 {
persistenceContextRef.setDescriptions(descriptions.toArray(new Text[descriptions.size()]));
} catch (final Exception e) {
context.setterError(reader, PersistenceContextRef.class, "setDescriptions", Text[].class, e);
}
}
if (persistenceProperty != null) {
persistenceContextRef.persistenceProperty = persistenceProperty;
}
if (injectionTarget != null) {
persistenceContextRef.injectionTarget = injectionTarget;
}
context.afterUnmarshal(persistenceContextRef, LifecycleCallback.NONE);
return persistenceContextRef;
}
use of org.metatype.sxc.util.XoXMLStreamReader in project tomee by apache.
the class PersistenceUnitRef$JAXB method _read.
public static final PersistenceUnitRef _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
// Check for xsi:nil
if (reader.isXsiNil()) {
return null;
}
if (context == null) {
context = new RuntimeContext();
}
final PersistenceUnitRef persistenceUnitRef = new PersistenceUnitRef();
context.beforeUnmarshal(persistenceUnitRef, LifecycleCallback.NONE);
ArrayList<Text> descriptions = null;
Set<InjectionTarget> injectionTarget = null;
// Check xsi:type
final QName xsiType = reader.getXsiType();
if (xsiType != null) {
if (("persistence-unit-refType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
return context.unexpectedXsiType(reader, PersistenceUnitRef.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, persistenceUnitRef);
persistenceUnitRef.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 (("persistence-unit-ref-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: persistenceUnitRefName
final String persistenceUnitRefNameRaw = elementReader.getElementAsString();
final String persistenceUnitRefName;
try {
persistenceUnitRefName = Adapters.collapsedStringAdapterAdapter.unmarshal(persistenceUnitRefNameRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
persistenceUnitRef.persistenceUnitRefName = persistenceUnitRefName;
} else if (("persistence-unit-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: persistenceUnitName
final String persistenceUnitNameRaw = elementReader.getElementAsString();
final String persistenceUnitName;
try {
persistenceUnitName = Adapters.collapsedStringAdapterAdapter.unmarshal(persistenceUnitNameRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
persistenceUnitRef.persistenceUnitName = persistenceUnitName;
} 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;
}
persistenceUnitRef.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 = persistenceUnitRef.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;
}
persistenceUnitRef.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", "persistence-unit-ref-name"), new QName("http://java.sun.com/xml/ns/javaee", "persistence-unit-name"), 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 {
persistenceUnitRef.setDescriptions(descriptions.toArray(new Text[descriptions.size()]));
} catch (final Exception e) {
context.setterError(reader, PersistenceUnitRef.class, "setDescriptions", Text[].class, e);
}
}
if (injectionTarget != null) {
persistenceUnitRef.injectionTarget = injectionTarget;
}
context.afterUnmarshal(persistenceUnitRef, LifecycleCallback.NONE);
return persistenceUnitRef;
}
use of org.metatype.sxc.util.XoXMLStreamReader in project tomee by apache.
the class Property$JAXB method _read.
public static final Property _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
// Check for xsi:nil
if (reader.isXsiNil()) {
return null;
}
if (context == null) {
context = new RuntimeContext();
}
final Property property = new Property();
context.beforeUnmarshal(property, LifecycleCallback.NONE);
// Check xsi:type
final QName xsiType = reader.getXsiType();
if (xsiType != null) {
if (("propertyType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
return context.unexpectedXsiType(reader, Property.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, property);
property.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 (("name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: name
final String nameRaw = elementReader.getElementAsString();
final String name;
try {
name = Adapters.collapsedStringAdapterAdapter.unmarshal(nameRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
property.name = name;
} else if (("value" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: value
final String valueRaw = elementReader.getElementAsString();
final String value;
try {
value = Adapters.collapsedStringAdapterAdapter.unmarshal(valueRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
property.value = value;
} else {
context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "name"), new QName("http://java.sun.com/xml/ns/javaee", "value"));
}
}
context.afterUnmarshal(property, LifecycleCallback.NONE);
return property;
}
Aggregations