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);
}
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;
}
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;
}
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;
}
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;
}
Aggregations