use of org.metatype.sxc.util.XoXMLStreamReader in project tomee by apache.
the class FacesBehaviorExtension$JAXB method _read.
public static final FacesBehaviorExtension _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
// Check for xsi:nil
if (reader.isXsiNil()) {
return null;
}
if (context == null) {
context = new RuntimeContext();
}
final FacesBehaviorExtension facesBehaviorExtension = new FacesBehaviorExtension();
context.beforeUnmarshal(facesBehaviorExtension, LifecycleCallback.NONE);
List<Object> any = null;
// Check xsi:type
final QName xsiType = reader.getXsiType();
if (xsiType != null) {
if (("faces-config-behavior-extensionType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
return context.unexpectedXsiType(reader, FacesBehaviorExtension.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, facesBehaviorExtension);
facesBehaviorExtension.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()) {
// ELEMENT_REF: any
if (any == null) {
any = facesBehaviorExtension.any;
if (any != null) {
any.clear();
} else {
any = new ArrayList<Object>();
}
}
any.add(context.readXmlAny(elementReader, Object.class, true));
}
if (any != null) {
facesBehaviorExtension.any = any;
}
context.afterUnmarshal(facesBehaviorExtension, LifecycleCallback.NONE);
return facesBehaviorExtension;
}
use of org.metatype.sxc.util.XoXMLStreamReader in project tomee by apache.
the class FacesComponent$JAXB method _read.
public static final FacesComponent _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
// Check for xsi:nil
if (reader.isXsiNil()) {
return null;
}
if (context == null) {
context = new RuntimeContext();
}
final FacesComponent facesComponent = new FacesComponent();
context.beforeUnmarshal(facesComponent, LifecycleCallback.NONE);
ArrayList<Text> descriptions = null;
ArrayList<Text> displayNames = null;
LocalCollection<Icon> icon = null;
List<FacesFacet> facet = null;
List<FacesAttribute> attribute1 = null;
List<FacesProperty> property = null;
List<FacesComponentExtension> componentExtension = null;
// Check xsi:type
final QName xsiType = reader.getXsiType();
if (xsiType != null) {
if (("faces-config-componentType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
return context.unexpectedXsiType(reader, FacesComponent.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, facesComponent);
facesComponent.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 = facesComponent.icon;
if (icon != null) {
icon.clear();
} else {
icon = new LocalCollection<Icon>();
}
}
icon.add(iconItem);
} else if (("component-type" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: componentType
final String componentTypeRaw = elementReader.getElementAsString();
final String componentType;
try {
componentType = Adapters.collapsedStringAdapterAdapter.unmarshal(componentTypeRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
facesComponent.componentType = componentType;
} else if (("component-class" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: componentClass
final String componentClassRaw = elementReader.getElementAsString();
final String componentClass;
try {
componentClass = Adapters.collapsedStringAdapterAdapter.unmarshal(componentClassRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
facesComponent.componentClass = componentClass;
} else if (("facet" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: facet
final FacesFacet facetItem = readFacesFacet(elementReader, context);
if (facet == null) {
facet = facesComponent.facet;
if (facet != null) {
facet.clear();
} else {
facet = new ArrayList<FacesFacet>();
}
}
facet.add(facetItem);
} else if (("attribute" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: attribute
final FacesAttribute attributeItem = readFacesAttribute(elementReader, context);
if (attribute1 == null) {
attribute1 = facesComponent.attribute;
if (attribute1 != null) {
attribute1.clear();
} else {
attribute1 = new ArrayList<FacesAttribute>();
}
}
attribute1.add(attributeItem);
} else if (("property" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: property
final FacesProperty propertyItem = readFacesProperty(elementReader, context);
if (property == null) {
property = facesComponent.property;
if (property != null) {
property.clear();
} else {
property = new ArrayList<FacesProperty>();
}
}
property.add(propertyItem);
} else if (("component-extension" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: componentExtension
final FacesComponentExtension componentExtensionItem = readFacesComponentExtension(elementReader, context);
if (componentExtension == null) {
componentExtension = facesComponent.componentExtension;
if (componentExtension != null) {
componentExtension.clear();
} else {
componentExtension = new ArrayList<FacesComponentExtension>();
}
}
componentExtension.add(componentExtensionItem);
} else {
// just here ATM to not prevent users to get JSF 2.2 feature because we can't read it
// TODO: handle it properly
// 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", "component-type"), new QName("http://java.sun.com/xml/ns/javaee", "component-class"), new QName("http://java.sun.com/xml/ns/javaee", "facet"), new QName("http://java.sun.com/xml/ns/javaee", "attribute"), new QName("http://java.sun.com/xml/ns/javaee", "property"), new QName("http://java.sun.com/xml/ns/javaee", "component-extension"));
}
}
if (descriptions != null) {
try {
facesComponent.setDescriptions(descriptions.toArray(new Text[descriptions.size()]));
} catch (final Exception e) {
context.setterError(reader, FacesComponent.class, "setDescriptions", Text[].class, e);
}
}
if (displayNames != null) {
try {
facesComponent.setDisplayNames(displayNames.toArray(new Text[displayNames.size()]));
} catch (final Exception e) {
context.setterError(reader, FacesComponent.class, "setDisplayNames", Text[].class, e);
}
}
if (icon != null) {
facesComponent.icon = icon;
}
if (facet != null) {
facesComponent.facet = facet;
}
if (attribute1 != null) {
facesComponent.attribute = attribute1;
}
if (property != null) {
facesComponent.property = property;
}
if (componentExtension != null) {
facesComponent.componentExtension = componentExtension;
}
context.afterUnmarshal(facesComponent, LifecycleCallback.NONE);
return facesComponent;
}
use of org.metatype.sxc.util.XoXMLStreamReader in project tomee by apache.
the class FacesConfig$JAXB method _read.
public static final FacesConfig _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
// Check for xsi:nil
if (reader.isXsiNil()) {
return null;
}
if (context == null) {
context = new RuntimeContext();
}
final FacesConfig facesConfig = new FacesConfig();
context.beforeUnmarshal(facesConfig, LifecycleCallback.NONE);
List<FacesApplication> application = null;
List<FacesOrdering> ordering = null;
List<FacesAbsoluteOrdering> absoluteOrdering = null;
List<FacesFactory> factory = null;
List<FacesComponent> component = null;
List<FacesConverter> converter = null;
List<FacesManagedBean> managedBean = null;
List<String> name = null;
List<FacesNavigationRule> navigationRule = null;
List<FacesReferencedBean> referencedBean = null;
List<FacesRenderKit> renderKit = null;
List<FacesLifecycle> lifecycle = null;
List<FacesValidator> validator = null;
List<FacesBehavior> behavior = null;
List<FacesExtension> facesConfigExtension = null;
// Check xsi:type
final QName xsiType = reader.getXsiType();
if (xsiType != null) {
if (("faces-configType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
return context.unexpectedXsiType(reader, FacesConfig.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, facesConfig);
facesConfig.id = id;
} else if (("version" == attribute.getLocalName()) && (("" == attribute.getNamespace()) || (attribute.getNamespace() == null))) {
// ATTRIBUTE: version
facesConfig.version = Adapters.collapsedStringAdapterAdapter.unmarshal(attribute.getValue());
} else if (("metadata-complete" == attribute.getLocalName()) && (("" == attribute.getNamespace()) || (attribute.getNamespace() == null))) {
// ATTRIBUTE: metadataComplete
final Boolean metadataComplete = ("1".equals(attribute.getValue()) || "true".equals(attribute.getValue()));
facesConfig.metadataComplete = metadataComplete;
} else if (XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI != attribute.getNamespace()) {
context.unexpectedAttribute(attribute, new QName("", "id"), new QName("", "version"), new QName("", "metadata-complete"));
}
}
// Read elements
for (final XoXMLStreamReader elementReader : reader.getChildElements()) {
if (("application" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: application
final FacesApplication applicationItem = readFacesApplication(elementReader, context);
if (application == null) {
application = facesConfig.application;
if (application != null) {
application.clear();
} else {
application = new ArrayList<FacesApplication>();
}
}
application.add(applicationItem);
} else if (("ordering" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: ordering
final FacesOrdering orderingItem = readFacesOrdering(elementReader, context);
if (ordering == null) {
ordering = facesConfig.ordering;
if (ordering != null) {
ordering.clear();
} else {
ordering = new ArrayList<FacesOrdering>();
}
}
ordering.add(orderingItem);
} else if (("absolute-ordering" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: absoluteOrdering
final FacesAbsoluteOrdering absoluteOrderingItem = readFacesAbsoluteOrdering(elementReader, context);
if (absoluteOrdering == null) {
absoluteOrdering = facesConfig.absoluteOrdering;
if (absoluteOrdering != null) {
absoluteOrdering.clear();
} else {
absoluteOrdering = new ArrayList<FacesAbsoluteOrdering>();
}
}
absoluteOrdering.add(absoluteOrderingItem);
} else if (("factory" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: factory
final FacesFactory factoryItem = readFacesFactory(elementReader, context);
if (factory == null) {
factory = facesConfig.factory;
if (factory != null) {
factory.clear();
} else {
factory = new ArrayList<FacesFactory>();
}
}
factory.add(factoryItem);
} else if (("component" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: component
final FacesComponent componentItem = readFacesComponent(elementReader, context);
if (component == null) {
component = facesConfig.component;
if (component != null) {
component.clear();
} else {
component = new ArrayList<FacesComponent>();
}
}
component.add(componentItem);
} else if (("converter" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: converter
final FacesConverter converterItem = readFacesConverter(elementReader, context);
if (converter == null) {
converter = facesConfig.converter;
if (converter != null) {
converter.clear();
} else {
converter = new ArrayList<FacesConverter>();
}
}
converter.add(converterItem);
} else if (("managed-bean" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: managedBean
final FacesManagedBean managedBeanItem = readFacesManagedBean(elementReader, context);
if (managedBean == null) {
managedBean = facesConfig.managedBean;
if (managedBean != null) {
managedBean.clear();
} else {
managedBean = new ArrayList<FacesManagedBean>();
}
}
managedBean.add(managedBeanItem);
} else if (("name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: name
String nameItemRaw = null;
if (!elementReader.isXsiNil()) {
nameItemRaw = elementReader.getElementAsString();
}
final String nameItem;
try {
nameItem = Adapters.collapsedStringAdapterAdapter.unmarshal(nameItemRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
if (name == null) {
name = facesConfig.name;
if (name != null) {
name.clear();
} else {
name = new ArrayList<String>();
}
}
name.add(nameItem);
} else if (("navigation-rule" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: navigationRule
final FacesNavigationRule navigationRuleItem = readFacesNavigationRule(elementReader, context);
if (navigationRule == null) {
navigationRule = facesConfig.navigationRule;
if (navigationRule != null) {
navigationRule.clear();
} else {
navigationRule = new ArrayList<FacesNavigationRule>();
}
}
navigationRule.add(navigationRuleItem);
} else if (("referenced-bean" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: referencedBean
final FacesReferencedBean referencedBeanItem = readFacesReferencedBean(elementReader, context);
if (referencedBean == null) {
referencedBean = facesConfig.referencedBean;
if (referencedBean != null) {
referencedBean.clear();
} else {
referencedBean = new ArrayList<FacesReferencedBean>();
}
}
referencedBean.add(referencedBeanItem);
} else if (("render-kit" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: renderKit
final FacesRenderKit renderKitItem = readFacesRenderKit(elementReader, context);
if (renderKit == null) {
renderKit = facesConfig.renderKit;
if (renderKit != null) {
renderKit.clear();
} else {
renderKit = new ArrayList<FacesRenderKit>();
}
}
renderKit.add(renderKitItem);
} else if (("lifecycle" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: lifecycle
final FacesLifecycle lifecycleItem = readFacesLifecycle(elementReader, context);
if (lifecycle == null) {
lifecycle = facesConfig.lifecycle;
if (lifecycle != null) {
lifecycle.clear();
} else {
lifecycle = new ArrayList<FacesLifecycle>();
}
}
lifecycle.add(lifecycleItem);
} else if (("validator" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: validator
final FacesValidator validatorItem = readFacesValidator(elementReader, context);
if (validator == null) {
validator = facesConfig.validator;
if (validator != null) {
validator.clear();
} else {
validator = new ArrayList<FacesValidator>();
}
}
validator.add(validatorItem);
} else if (("behavior" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: behavior
final FacesBehavior behaviorItem = readFacesBehavior(elementReader, context);
if (behavior == null) {
behavior = facesConfig.behavior;
if (behavior != null) {
behavior.clear();
} else {
behavior = new ArrayList<FacesBehavior>();
}
}
behavior.add(behaviorItem);
} else if (("faces-config-extension" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: facesConfigExtension
final FacesExtension facesConfigExtensionItem = readFacesExtension(elementReader, context);
if (facesConfigExtension == null) {
facesConfigExtension = facesConfig.facesConfigExtension;
if (facesConfigExtension != null) {
facesConfigExtension.clear();
} else {
facesConfigExtension = new ArrayList<FacesExtension>();
}
}
facesConfigExtension.add(facesConfigExtensionItem);
} else if ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI()) {
// just here ATM to not prevent users to get JSF 2.2 feature because we can't read it
// TODO: read it if we need it (= classes to add to injectable classes, other file to parse to find them etc...)
} else {
context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "application"), new QName("http://java.sun.com/xml/ns/javaee", "ordering"), new QName("http://java.sun.com/xml/ns/javaee", "absolute-ordering"), new QName("http://java.sun.com/xml/ns/javaee", "factory"), new QName("http://java.sun.com/xml/ns/javaee", "component"), new QName("http://java.sun.com/xml/ns/javaee", "converter"), new QName("http://java.sun.com/xml/ns/javaee", "managed-bean"), new QName("http://java.sun.com/xml/ns/javaee", "name"), new QName("http://java.sun.com/xml/ns/javaee", "navigation-rule"), new QName("http://java.sun.com/xml/ns/javaee", "referenced-bean"), new QName("http://java.sun.com/xml/ns/javaee", "render-kit"), new QName("http://java.sun.com/xml/ns/javaee", "lifecycle"), new QName("http://java.sun.com/xml/ns/javaee", "validator"), new QName("http://java.sun.com/xml/ns/javaee", "behavior"), new QName("http://java.sun.com/xml/ns/javaee", "faces-config-extension"));
}
}
if (application != null) {
facesConfig.application = application;
}
if (ordering != null) {
facesConfig.ordering = ordering;
}
if (absoluteOrdering != null) {
facesConfig.absoluteOrdering = absoluteOrdering;
}
if (factory != null) {
facesConfig.factory = factory;
}
if (component != null) {
facesConfig.component = component;
}
if (converter != null) {
facesConfig.converter = converter;
}
if (managedBean != null) {
facesConfig.managedBean = managedBean;
}
if (name != null) {
facesConfig.name = name;
}
if (navigationRule != null) {
facesConfig.navigationRule = navigationRule;
}
if (referencedBean != null) {
facesConfig.referencedBean = referencedBean;
}
if (renderKit != null) {
facesConfig.renderKit = renderKit;
}
if (lifecycle != null) {
facesConfig.lifecycle = lifecycle;
}
if (validator != null) {
facesConfig.validator = validator;
}
if (behavior != null) {
facesConfig.behavior = behavior;
}
if (facesConfigExtension != null) {
facesConfig.facesConfigExtension = facesConfigExtension;
}
context.afterUnmarshal(facesConfig, LifecycleCallback.NONE);
return facesConfig;
}
use of org.metatype.sxc.util.XoXMLStreamReader in project tomee by apache.
the class FacesConverterExtension$JAXB method _read.
public static final FacesConverterExtension _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
// Check for xsi:nil
if (reader.isXsiNil()) {
return null;
}
if (context == null) {
context = new RuntimeContext();
}
final FacesConverterExtension facesConverterExtension = new FacesConverterExtension();
context.beforeUnmarshal(facesConverterExtension, LifecycleCallback.NONE);
List<Object> any = null;
// Check xsi:type
final QName xsiType = reader.getXsiType();
if (xsiType != null) {
if (("faces-config-converter-extensionType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
return context.unexpectedXsiType(reader, FacesConverterExtension.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, facesConverterExtension);
facesConverterExtension.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()) {
// ELEMENT_REF: any
if (any == null) {
any = facesConverterExtension.any;
if (any != null) {
any.clear();
} else {
any = new ArrayList<Object>();
}
}
any.add(context.readXmlAny(elementReader, Object.class, true));
}
if (any != null) {
facesConverterExtension.any = any;
}
context.afterUnmarshal(facesConverterExtension, LifecycleCallback.NONE);
return facesConverterExtension;
}
use of org.metatype.sxc.util.XoXMLStreamReader in project tomee by apache.
the class FacesFacet$JAXB method _read.
public static final FacesFacet _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
// Check for xsi:nil
if (reader.isXsiNil()) {
return null;
}
if (context == null) {
context = new RuntimeContext();
}
final FacesFacet facesFacet = new FacesFacet();
context.beforeUnmarshal(facesFacet, LifecycleCallback.NONE);
ArrayList<Text> descriptions = null;
ArrayList<Text> displayNames = null;
LocalCollection<Icon> icon = null;
List<FacesFacetExtension> facetExtension = null;
// Check xsi:type
final QName xsiType = reader.getXsiType();
if (xsiType != null) {
if (("faces-config-facetType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
return context.unexpectedXsiType(reader, FacesFacet.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, facesFacet);
facesFacet.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 = facesFacet.icon;
if (icon != null) {
icon.clear();
} else {
icon = new LocalCollection<Icon>();
}
}
icon.add(iconItem);
} else if (("facet-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: facetName
final String facetNameRaw = elementReader.getElementAsString();
final String facetName;
try {
facetName = Adapters.collapsedStringAdapterAdapter.unmarshal(facetNameRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
facesFacet.facetName = facetName;
} else if (("facet-extension" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: facetExtension
final FacesFacetExtension facetExtensionItem = readFacesFacetExtension(elementReader, context);
if (facetExtension == null) {
facetExtension = facesFacet.facetExtension;
if (facetExtension != null) {
facetExtension.clear();
} else {
facetExtension = new ArrayList<FacesFacetExtension>();
}
}
facetExtension.add(facetExtensionItem);
} 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", "facet-name"), new QName("http://java.sun.com/xml/ns/javaee", "facet-extension"));
}
}
if (descriptions != null) {
try {
facesFacet.setDescriptions(descriptions.toArray(new Text[descriptions.size()]));
} catch (final Exception e) {
context.setterError(reader, FacesFacet.class, "setDescriptions", Text[].class, e);
}
}
if (displayNames != null) {
try {
facesFacet.setDisplayNames(displayNames.toArray(new Text[displayNames.size()]));
} catch (final Exception e) {
context.setterError(reader, FacesFacet.class, "setDisplayNames", Text[].class, e);
}
}
if (icon != null) {
facesFacet.icon = icon;
}
if (facetExtension != null) {
facesFacet.facetExtension = facetExtension;
}
context.afterUnmarshal(facesFacet, LifecycleCallback.NONE);
return facesFacet;
}
Aggregations