use of org.eclipse.persistence.oxm.XMLUnionField in project eclipselink by eclipse-ee4j.
the class SimpleUnionPositionalXMLAttributeProject method getPersonDescriptor.
private XMLDescriptor getPersonDescriptor() {
XMLDescriptor descriptor = new XMLDescriptor();
descriptor.setJavaClass(Person.class);
descriptor.setDefaultRootElement("person");
NamespaceResolver resolver = new NamespaceResolver();
resolver.put(XMLConstants.SCHEMA_INSTANCE_PREFIX, javax.xml.XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI);
resolver.put(XMLConstants.SCHEMA_PREFIX, javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI);
descriptor.setNamespaceResolver(resolver);
XMLCompositeDirectCollectionMapping itemsMapping = new XMLCompositeDirectCollectionMapping();
itemsMapping.setAttributeName("items");
itemsMapping.setGetMethodName("getItems");
itemsMapping.setSetMethodName("setItems");
itemsMapping.useCollectionClass(java.util.ArrayList.class);
XMLUnionField field = new XMLUnionField("items[1]/@item");
QName dateQname = new QName(javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI, "date");
QName integerQName = new QName(javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI, "integer");
field.addSchemaType(dateQname);
field.addSchemaType(integerQName);
itemsMapping.setField(field);
descriptor.addMapping(itemsMapping);
XMLDirectMapping firstNameMapping = new XMLDirectMapping();
firstNameMapping.setAttributeName("firstName");
firstNameMapping.setXPath("first-name/text()");
descriptor.addMapping(firstNameMapping);
XMLDirectMapping lastNameMapping = new XMLDirectMapping();
lastNameMapping.setAttributeName("lastName");
lastNameMapping.setXPath("last-name/text()");
descriptor.addMapping(lastNameMapping);
return descriptor;
}
use of org.eclipse.persistence.oxm.XMLUnionField in project eclipselink by eclipse-ee4j.
the class SimpleUnionProject method getPersonDescriptor.
private XMLDescriptor getPersonDescriptor() {
XMLDescriptor descriptor = new XMLDescriptor();
descriptor.setJavaClass(Person.class);
descriptor.setDefaultRootElement("person");
NamespaceResolver resolver = new NamespaceResolver();
resolver.put(XMLConstants.SCHEMA_INSTANCE_PREFIX, javax.xml.XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI);
resolver.put(XMLConstants.SCHEMA_PREFIX, javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI);
descriptor.setNamespaceResolver(resolver);
XMLDirectMapping ageMapping = new XMLDirectMapping();
ageMapping.setAttributeName("age");
XMLUnionField field = new XMLUnionField("age/text()");
QName qname = new QName(javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI, "date");
QName integerQName = new QName(javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI, "integer");
field.setSchemaType(qname);
field.addSchemaType(integerQName);
field.addSchemaType(integerQName);
ageMapping.setField(field);
descriptor.addMapping(ageMapping);
XMLDirectMapping firstNameMapping = new XMLDirectMapping();
firstNameMapping.setAttributeName("firstName");
firstNameMapping.setXPath("first-name/text()");
descriptor.addMapping(firstNameMapping);
XMLDirectMapping lastNameMapping = new XMLDirectMapping();
lastNameMapping.setAttributeName("lastName");
lastNameMapping.setXPath("last-name/text()");
descriptor.addMapping(lastNameMapping);
return descriptor;
}
use of org.eclipse.persistence.oxm.XMLUnionField in project eclipselink by eclipse-ee4j.
the class XMLObjectReferenceMapping method getSchemaType.
/**
* Return a QName representation the schema type for a given XMLField, if
* applicable.
*
* Note: This method performs the same functionality as 'getSchemaType' in
* org.eclipse.persistence.internal.oxm.XMLSimpleMappingNodeValue.
*/
protected QName getSchemaType(XMLField xmlField, Object value, AbstractSession session) {
QName schemaType = null;
if (xmlField.isTypedTextField()) {
ConversionManager conversionManager = (ConversionManager) session.getDatasourcePlatform().getConversionManager();
schemaType = xmlField.getXMLType(value.getClass(), conversionManager);
} else if (xmlField.isUnionField()) {
return getSingleValueToWriteForUnion((XMLUnionField) xmlField, value, session);
} else if (xmlField.getSchemaType() != null) {
schemaType = xmlField.getSchemaType();
}
return schemaType;
}
use of org.eclipse.persistence.oxm.XMLUnionField in project eclipselink by eclipse-ee4j.
the class SimpleUnionXMLAttributeProject method getPersonDescriptor.
private XMLDescriptor getPersonDescriptor() {
XMLDescriptor descriptor = new XMLDescriptor();
descriptor.setJavaClass(Person.class);
descriptor.setDefaultRootElement("person");
NamespaceResolver resolver = new NamespaceResolver();
resolver.put(XMLConstants.SCHEMA_INSTANCE_PREFIX, javax.xml.XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI);
resolver.put(XMLConstants.SCHEMA_PREFIX, javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI);
descriptor.setNamespaceResolver(resolver);
XMLDirectMapping ageMapping = new XMLDirectMapping();
ageMapping.setAttributeName("age");
XMLUnionField field = new XMLUnionField("age-info/@age");
QName qname = new QName(javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI, "date");
QName integerQName = new QName(javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI, "integer");
field.setSchemaType(qname);
field.addSchemaType(integerQName);
field.addSchemaType(integerQName);
ageMapping.setField(field);
descriptor.addMapping(ageMapping);
XMLDirectMapping firstNameMapping = new XMLDirectMapping();
firstNameMapping.setAttributeName("firstName");
firstNameMapping.setXPath("first-name/text()");
descriptor.addMapping(firstNameMapping);
XMLDirectMapping lastNameMapping = new XMLDirectMapping();
lastNameMapping.setAttributeName("lastName");
lastNameMapping.setXPath("last-name/text()");
descriptor.addMapping(lastNameMapping);
return descriptor;
}
use of org.eclipse.persistence.oxm.XMLUnionField in project eclipselink by eclipse-ee4j.
the class SimpleUnionProject method getPersonDescriptor.
private XMLDescriptor getPersonDescriptor() {
XMLDescriptor descriptor = new XMLDescriptor();
descriptor.setJavaClass(Person.class);
descriptor.setDefaultRootElement("person");
NamespaceResolver resolver = new NamespaceResolver();
resolver.put(XMLConstants.SCHEMA_INSTANCE_PREFIX, javax.xml.XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI);
resolver.put(XMLConstants.SCHEMA_PREFIX, javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI);
descriptor.setNamespaceResolver(resolver);
XMLCompositeDirectCollectionMapping itemsMapping = new XMLCompositeDirectCollectionMapping();
itemsMapping.setAttributeName("items");
itemsMapping.setGetMethodName("getItems");
itemsMapping.setSetMethodName("setItems");
itemsMapping.useCollectionClass(java.util.ArrayList.class);
XMLUnionField field = new XMLUnionField("item/text()");
QName dateQname = new QName(javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI, "date");
QName integerQName = new QName(javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI, "integer");
field.addSchemaType(dateQname);
field.addSchemaType(integerQName);
itemsMapping.setField(field);
descriptor.addMapping(itemsMapping);
XMLDirectMapping firstNameMapping = new XMLDirectMapping();
firstNameMapping.setAttributeName("firstName");
firstNameMapping.setXPath("first-name/text()");
descriptor.addMapping(firstNameMapping);
XMLDirectMapping lastNameMapping = new XMLDirectMapping();
lastNameMapping.setAttributeName("lastName");
lastNameMapping.setXPath("last-name/text()");
descriptor.addMapping(lastNameMapping);
return descriptor;
}
Aggregations