Package org.semanticweb.owlapi.model

Examples of org.semanticweb.owlapi.model.OWLOntologyStorageException


                    ontology, writer);
            renderer.setPrefixManager(new LabelPrefixManager(ontology));
            ontology.accept(renderer);
            writer.flush();
        } catch (IOException e) {
            throw new OWLOntologyStorageException(e);
        }
    }
View Full Code Here


                StringBuilder sb = new StringBuilder();
                for (OWLEntity entity : entities) {
                    sb.append(entity.toStringID());
                    sb.append('\n');
                }
                throw new OWLOntologyStorageException(sb.toString().trim(),
                        new IllegalElementNameException(sb.toString().trim()));
            }
            renderer.render();
        } catch (IOException e) {
            throw new OWLOntologyStorageException(e);
        } catch (IllegalElementNameException e) {
            throw new OWLOntologyStorageException(e);
        }
    }
View Full Code Here

            return new StatementCollector();
        } else {
            try {
                return Rio.createWriter(format, outputStream);
            } catch (final UnsupportedRDFormatException e) {
                throw new OWLOntologyStorageException(e);
            }
        }
    }
View Full Code Here

        // render the output, even if it does not render to a writer. For
        // example, it could store the triples in memory without serialising
        // them to any particular format.
        if (rioHandler == null) {
            if (!(format instanceof RioRDFDocumentFormat)) {
                throw new OWLOntologyStorageException(
                        "Unable to use RioOntologyStorer to store this format as it is not recognised as a RioRDFOntologyFormat: "
                                + format);
            }
            final RioRDFDocumentFormat rioFormat = (RioRDFDocumentFormat) format;
            if (format.isTextual()) {
                rioHandler = getRDFHandlerForWriter(rioFormat.getRioFormat(),
                        writer);
            } else {
                throw new OWLOntologyStorageException(
                        "Unable to use storeOntology with a Writer as the desired format is not textual. Format was "
                                + format);
            }
        }
        try {
            final RioRenderer ren = new RioRenderer(ontology, rioHandler,
                    format, contexts);
            ren.render();
        } catch (final IOException e) {
            throw new OWLOntologyStorageException(e);
        }
    }
View Full Code Here

        // render the output, even if it does not render to a writer. For
        // example, it could store the triples in memory without serialising
        // them to any particular format.
        if (rioHandler == null) {
            if (!(format instanceof RioRDFDocumentFormat)) {
                throw new OWLOntologyStorageException(
                        "Unable to use RioOntologyStorer to store this format as it is not recognised as a RioRDFOntologyFormat: "
                                + format);
            }
            final RioRDFDocumentFormat rioFormat = (RioRDFDocumentFormat) format;
            if (format.isTextual()) {
                try {
                    Writer writer = new BufferedWriter(new OutputStreamWriter(
                            outputStream, UTF_8));
                    rioHandler = getRDFHandlerForWriter(
                            rioFormat.getRioFormat(), writer);
                } catch (IOException e) {
                    throw new OWLOntologyStorageException(e);
                }
            } else {
                rioHandler = getRDFHandlerForOutputStream(
                        rioFormat.getRioFormat(), outputStream);
            }
        }
        try {
            final RioRenderer ren = new RioRenderer(ontology, rioHandler,
                    format, contexts);
            ren.render();
        } catch (final IOException e) {
            throw new OWLOntologyStorageException(e);
        }
    }
View Full Code Here

            return new StatementCollector();
        } else {
            try {
                return Rio.createWriter(format, writer);
            } catch (final UnsupportedRDFormatException e) {
                throw new OWLOntologyStorageException(e);
            }
        }
    }
View Full Code Here

    @Override
    public void storeOntology(OWLOntology ontology, @Nonnull IRI documentIRI,
            OWLDocumentFormat ontologyFormat)
            throws OWLOntologyStorageException {
        if (!documentIRI.isAbsolute()) {
            throw new OWLOntologyStorageException(
                    "Document IRI must be absolute: " + documentIRI);
        }
        try {
            OutputStream os = null;
            try {
                // prepare actual output
                os = prepareActualOutput(documentIRI);
                store(ontology, ontologyFormat, os);
            } finally {
                if (os != null) {
                    os.close();
                }
            }
        } catch (IOException e) {
            throw new OWLOntologyStorageException(e);
        }
    }
View Full Code Here

        if (format.isTextual() && target.isWriterAvailable()) {
            try (Writer w = target.getWriter();) {
                storeOntology(ontology, w, format);
                w.flush();
            } catch (IOException e) {
                throw new OWLOntologyStorageException(e);
            }
        } else if (target.isOutputStreamAvailable()) {
            try {
                storeOntology(ontology, target.getOutputStream(), format);
            } catch (IOException e) {
                throw new OWLOntologyStorageException(e);
            }
        } else if (target.isDocumentIRIAvailable()) {
            storeOntology(ontology, target.getDocumentIRI(), format);
        } else {
            throw new OWLOntologyStorageException(
                    "Neither a Writer, OutputStream or Document IRI could be obtained to store the ontology in this format: "
                            + format.getKey());
        }
    }
View Full Code Here

    protected void storeOntology(@Nonnull OWLOntology ontology,
            @Nonnull OutputStream outputStream,
            @Nonnull OWLDocumentFormat format)
            throws OWLOntologyStorageException {
        if (!format.isTextual()) {
            throw new OWLOntologyStorageException(
                    "This method must be overridden to support this binary format: "
                            + format.getKey());
        }
        try {
            Writer writer = new BufferedWriter(new OutputStreamWriter(
                    outputStream, UTF_8));
            storeOntology(ontology, writer, format);
            writer.flush();
        } catch (IOException e) {
            throw new OWLOntologyStorageException(e);
        }
    }
View Full Code Here

            OWLDocumentFormat format) throws OWLOntologyStorageException {
        try {
            TurtleRenderer ren = new TurtleRenderer(ontology, writer, format);
            ren.render();
        } catch (IOException e) {
            throw new OWLOntologyStorageException(e);
        }
    }
View Full Code Here

TOP

Related Classes of org.semanticweb.owlapi.model.OWLOntologyStorageException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.