Search in sources :

Example 1 with ObjectFactory

use of eu.esdihumboldt.hale.common.core.io.project.model.internal.generated.ObjectFactory in project hale by halestudio.

the class JaxbProjectIO method save.

/**
 * Save a project to an output stream.
 *
 * @param project the project to save
 * @param out the output stream
 * @throws Exception if converting or writing the alignment fails
 */
public static void save(Project project, OutputStream out) throws Exception {
    ProjectType projType = ProjectToJaxb.convert(project);
    JAXBContext jc = JAXBContext.newInstance(PROJECT_CONTEXT, ObjectFactory.class.getClassLoader());
    Marshaller m = jc.createMarshaller();
    // Indent output
    m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
    // set encoding
    m.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
    // Specify the schema location
    // m.setProperty(Marshaller.JAXB_SCHEMA_LOCATION,
    // "http://knowledgeweb.semanticweb.org/heterogeneity/alignment align.xsd");
    ObjectFactory of = new ObjectFactory();
    try {
        m.marshal(of.createHaleProject(projType), out);
    } finally {
        out.flush();
        out.close();
    }
}
Also used : Marshaller(javax.xml.bind.Marshaller) ObjectFactory(eu.esdihumboldt.hale.common.core.io.project.model.internal.generated.ObjectFactory) ProjectType(eu.esdihumboldt.hale.common.core.io.project.model.internal.generated.ProjectType) JAXBContext(javax.xml.bind.JAXBContext)

Aggregations

ObjectFactory (eu.esdihumboldt.hale.common.core.io.project.model.internal.generated.ObjectFactory)1 ProjectType (eu.esdihumboldt.hale.common.core.io.project.model.internal.generated.ProjectType)1 JAXBContext (javax.xml.bind.JAXBContext)1 Marshaller (javax.xml.bind.Marshaller)1