use of org.apache.openejb.jee.FacesAttribute$JAXB.readFacesAttribute in project tomee by apache.
the class FacesValidator$JAXB method _read.
public static final FacesValidator _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
// Check for xsi:nil
if (reader.isXsiNil()) {
return null;
}
if (context == null) {
context = new RuntimeContext();
}
final FacesValidator facesValidator = new FacesValidator();
context.beforeUnmarshal(facesValidator, LifecycleCallback.NONE);
ArrayList<Text> descriptions = null;
ArrayList<Text> displayNames = null;
LocalCollection<Icon> icon = null;
List<FacesAttribute> attribute1 = null;
List<FacesProperty> property = null;
List<FacesValidatorExtension> validatorExtension = null;
// Check xsi:type
final QName xsiType = reader.getXsiType();
if (xsiType != null) {
if (("faces-config-validatorType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
return context.unexpectedXsiType(reader, FacesValidator.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, facesValidator);
facesValidator.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 = facesValidator.icon;
if (icon != null) {
icon.clear();
} else {
icon = new LocalCollection<Icon>();
}
}
icon.add(iconItem);
} else if (("validator-id" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: validatorId
final String validatorIdRaw = elementReader.getElementAsString();
final String validatorId;
try {
validatorId = Adapters.collapsedStringAdapterAdapter.unmarshal(validatorIdRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
facesValidator.validatorId = validatorId;
} else if (("validator-class" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: validatorClass
final String validatorClassRaw = elementReader.getElementAsString();
final String validatorClass;
try {
validatorClass = Adapters.collapsedStringAdapterAdapter.unmarshal(validatorClassRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
facesValidator.validatorClass = validatorClass;
} 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 = facesValidator.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 = facesValidator.property;
if (property != null) {
property.clear();
} else {
property = new ArrayList<FacesProperty>();
}
}
property.add(propertyItem);
} else if (("validator-extension" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: validatorExtension
final FacesValidatorExtension validatorExtensionItem = readFacesValidatorExtension(elementReader, context);
if (validatorExtension == null) {
validatorExtension = facesValidator.validatorExtension;
if (validatorExtension != null) {
validatorExtension.clear();
} else {
validatorExtension = new ArrayList<FacesValidatorExtension>();
}
}
validatorExtension.add(validatorExtensionItem);
} 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", "validator-id"), new QName("http://java.sun.com/xml/ns/javaee", "validator-class"), 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", "validator-extension"));
}
}
if (descriptions != null) {
try {
facesValidator.setDescriptions(descriptions.toArray(new Text[descriptions.size()]));
} catch (final Exception e) {
context.setterError(reader, FacesValidator.class, "setDescriptions", Text[].class, e);
}
}
if (displayNames != null) {
try {
facesValidator.setDisplayNames(displayNames.toArray(new Text[displayNames.size()]));
} catch (final Exception e) {
context.setterError(reader, FacesValidator.class, "setDisplayNames", Text[].class, e);
}
}
if (icon != null) {
facesValidator.icon = icon;
}
if (attribute1 != null) {
facesValidator.attribute = attribute1;
}
if (property != null) {
facesValidator.property = property;
}
if (validatorExtension != null) {
facesValidator.validatorExtension = validatorExtension;
}
context.afterUnmarshal(facesValidator, LifecycleCallback.NONE);
return facesValidator;
}
use of org.apache.openejb.jee.FacesAttribute$JAXB.readFacesAttribute in project tomee by apache.
the class FacesValidator$JAXB method _write.
public static final void _write(final XoXMLStreamWriter writer, final FacesValidator facesValidator, RuntimeContext context) throws Exception {
if (facesValidator == null) {
writer.writeXsiNil();
return;
}
if (context == null) {
context = new RuntimeContext();
}
final String prefix = writer.getUniquePrefix("http://java.sun.com/xml/ns/javaee");
if (FacesValidator.class != facesValidator.getClass()) {
context.unexpectedSubclass(writer, facesValidator, FacesValidator.class);
return;
}
context.beforeMarshal(facesValidator, LifecycleCallback.NONE);
// ATTRIBUTE: id
final String idRaw = facesValidator.id;
if (idRaw != null) {
String id = null;
try {
id = Adapters.collapsedStringAdapterAdapter.marshal(idRaw);
} catch (final Exception e) {
context.xmlAdapterError(facesValidator, "id", CollapsedStringAdapter.class, String.class, String.class, e);
}
writer.writeAttribute("", "", "id", id);
}
// ELEMENT: descriptions
Text[] descriptions = null;
try {
descriptions = facesValidator.getDescriptions();
} catch (final Exception e) {
context.getterError(facesValidator, "descriptions", FacesValidator.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(facesValidator, "descriptions");
}
}
}
// ELEMENT: displayNames
Text[] displayNames = null;
try {
displayNames = facesValidator.getDisplayNames();
} catch (final Exception e) {
context.getterError(facesValidator, "displayNames", FacesValidator.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(facesValidator, "displayNames");
}
}
}
// ELEMENT: icon
final LocalCollection<Icon> icon = facesValidator.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(facesValidator, "icon");
}
}
}
// ELEMENT: validatorId
final String validatorIdRaw = facesValidator.validatorId;
String validatorId = null;
try {
validatorId = Adapters.collapsedStringAdapterAdapter.marshal(validatorIdRaw);
} catch (final Exception e) {
context.xmlAdapterError(facesValidator, "validatorId", CollapsedStringAdapter.class, String.class, String.class, e);
}
if (validatorId != null) {
writer.writeStartElement(prefix, "validator-id", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(validatorId);
writer.writeEndElement();
} else {
context.unexpectedNullValue(facesValidator, "validatorId");
}
// ELEMENT: validatorClass
final String validatorClassRaw = facesValidator.validatorClass;
String validatorClass = null;
try {
validatorClass = Adapters.collapsedStringAdapterAdapter.marshal(validatorClassRaw);
} catch (final Exception e) {
context.xmlAdapterError(facesValidator, "validatorClass", CollapsedStringAdapter.class, String.class, String.class, e);
}
if (validatorClass != null) {
writer.writeStartElement(prefix, "validator-class", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(validatorClass);
writer.writeEndElement();
} else {
context.unexpectedNullValue(facesValidator, "validatorClass");
}
// ELEMENT: attribute
final List<FacesAttribute> attribute = facesValidator.attribute;
if (attribute != null) {
for (final FacesAttribute attributeItem : attribute) {
writer.writeStartElement(prefix, "attribute", "http://java.sun.com/xml/ns/javaee");
if (attributeItem != null) {
writeFacesAttribute(writer, attributeItem, context);
} else {
writer.writeXsiNil();
}
writer.writeEndElement();
}
}
// ELEMENT: property
final List<FacesProperty> property = facesValidator.property;
if (property != null) {
for (final FacesProperty propertyItem : property) {
writer.writeStartElement(prefix, "property", "http://java.sun.com/xml/ns/javaee");
if (propertyItem != null) {
writeFacesProperty(writer, propertyItem, context);
} else {
writer.writeXsiNil();
}
writer.writeEndElement();
}
}
// ELEMENT: validatorExtension
final List<FacesValidatorExtension> validatorExtension = facesValidator.validatorExtension;
if (validatorExtension != null) {
for (final FacesValidatorExtension validatorExtensionItem : validatorExtension) {
if (validatorExtensionItem != null) {
writer.writeStartElement(prefix, "validator-extension", "http://java.sun.com/xml/ns/javaee");
writeFacesValidatorExtension(writer, validatorExtensionItem, context);
writer.writeEndElement();
}
}
}
context.afterMarshal(facesValidator, LifecycleCallback.NONE);
}
use of org.apache.openejb.jee.FacesAttribute$JAXB.readFacesAttribute in project tomee by apache.
the class FacesRenderer$JAXB method _read.
public static final FacesRenderer _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
// Check for xsi:nil
if (reader.isXsiNil()) {
return null;
}
if (context == null) {
context = new RuntimeContext();
}
final FacesRenderer facesRenderer = new FacesRenderer();
context.beforeUnmarshal(facesRenderer, LifecycleCallback.NONE);
ArrayList<Text> descriptions = null;
ArrayList<Text> displayNames = null;
LocalCollection<Icon> icon = null;
List<FacesFacet> facet = null;
List<FacesAttribute> attribute1 = null;
List<FacesRendererExtension> rendererExtension = null;
// Check xsi:type
final QName xsiType = reader.getXsiType();
if (xsiType != null) {
if (("faces-config-rendererType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
return context.unexpectedXsiType(reader, FacesRenderer.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, facesRenderer);
facesRenderer.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 = facesRenderer.icon;
if (icon != null) {
icon.clear();
} else {
icon = new LocalCollection<Icon>();
}
}
icon.add(iconItem);
} else if (("component-family" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: componentFamily
final String componentFamilyRaw = elementReader.getElementAsString();
final String componentFamily;
try {
componentFamily = Adapters.collapsedStringAdapterAdapter.unmarshal(componentFamilyRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
facesRenderer.componentFamily = componentFamily;
} else if (("renderer-type" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: rendererType
final String rendererTypeRaw = elementReader.getElementAsString();
final String rendererType;
try {
rendererType = Adapters.collapsedStringAdapterAdapter.unmarshal(rendererTypeRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
facesRenderer.rendererType = rendererType;
} else if (("renderer-class" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: rendererClass
final String rendererClassRaw = elementReader.getElementAsString();
final String rendererClass;
try {
rendererClass = Adapters.collapsedStringAdapterAdapter.unmarshal(rendererClassRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
facesRenderer.rendererClass = rendererClass;
} 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 = facesRenderer.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 = facesRenderer.attribute;
if (attribute1 != null) {
attribute1.clear();
} else {
attribute1 = new ArrayList<FacesAttribute>();
}
}
attribute1.add(attributeItem);
} else if (("renderer-extension" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: rendererExtension
final FacesRendererExtension rendererExtensionItem = readFacesRendererExtension(elementReader, context);
if (rendererExtension == null) {
rendererExtension = facesRenderer.rendererExtension;
if (rendererExtension != null) {
rendererExtension.clear();
} else {
rendererExtension = new ArrayList<FacesRendererExtension>();
}
}
rendererExtension.add(rendererExtensionItem);
} 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", "component-family"), new QName("http://java.sun.com/xml/ns/javaee", "renderer-type"), new QName("http://java.sun.com/xml/ns/javaee", "renderer-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", "renderer-extension"));
}
}
if (descriptions != null) {
try {
facesRenderer.setDescriptions(descriptions.toArray(new Text[descriptions.size()]));
} catch (final Exception e) {
context.setterError(reader, FacesRenderer.class, "setDescriptions", Text[].class, e);
}
}
if (displayNames != null) {
try {
facesRenderer.setDisplayNames(displayNames.toArray(new Text[displayNames.size()]));
} catch (final Exception e) {
context.setterError(reader, FacesRenderer.class, "setDisplayNames", Text[].class, e);
}
}
if (icon != null) {
facesRenderer.icon = icon;
}
if (facet != null) {
facesRenderer.facet = facet;
}
if (attribute1 != null) {
facesRenderer.attribute = attribute1;
}
if (rendererExtension != null) {
facesRenderer.rendererExtension = rendererExtension;
}
context.afterUnmarshal(facesRenderer, LifecycleCallback.NONE);
return facesRenderer;
}
use of org.apache.openejb.jee.FacesAttribute$JAXB.readFacesAttribute in project tomee by apache.
the class FacesConverter$JAXB method _read.
public static final FacesConverter _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
// Check for xsi:nil
if (reader.isXsiNil()) {
return null;
}
if (context == null) {
context = new RuntimeContext();
}
final FacesConverter facesConverter = new FacesConverter();
context.beforeUnmarshal(facesConverter, LifecycleCallback.NONE);
ArrayList<Text> descriptions = null;
ArrayList<Text> displayNames = null;
LocalCollection<Icon> icon = null;
List<FacesAttribute> attribute1 = null;
List<FacesProperty> property = null;
List<FacesConverterExtension> converterExtension = null;
// Check xsi:type
final QName xsiType = reader.getXsiType();
if (xsiType != null) {
if (("faces-config-converterType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
return context.unexpectedXsiType(reader, FacesConverter.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, facesConverter);
facesConverter.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 = facesConverter.icon;
if (icon != null) {
icon.clear();
} else {
icon = new LocalCollection<Icon>();
}
}
icon.add(iconItem);
} else if (("converter-id" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: converterId
final String converterIdRaw = elementReader.getElementAsString();
final String converterId;
try {
converterId = Adapters.collapsedStringAdapterAdapter.unmarshal(converterIdRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
facesConverter.converterId = converterId;
} else if (("converter-for-class" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: converterForClass
final String converterForClassRaw = elementReader.getElementAsString();
final String converterForClass;
try {
converterForClass = Adapters.collapsedStringAdapterAdapter.unmarshal(converterForClassRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
facesConverter.converterForClass = converterForClass;
} else if (("converter-class" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: converterClass
final String converterClassRaw = elementReader.getElementAsString();
final String converterClass;
try {
converterClass = Adapters.collapsedStringAdapterAdapter.unmarshal(converterClassRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
facesConverter.converterClass = converterClass;
} 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 = facesConverter.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 = facesConverter.property;
if (property != null) {
property.clear();
} else {
property = new ArrayList<FacesProperty>();
}
}
property.add(propertyItem);
} else if (("converter-extension" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: converterExtension
final FacesConverterExtension converterExtensionItem = readFacesConverterExtension(elementReader, context);
if (converterExtension == null) {
converterExtension = facesConverter.converterExtension;
if (converterExtension != null) {
converterExtension.clear();
} else {
converterExtension = new ArrayList<FacesConverterExtension>();
}
}
converterExtension.add(converterExtensionItem);
} 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", "converter-id"), new QName("http://java.sun.com/xml/ns/javaee", "converter-for-class"), new QName("http://java.sun.com/xml/ns/javaee", "converter-class"), 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", "converter-extension"));
}
}
if (descriptions != null) {
try {
facesConverter.setDescriptions(descriptions.toArray(new Text[descriptions.size()]));
} catch (final Exception e) {
context.setterError(reader, FacesConverter.class, "setDescriptions", Text[].class, e);
}
}
if (displayNames != null) {
try {
facesConverter.setDisplayNames(displayNames.toArray(new Text[displayNames.size()]));
} catch (final Exception e) {
context.setterError(reader, FacesConverter.class, "setDisplayNames", Text[].class, e);
}
}
if (icon != null) {
facesConverter.icon = icon;
}
if (attribute1 != null) {
facesConverter.attribute = attribute1;
}
if (property != null) {
facesConverter.property = property;
}
if (converterExtension != null) {
facesConverter.converterExtension = converterExtension;
}
context.afterUnmarshal(facesConverter, LifecycleCallback.NONE);
return facesConverter;
}
use of org.apache.openejb.jee.FacesAttribute$JAXB.readFacesAttribute in project tomee by apache.
the class FacesConverter$JAXB method _write.
public static final void _write(final XoXMLStreamWriter writer, final FacesConverter facesConverter, RuntimeContext context) throws Exception {
if (facesConverter == null) {
writer.writeXsiNil();
return;
}
if (context == null) {
context = new RuntimeContext();
}
final String prefix = writer.getUniquePrefix("http://java.sun.com/xml/ns/javaee");
if (FacesConverter.class != facesConverter.getClass()) {
context.unexpectedSubclass(writer, facesConverter, FacesConverter.class);
return;
}
context.beforeMarshal(facesConverter, LifecycleCallback.NONE);
// ATTRIBUTE: id
final String idRaw = facesConverter.id;
if (idRaw != null) {
String id = null;
try {
id = Adapters.collapsedStringAdapterAdapter.marshal(idRaw);
} catch (final Exception e) {
context.xmlAdapterError(facesConverter, "id", CollapsedStringAdapter.class, String.class, String.class, e);
}
writer.writeAttribute("", "", "id", id);
}
// ELEMENT: descriptions
Text[] descriptions = null;
try {
descriptions = facesConverter.getDescriptions();
} catch (final Exception e) {
context.getterError(facesConverter, "descriptions", FacesConverter.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(facesConverter, "descriptions");
}
}
}
// ELEMENT: displayNames
Text[] displayNames = null;
try {
displayNames = facesConverter.getDisplayNames();
} catch (final Exception e) {
context.getterError(facesConverter, "displayNames", FacesConverter.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(facesConverter, "displayNames");
}
}
}
// ELEMENT: icon
final LocalCollection<Icon> icon = facesConverter.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(facesConverter, "icon");
}
}
}
// ELEMENT: converterId
final String converterIdRaw = facesConverter.converterId;
String converterId = null;
try {
converterId = Adapters.collapsedStringAdapterAdapter.marshal(converterIdRaw);
} catch (final Exception e) {
context.xmlAdapterError(facesConverter, "converterId", CollapsedStringAdapter.class, String.class, String.class, e);
}
if (converterId != null) {
writer.writeStartElement(prefix, "converter-id", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(converterId);
writer.writeEndElement();
}
// ELEMENT: converterForClass
final String converterForClassRaw = facesConverter.converterForClass;
String converterForClass = null;
try {
converterForClass = Adapters.collapsedStringAdapterAdapter.marshal(converterForClassRaw);
} catch (final Exception e) {
context.xmlAdapterError(facesConverter, "converterForClass", CollapsedStringAdapter.class, String.class, String.class, e);
}
if (converterForClass != null) {
writer.writeStartElement(prefix, "converter-for-class", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(converterForClass);
writer.writeEndElement();
}
// ELEMENT: converterClass
final String converterClassRaw = facesConverter.converterClass;
String converterClass = null;
try {
converterClass = Adapters.collapsedStringAdapterAdapter.marshal(converterClassRaw);
} catch (final Exception e) {
context.xmlAdapterError(facesConverter, "converterClass", CollapsedStringAdapter.class, String.class, String.class, e);
}
if (converterClass != null) {
writer.writeStartElement(prefix, "converter-class", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(converterClass);
writer.writeEndElement();
} else {
context.unexpectedNullValue(facesConverter, "converterClass");
}
// ELEMENT: attribute
final List<FacesAttribute> attribute = facesConverter.attribute;
if (attribute != null) {
for (final FacesAttribute attributeItem : attribute) {
writer.writeStartElement(prefix, "attribute", "http://java.sun.com/xml/ns/javaee");
if (attributeItem != null) {
writeFacesAttribute(writer, attributeItem, context);
} else {
writer.writeXsiNil();
}
writer.writeEndElement();
}
}
// ELEMENT: property
final List<FacesProperty> property = facesConverter.property;
if (property != null) {
for (final FacesProperty propertyItem : property) {
writer.writeStartElement(prefix, "property", "http://java.sun.com/xml/ns/javaee");
if (propertyItem != null) {
writeFacesProperty(writer, propertyItem, context);
} else {
writer.writeXsiNil();
}
writer.writeEndElement();
}
}
// ELEMENT: converterExtension
final List<FacesConverterExtension> converterExtension = facesConverter.converterExtension;
if (converterExtension != null) {
for (final FacesConverterExtension converterExtensionItem : converterExtension) {
if (converterExtensionItem != null) {
writer.writeStartElement(prefix, "converter-extension", "http://java.sun.com/xml/ns/javaee");
writeFacesConverterExtension(writer, converterExtensionItem, context);
writer.writeEndElement();
}
}
}
context.afterMarshal(facesConverter, LifecycleCallback.NONE);
}
Aggregations