use of org.eclipse.persistence.oxm.XMLField in project eclipselink by eclipse-ee4j.
the class XMLChoiceCollectionMapping method getChoiceFieldToClassAssociations.
@Override
public ArrayList getChoiceFieldToClassAssociations() {
ArrayList associations = new ArrayList();
if (this.fieldToClassNameMappings.size() > 0) {
Set<Entry<XMLField, String>> entries = fieldToClassNameMappings.entrySet();
Iterator<Entry<XMLField, String>> iter = entries.iterator();
while (iter.hasNext()) {
Entry<XMLField, String> nextEntry = iter.next();
XMLField xmlField = nextEntry.getKey();
String className = nextEntry.getValue();
XMLChoiceFieldToClassAssociation association = new XMLChoiceFieldToClassAssociation(xmlField, className);
associations.add(association);
}
}
return associations;
}
use of org.eclipse.persistence.oxm.XMLField in project eclipselink by eclipse-ee4j.
the class XMLChoiceCollectionMapping method getFieldForName.
private XMLField getFieldForName(String localName, String namespaceUri) {
Iterator<DatabaseField> fields = getFields().iterator();
while (fields.hasNext()) {
XMLField nextField = (XMLField) fields.next();
XPathFragment fragment = nextField.getXPathFragment();
while (fragment != null && (!fragment.nameIsText())) {
if (fragment.getNextFragment() == null || fragment.getHasText()) {
if (fragment.getLocalName().equals(localName)) {
String fragUri = fragment.getNamespaceURI();
if ((namespaceUri == null && fragUri == null) || (namespaceUri != null && fragUri != null && namespaceUri.equals(fragUri))) {
return nextField;
}
}
}
fragment = fragment.getNextFragment();
}
}
return null;
}
use of org.eclipse.persistence.oxm.XMLField in project eclipselink by eclipse-ee4j.
the class BinaryDataCollectionReuseProject method getEmployeeDescriptor.
private XMLDescriptor getEmployeeDescriptor(NamespaceResolver aNSResolver) {
XMLDescriptor descriptor = new XMLDescriptor();
descriptor.setJavaClass(Employee.class);
descriptor.setDefaultRootElement("employee");
XMLDirectMapping idMapping = new XMLDirectMapping();
idMapping.setAttributeName("id");
idMapping.setXPath("@id");
descriptor.addMapping(idMapping);
XMLBinaryDataCollectionMapping photosMapping = new XMLBinaryDataCollectionMapping();
photosMapping.setAttributeName("photos");
XMLField field = new XMLField("photos/list/photo");
field.setSchemaType(XMLConstants.BASE_64_BINARY_QNAME);
photosMapping.setReuseContainer(true);
photosMapping.setField(field);
descriptor.addMapping(photosMapping);
if (aNSResolver != null) {
descriptor.setNamespaceResolver(aNSResolver);
}
photosMapping.setShouldInlineBinaryData(false);
photosMapping.setSwaRef(false);
photosMapping.setMimeType("image");
photosMapping.setCollectionContentType(ClassConstants.APBYTE);
return descriptor;
}
use of org.eclipse.persistence.oxm.XMLField in project eclipselink by eclipse-ee4j.
the class BinaryDataCollectionDataHandlerProject method getEmployeeDescriptor.
@Override
protected XMLDescriptor getEmployeeDescriptor(NamespaceResolver aNSResolver) {
XMLDescriptor descriptor = new XMLDescriptor();
descriptor.setJavaClass(EmployeeWithByteArrayObject.class);
descriptor.setDefaultRootElement("employee");
XMLDirectMapping idMapping = new XMLDirectMapping();
idMapping.setAttributeName("id");
idMapping.setXPath("@id");
descriptor.addMapping(idMapping);
XMLBinaryDataCollectionMapping photosMapping = new XMLBinaryDataCollectionMapping();
photosMapping.setAttributeName("photos");
XMLField field = new XMLField("photos/list/photo");
photosMapping.setField(field);
descriptor.addMapping(photosMapping);
if (aNSResolver != null) {
descriptor.setNamespaceResolver(aNSResolver);
}
photosMapping.setShouldInlineBinaryData(false);
photosMapping.setSwaRef(true);
photosMapping.setMimeType("image");
photosMapping.setAttributeElementClass(DataHandler.class);
return descriptor;
}
use of org.eclipse.persistence.oxm.XMLField in project eclipselink by eclipse-ee4j.
the class XMLChoiceWithReferenceProject method getEmployeeDescriptor.
public XMLDescriptor getEmployeeDescriptor() {
XMLDescriptor desc = new XMLDescriptor();
desc.setJavaClass(Employee.class);
XMLDirectMapping name = new XMLDirectMapping();
name.setAttributeName("name");
name.setXPath("name/text()");
desc.addMapping(name);
XMLChoiceObjectMapping mapping = new XMLChoiceObjectMapping();
mapping.setAttributeName("contact");
List<XMLField> sourceFields = new ArrayList<XMLField>();
List<XMLField> targetFields = new ArrayList<XMLField>();
XMLField source = new XMLField("address/address-id/text()");
sourceFields.add(source);
source = new XMLField("address/zip/text()");
sourceFields.add(source);
XMLField target = new XMLField("@id");
targetFields.add(target);
target = new XMLField("zip/text()");
targetFields.add(target);
mapping.addChoiceElement(sourceFields, Address.class, targetFields);
sourceFields = new ArrayList<XMLField>();
source = new XMLField("phone/@id");
sourceFields.add(source);
targetFields = new ArrayList<XMLField>();
target = new XMLField("@id");
targetFields.add(target);
mapping.addChoiceElement(sourceFields, PhoneNumber.class, targetFields);
desc.addMapping(mapping);
return desc;
}
Aggregations