Search in sources :

Example 1 with StreamDocumentTarget

use of org.semanticweb.owlapi.io.StreamDocumentTarget in project stanbol by apache.

the class ResponseTaskBuilder method stream.

/**
     * This supports OWLOntology and jena Model objects.
     * In the case of Jena the reuslt is printed as Turtle, 
     * in case of OWLApi the result is in Manchester syntax (more readable).
     * 
     * FIXME: Both should return the same format
     * 
     * @param object
     * @return
     */
private OutputStream stream(Object object) {
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    if (object instanceof OWLOntology) {
        OWLOntology o = (OWLOntology) object;
        ManchesterOWLSyntaxOntologyStorer mosos = new ManchesterOWLSyntaxOntologyStorer();
        try {
            mosos.storeOntology(o.getOWLOntologyManager(), o, new StreamDocumentTarget(out), new ManchesterOWLSyntaxOntologyFormat());
        } catch (OWLOntologyStorageException e) {
            log.error("Cannot stream the ontology", e);
            throw new RuntimeException(e);
        }
    } else if (object instanceof Model) {
        Model m = (Model) object;
        // FIXME Both should return the same format
        m.write(out, "TURTLE");
    }
    return out;
}
Also used : ManchesterOWLSyntaxOntologyFormat(org.coode.owlapi.manchesterowlsyntax.ManchesterOWLSyntaxOntologyFormat) OWLOntology(org.semanticweb.owlapi.model.OWLOntology) Model(com.hp.hpl.jena.rdf.model.Model) ByteArrayOutputStream(java.io.ByteArrayOutputStream) StreamDocumentTarget(org.semanticweb.owlapi.io.StreamDocumentTarget) ManchesterOWLSyntaxOntologyStorer(uk.ac.manchester.cs.owl.owlapi.mansyntaxrenderer.ManchesterOWLSyntaxOntologyStorer) OWLOntologyStorageException(org.semanticweb.owlapi.model.OWLOntologyStorageException)

Aggregations

Model (com.hp.hpl.jena.rdf.model.Model)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 ManchesterOWLSyntaxOntologyFormat (org.coode.owlapi.manchesterowlsyntax.ManchesterOWLSyntaxOntologyFormat)1 StreamDocumentTarget (org.semanticweb.owlapi.io.StreamDocumentTarget)1 OWLOntology (org.semanticweb.owlapi.model.OWLOntology)1 OWLOntologyStorageException (org.semanticweb.owlapi.model.OWLOntologyStorageException)1 ManchesterOWLSyntaxOntologyStorer (uk.ac.manchester.cs.owl.owlapi.mansyntaxrenderer.ManchesterOWLSyntaxOntologyStorer)1