Search in sources :

Example 6 with XMLDescriptor

use of org.eclipse.persistence.oxm.XMLDescriptor in project eclipselink by eclipse-ee4j.

the class TestModelProject method addCollectionReferenceTargetDescriptor.

public void addCollectionReferenceTargetDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClassName("org.persistence.testing.jaxb.dynamic.xxx.CollectionReferenceTarget");
    descriptor.addPrimaryKeyFieldName("@id");
    descriptor.setNamespaceResolver(nsResolver);
    XMLDirectMapping id = new XMLDirectMapping();
    id.setAttributeName("id");
    id.setXPath("@id");
    descriptor.addMapping(id);
    XMLDirectMapping value = new XMLDirectMapping();
    value.setAttributeName("value");
    value.setXPath("value/text()");
    descriptor.addMapping(value);
    this.addDescriptor(descriptor);
}
Also used : XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) XMLDirectMapping(org.eclipse.persistence.oxm.mappings.XMLDirectMapping)

Example 7 with XMLDescriptor

use of org.eclipse.persistence.oxm.XMLDescriptor in project eclipselink by eclipse-ee4j.

the class TestModelProject method addCompositeCollectionTargetDescriptor.

public void addCompositeCollectionTargetDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClassName("org.persistence.testing.jaxb.dynamic.xxx.CompositeCollectionTarget");
    descriptor.setNamespaceResolver(nsResolver);
    XMLDirectMapping value = new XMLDirectMapping();
    value.setAttributeName("value");
    value.setXPath("value/text()");
    descriptor.addMapping(value);
    XMLInverseReferenceMapping invRef = new XMLInverseReferenceMapping();
    invRef.setReferenceClassName("org.persistence.testing.jaxb.dynamic.xxx.Root");
    invRef.setMappedBy("compColl");
    invRef.setAttributeName("invRef");
    descriptor.addMapping(invRef);
    this.addDescriptor(descriptor);
}
Also used : XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) XMLDirectMapping(org.eclipse.persistence.oxm.mappings.XMLDirectMapping) XMLInverseReferenceMapping(org.eclipse.persistence.oxm.mappings.XMLInverseReferenceMapping)

Example 8 with XMLDescriptor

use of org.eclipse.persistence.oxm.XMLDescriptor in project eclipselink by eclipse-ee4j.

the class TestModelProject method addAnyCollectionTargetDescriptor.

public void addAnyCollectionTargetDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClassName("org.persistence.testing.jaxb.dynamic.xxx.AnyCollectionTarget");
    descriptor.setDefaultRootElement("any-coll-value");
    descriptor.setNamespaceResolver(nsResolver);
    XMLDirectMapping value = new XMLDirectMapping();
    value.setAttributeName("value");
    value.setXPath("text()");
    descriptor.addMapping(value);
    this.addDescriptor(descriptor);
}
Also used : XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) XMLDirectMapping(org.eclipse.persistence.oxm.mappings.XMLDirectMapping)

Example 9 with XMLDescriptor

use of org.eclipse.persistence.oxm.XMLDescriptor in project eclipselink by eclipse-ee4j.

the class XmlAnyElementListTestCases method testContainerType.

public void testContainerType() {
    XMLDescriptor xDesc = xmlContext.getDescriptor(new QName("employee"));
    assertNotNull("No descriptor was generated for EmployeeWithList.", xDesc);
    DatabaseMapping mapping = xDesc.getMappingForAttributeName("stuff");
    assertNotNull("No mapping exists on EmployeeWithList for attribute [stuff].", mapping);
    assertTrue("Expected an XMLAnyCollectionMapping for attribute [stuff], but was [" + mapping.toString() + "].", mapping instanceof XMLAnyCollectionMapping);
    assertTrue("Expected container class [java.util.LinkedList] but was [" + mapping.getContainerPolicy().getContainerClassName() + "]", mapping.getContainerPolicy().getContainerClassName().equals("java.util.LinkedList"));
}
Also used : XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) QName(javax.xml.namespace.QName) XMLAnyCollectionMapping(org.eclipse.persistence.oxm.mappings.XMLAnyCollectionMapping) DatabaseMapping(org.eclipse.persistence.mappings.DatabaseMapping)

Example 10 with XMLDescriptor

use of org.eclipse.persistence.oxm.XMLDescriptor in project eclipselink by eclipse-ee4j.

the class XmlValueCdnPricesTestCases method testContainerType.

public void testContainerType() {
    XMLDescriptor xDesc = xmlContext.getDescriptor(new QName("canadian-price"));
    assertNotNull("No descriptor was generated for CDNPricesNoAnnotation.", xDesc);
    DatabaseMapping mapping = xDesc.getMappingForAttributeName("prices");
    assertNotNull("No mapping exists on CDNPricesNoAnnotation for attribute [prices].", mapping);
    assertTrue("Expected an XMLCompositeDirectCollectionMapping for attribute [prices], but was [" + mapping.toString() + "].", mapping instanceof XMLCompositeDirectCollectionMapping);
    assertTrue("Expected container class [java.util.LinkedList] but was [" + mapping.getContainerPolicy().getContainerClassName() + "]", mapping.getContainerPolicy().getContainerClassName().equals("java.util.LinkedList"));
}
Also used : XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) QName(javax.xml.namespace.QName) DatabaseMapping(org.eclipse.persistence.mappings.DatabaseMapping) XMLCompositeDirectCollectionMapping(org.eclipse.persistence.oxm.mappings.XMLCompositeDirectCollectionMapping)

Aggregations

XMLDescriptor (org.eclipse.persistence.oxm.XMLDescriptor)1206 XMLDirectMapping (org.eclipse.persistence.oxm.mappings.XMLDirectMapping)629 XMLCompositeObjectMapping (org.eclipse.persistence.oxm.mappings.XMLCompositeObjectMapping)198 XMLCompositeCollectionMapping (org.eclipse.persistence.oxm.mappings.XMLCompositeCollectionMapping)151 XMLField (org.eclipse.persistence.oxm.XMLField)143 NamespaceResolver (org.eclipse.persistence.oxm.NamespaceResolver)141 QName (javax.xml.namespace.QName)75 XMLSchemaClassPathReference (org.eclipse.persistence.oxm.schema.XMLSchemaClassPathReference)69 XMLCompositeDirectCollectionMapping (org.eclipse.persistence.oxm.mappings.XMLCompositeDirectCollectionMapping)49 ArrayList (java.util.ArrayList)37 DatabaseMapping (org.eclipse.persistence.mappings.DatabaseMapping)37 XMLSchemaURLReference (org.eclipse.persistence.oxm.schema.XMLSchemaURLReference)36 XMLRoot (org.eclipse.persistence.oxm.XMLRoot)34 XMLCollectionReferenceMapping (org.eclipse.persistence.oxm.mappings.XMLCollectionReferenceMapping)32 XMLObjectReferenceMapping (org.eclipse.persistence.oxm.mappings.XMLObjectReferenceMapping)32 Document (org.w3c.dom.Document)31 AttributeAccessor (org.eclipse.persistence.mappings.AttributeAccessor)30 ClassDescriptor (org.eclipse.persistence.descriptors.ClassDescriptor)29 URL (java.net.URL)27 ObjectTypeConverter (org.eclipse.persistence.mappings.converters.ObjectTypeConverter)27