/** * PUBLIC: * Convert the given object to XML and update the given contentHandler with that XML Document * @param object the object to marshal * @param contentHandler the contentHandler which the specified object should be marshalled to * @throws XMLMarshalException if an error occurred during marshalling */ public void marshal(Object object, ContentHandler contentHandler) throws XMLMarshalException { marshal(object, contentHandler, null); }
/** * Convert the given object to XML and update the given marshal record with * that XML Document. * @param object the object to marshal * @param marshalRecord the marshalRecord to marshal the object to */ protected void marshal(Object object, AbstractSession session, MarshalRecord marshalRecord) { boolean isXMLRoot = (object instanceof Root); marshal(object, marshalRecord, session, getDescriptor(object, isXMLRoot), isXMLRoot); }
/** * Convert the given object to XML and update the given marshal record with * that XML Document. * @param object the object to marshal * @param marshalRecord the marshalRecord to marshal the object to */ protected void marshal(Object object, AbstractSession session, MarshalRecord marshalRecord) { boolean isXMLRoot = (object instanceof XMLRoot); marshal(object, marshalRecord, session, getDescriptor(object, isXMLRoot), isXMLRoot); }
/** * Convert the given object to XML and update the given marshal record with * that XML Document. * @param object the object to marshal * @param marshalRecord the marshalRecord to marshal the object to */ protected void marshal(Object object, AbstractSession session, MarshalRecord marshalRecord) { boolean isXMLRoot = (object instanceof Root); marshal(object, marshalRecord, session, getDescriptor(object, isXMLRoot), isXMLRoot); }
public void marshal(Object object, Result result) throws JAXBException { if (object == null || result == null) { throw new IllegalArgumentException(); } object = validateAndTransformIfNeeded(object); // xml bindings + json object try { xmlMarshaller.marshal(object, result); } catch (BeanValidationException bve) { throw new MarshalException(bve.getMessage(), String.valueOf(bve.getErrorCode()), bve); } catch (Exception e) { throw new MarshalException(e); } }
@Override public void marshal(Object object, Result result) throws JAXBException { if (object == null || result == null) { throw new IllegalArgumentException(); } object = validateAndTransformIfNeeded(object); // xml bindings + json object try { xmlMarshaller.marshal(object, result); } catch (BeanValidationException bve) { throw new MarshalException(bve.getMessage(), String.valueOf(bve.getErrorCode()), bve); } catch (Exception e) { throw new MarshalException(e); } }
/** * INTENAL: */ public static void write(XMLEntityMappings entityMappings, Writer writer) { XMLContext context = XMLEntityMappingsReader.getEclipseLinkOrmProject(); XMLMarshaller marshaller = context.createMarshaller(); marshaller.setSchemaLocation(XMLEntityMappingsReader.ECLIPSELINK_ORM_NAMESPACE + " " + XMLEntityMappingsReader.ECLIPSELINK_ORM_XSD); marshaller.marshal(entityMappings, writer); try { writer.flush(); } catch (IOException exception) { throw ValidationException.fileError(exception); } } }
public void marshal(Object object, MarshalRecord record) throws JAXBException { if (object == null || record == null) { throw new IllegalArgumentException(); } object = validateAndTransformIfNeeded(object); // xml bindings + object try { record.setMarshaller(xmlMarshaller); xmlMarshaller.marshal(object, record); } catch (BeanValidationException bve) { throw new MarshalException(bve.getMessage(), String.valueOf(bve.getErrorCode()), bve); } catch (Exception e) { throw new MarshalException(e); } }
public void marshal(Object object, MarshalRecord record) throws JAXBException { if (object == null || record == null) { throw new IllegalArgumentException(); } object = validateAndTransformIfNeeded(object); // xml bindings + object try { record.setMarshaller(xmlMarshaller); xmlMarshaller.marshal(object, record); } catch (BeanValidationException bve) { throw new MarshalException(bve.getMessage(), String.valueOf(bve.getErrorCode()), bve); } catch (Exception e) { throw new MarshalException(e); } }
/** * Given the writer, and a SessionConfigs, * this writes out the session XML file. * * @param writer writer to writer to * @param eclipseLinkSessions the SessionConfigs instance to write */ public static void write(SessionConfigs toplinkSessions, Writer writer) { XMLContext context = new XMLContext(new XMLSessionConfigProject_11_1_1()); XMLMarshaller marshaller = context.createMarshaller(); // this is throwing a null pointer exception right now, bug entered //marshaller.setNoNamespaceSchemaLocation("eclipse_persistence_sessions_1_0.xsd"); marshaller.marshal(toplinkSessions, writer); try { writer.flush(); } catch (IOException exception) { throw ValidationException.fileError(exception); } } }
/** * Given the writer, and a SessionConfigs, * this writes out the session XML file. * * @param writer writer to writer to * @param eclipseLinkSessions the SessionConfigs instance to write */ public static void write(SessionConfigs toplinkSessions, Writer writer) { XMLContext context = new XMLContext(new XMLSessionConfigProject_11_1_1()); XMLMarshaller marshaller = context.createMarshaller(); // this is throwing a null pointer exception right now, bug entered //marshaller.setNoNamespaceSchemaLocation("eclipse_persistence_sessions_1_0.xsd"); marshaller.marshal(toplinkSessions, writer); try { writer.flush(); } catch (IOException exception) { throw ValidationException.fileError(exception); } } }
/** * Given the writer, and a SessionConfigs, * this writes out the session XML file. * * @param writer writer to writer to * @param eclipseLinkSessions the SessionConfigs instance to write */ public static void write(SessionConfigs toplinkSessions, Writer writer) { XMLContext context = new XMLContext(new XMLSessionConfigProject_11_1_1()); XMLMarshaller marshaller = context.createMarshaller(); // this is throwing a null pointer exception right now, bug entered //marshaller.setNoNamespaceSchemaLocation("eclipse_persistence_sessions_1_0.xsd"); marshaller.marshal(toplinkSessions, writer); try { writer.flush(); } catch (IOException exception) { throw ValidationException.fileError(exception); } } }
public void marshal(Object object, Node node) throws JAXBException { if (object == null || node == null) { throw new IllegalArgumentException(); } Listener listener = getListener(); if(listener != null) { if(object instanceof JAXBElement) { listener.beforeMarshal(object); } } Object oxmObject = validateAndTransformIfNeeded(object); // xml bindings + object try { xmlMarshaller.marshal(oxmObject, node); } catch (BeanValidationException bve) { throw new MarshalException(bve.getMessage(), String.valueOf(bve.getErrorCode()), bve); } catch (Exception e) { throw new MarshalException(e); } if(listener != null) { if(object instanceof JAXBElement) { listener.afterMarshal(object); } } }
/** * PUBLIC: * Given the writer, and a project, * this writes out the deployment XML file storing the project's descriptor and mapping information. * * @param writer writer to writer to * @param project the project instance to write */ public static void write(Project project, Writer writer) { XMLContext context = new XMLContext(new ObjectPersistenceWorkbenchXMLProject()); context.getSession(project).getEventManager().addListener(new MissingDescriptorListener()); XMLMarshaller marshaller = context.createMarshaller(); marshaller.marshal(project, writer); try { writer.flush(); } catch (IOException exception) { throw ValidationException.fileError(exception); } }
/** * PUBLIC: * Given the writer, and a project, * this writes out the deployment XML file storing the project's descriptor and mapping information. * * @param writer writer to writer to * @param project the project instance to write */ public static void write(Project project, Writer writer) { XMLContext context = new XMLContext(new ObjectPersistenceWorkbenchXMLProject()); context.getSession(project).getEventManager().addListener(new MissingDescriptorListener()); XMLMarshaller marshaller = context.createMarshaller(); marshaller.marshal(project, writer); try { writer.flush(); } catch (IOException exception) { throw ValidationException.fileError(exception); } }
/** * PUBLIC: * Given the writer, and a project, * this writes out the deployment XML file storing the project's descriptor and mapping information. * * @param writer writer to writer to * @param project the project instance to write */ public static void write(Project project, Writer writer) { XMLContext context = new XMLContext(new ObjectPersistenceWorkbenchXMLProject()); context.getSession(project).getEventManager().addListener(new MissingDescriptorListener()); XMLMarshaller marshaller = context.createMarshaller(); marshaller.marshal(project, writer); try { writer.flush(); } catch (IOException exception) { throw ValidationException.fileError(exception); } }
private Object buildFragment(Property property, SDODataObject parentObject, SDODataObject value) { //build an XML Fragment from this SDO XMLPlatform xmlPlatform = XMLPlatformFactory.getInstance().getXMLPlatform(); XMLMarshaller xmlMarshaller = ((SDOXMLHelper)helperContext.getXMLHelper()).getXmlContext().createMarshaller(); Document doc = xmlPlatform.createDocument(); XMLRoot root = new XMLRoot(); root.setObject(value); root.setLocalName(property.getName()); if(((SDOProperty)property).isNamespaceQualified()){ root.setNamespaceURI(parentObject.getType().getURI()); } xmlMarshaller.marshal(root, doc); return doc.getDocumentElement(); } }
private Object buildFragment(Property property, SDODataObject parentObject, SDODataObject value) { //build an XML Fragment from this SDO XMLPlatform xmlPlatform = XMLPlatformFactory.getInstance().getXMLPlatform(); XMLMarshaller xmlMarshaller = ((SDOXMLHelper)helperContext.getXMLHelper()).getXmlContext().createMarshaller(); Document doc = xmlPlatform.createDocument(); XMLRoot root = new XMLRoot(); root.setObject(value); root.setLocalName(property.getName()); if(((SDOProperty)property).isNamespaceQualified()){ root.setNamespaceURI(parentObject.getType().getURI()); } xmlMarshaller.marshal(root, doc); return doc.getDocumentElement(); } }
public Map<String, SchemaTypeInfo> generateSchemaFiles(String schemaPath, Map<QName, Type> additionalGlobalElements) throws FileNotFoundException { // process any additional global elements processAdditionalElements(additionalGlobalElements, annotationsProcessor); schemaGenerator.generateSchema(annotationsProcessor.getTypeInfoClasses(), annotationsProcessor.getTypeInfos(), annotationsProcessor.getUserDefinedSchemaTypes(), annotationsProcessor.getPackageToPackageInfoMappings(), annotationsProcessor.getGlobalElements(), annotationsProcessor.getArrayClassesToGeneratedClasses()); CoreProject proj = new SchemaModelProject(); XMLContext context = new XMLContext((Project)proj); XMLMarshaller marshaller = context.createMarshaller(); Descriptor schemaDescriptor = (Descriptor)proj.getDescriptor(Schema.class); java.util.Collection<Schema> schemas = schemaGenerator.getAllSchemas(); for(Schema schema : schemas) { File file = new File(schemaPath + "/" + schema.getName()); NamespaceResolver schemaNamespaces = schema.getNamespaceResolver(); schemaNamespaces.put(Constants.SCHEMA_PREFIX, XMLConstants.W3C_XML_SCHEMA_NS_URI); schemaDescriptor.setNamespaceResolver(schemaNamespaces); marshaller.marshal(schema, new FileOutputStream(file)); } return schemaGenerator.getSchemaTypeInfo(); }
public Map<String, SchemaTypeInfo> generateSchemaFiles(String schemaPath, Map<QName, Type> additionalGlobalElements) throws FileNotFoundException { // process any additional global elements processAdditionalElements(additionalGlobalElements, annotationsProcessor); schemaGenerator.generateSchema(annotationsProcessor.getTypeInfoClasses(), annotationsProcessor.getTypeInfos(), annotationsProcessor.getUserDefinedSchemaTypes(), annotationsProcessor.getPackageToPackageInfoMappings(), annotationsProcessor.getGlobalElements(), annotationsProcessor.getArrayClassesToGeneratedClasses()); CoreProject proj = new SchemaModelProject(); XMLContext context = new XMLContext((Project)proj); XMLMarshaller marshaller = context.createMarshaller(); Descriptor schemaDescriptor = (Descriptor)proj.getDescriptor(Schema.class); java.util.Collection<Schema> schemas = schemaGenerator.getAllSchemas(); for(Schema schema : schemas) { File file = new File(schemaPath + "/" + schema.getName()); NamespaceResolver schemaNamespaces = schema.getNamespaceResolver(); schemaNamespaces.put(Constants.SCHEMA_PREFIX, XMLConstants.W3C_XML_SCHEMA_NS_URI); schemaDescriptor.setNamespaceResolver(schemaNamespaces); marshaller.marshal(schema, new FileOutputStream(file)); } return schemaGenerator.getSchemaTypeInfo(); }