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