Search in sources :

Example 11 with XMLDescriptor

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

the class MapNamespaceTestCases method testObjectToXMLWithContentHandler.

public void testObjectToXMLWithContentHandler() throws Exception {
    Object objectToWrite = getWriteControlObject();
    StringWriter writer = new StringWriter();
    PrintWriter printWriter = new PrintWriter(writer);
    DataWriter dataWriter = new DataWriter(printWriter, "UTF-8", new DummyCharacterEscapeHandler());
    XMLDescriptor desc = null;
    if (objectToWrite instanceof XMLRoot) {
        desc = (XMLDescriptor) xmlContext.getSession(0).getProject().getDescriptor(((XMLRoot) objectToWrite).getObject().getClass());
    } else {
        desc = (XMLDescriptor) xmlContext.getSession(0).getProject().getDescriptor(objectToWrite.getClass());
    }
    int sizeBefore = getNamespaceResolverSize(desc);
    jaxbMarshaller.setProperty(MarshallerProperties.MEDIA_TYPE, "application/xml");
    jaxbMarshaller.setProperty("org.glassfish.jaxb.xmlDeclaration", Boolean.FALSE);
    try {
        jaxbMarshaller.marshal(objectToWrite, dataWriter);
    } catch (Exception e) {
        assertMarshalException(e);
        return;
    }
    if (expectsMarshalException) {
        fail("An exception should have occurred but didn't.");
        return;
    }
    int sizeAfter = getNamespaceResolverSize(desc);
    assertEquals(sizeBefore, sizeAfter);
    Document testDocument = getTestDocument(writer.toString());
    writer.close();
    objectToXMLDocumentTest(testDocument);
}
Also used : XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) StringWriter(java.io.StringWriter) XMLRoot(org.eclipse.persistence.oxm.XMLRoot) Document(org.w3c.dom.Document) IOException(java.io.IOException) PrintWriter(java.io.PrintWriter) DataWriter(org.glassfish.jaxb.core.marshaller.DataWriter)

Example 12 with XMLDescriptor

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

the class XMLEntityMappingsMappingProject method buildStructConverterDescriptor.

/**
 * INTERNAL:
 * XSD: struct-converter
 */
protected ClassDescriptor buildStructConverterDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(StructConverterMetadata.class);
    descriptor.addMapping(getNameAttributeMapping());
    XMLDirectMapping converterMapping = new XMLDirectMapping();
    converterMapping.setAttributeName("m_converter");
    converterMapping.setGetMethodName("getConverter");
    converterMapping.setSetMethodName("setConverter");
    converterMapping.setXPath("@converter");
    descriptor.addMapping(converterMapping);
    return descriptor;
}
Also used : XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) XMLDirectMapping(org.eclipse.persistence.oxm.mappings.XMLDirectMapping)

Example 13 with XMLDescriptor

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

the class XMLEntityMappingsMappingProject method buildPLSQLRecordDescriptor.

/**
 * INTERNAL:
 * XSD: plsql-record
 */
protected ClassDescriptor buildPLSQLRecordDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(PLSQLRecordMetadata.class);
    // Element mappings - must remain in order of definition in XML.
    descriptor.addMapping(getFieldsMapping());
    // Attribute mappings
    descriptor.addMapping(getNameAttributeMapping());
    descriptor.addMapping(getCompatibleTypeAttributeMapping());
    descriptor.addMapping(getJavaTypeAttributeMapping());
    return descriptor;
}
Also used : XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor)

Example 14 with XMLDescriptor

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

the class XMLEntityMappingsMappingProject method buildChangeTrackingDescriptor.

/**
 * INTERNAL:
 * XSD: change-tracking
 */
protected ClassDescriptor buildChangeTrackingDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(ChangeTrackingMetadata.class);
    descriptor.addMapping(getTypeAttributeMapping());
    return descriptor;
}
Also used : XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor)

Example 15 with XMLDescriptor

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

the class XMLEntityMappingsMappingProject method buildTransformationDescriptor.

/**
 * INTERNAL:
 * XSD: transformation
 */
protected ClassDescriptor buildTransformationDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(TransformationAccessor.class);
    // Element mappings - must remain in order of definition in XML.
    XMLCompositeObjectMapping readTransformerMapping = new XMLCompositeObjectMapping();
    readTransformerMapping.setAttributeName("m_readTransformer");
    readTransformerMapping.setGetMethodName("getReadTransformer");
    readTransformerMapping.setSetMethodName("setReadTransformer");
    readTransformerMapping.setReferenceClass(ReadTransformerMetadata.class);
    readTransformerMapping.setXPath("orm:read-transformer");
    descriptor.addMapping(readTransformerMapping);
    XMLCompositeCollectionMapping writeTransformersMapping = new XMLCompositeCollectionMapping();
    writeTransformersMapping.setAttributeName("m_writeTransformers");
    writeTransformersMapping.setGetMethodName("getWriteTransformers");
    writeTransformersMapping.setSetMethodName("setWriteTransformers");
    writeTransformersMapping.setReferenceClass(WriteTransformerMetadata.class);
    writeTransformersMapping.setXPath("orm:write-transformer");
    descriptor.addMapping(writeTransformersMapping);
    descriptor.addMapping(getPropertyMapping());
    descriptor.addMapping(getAccessMethodsMapping());
    // Attribute mappings
    descriptor.addMapping(getNameAttributeMapping());
    descriptor.addMapping(getFetchAttributeMapping());
    descriptor.addMapping(getOptionalAttributeMapping());
    descriptor.addMapping(getAccessAttributeMapping());
    descriptor.addMapping(getMutableAttributeMapping());
    return descriptor;
}
Also used : XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) XMLCompositeCollectionMapping(org.eclipse.persistence.oxm.mappings.XMLCompositeCollectionMapping) XMLCompositeObjectMapping(org.eclipse.persistence.oxm.mappings.XMLCompositeObjectMapping)

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