use of org.sbolstandard.core.io.rdf.RdfIo in project libSBOLj by SynBioDex.
the class SBOLWriter method writeRDF.
private static void writeRDF(Writer stream, DocumentRoot<QName> document) throws XMLStreamException, FactoryConfigurationError, CoreIoException {
XMLStreamWriter xmlWriter = new IndentingXMLStreamWriter(XMLOutputFactory.newInstance().createXMLStreamWriter(stream));
RdfIo rdfIo = new RdfIo();
rdfIo.createIoWriter(xmlWriter).write(document);
xmlWriter.flush();
xmlWriter.close();
}
use of org.sbolstandard.core.io.rdf.RdfIo in project libSBOLj by SynBioDex.
the class SBOLReader method readRDF.
/**
* @param reader
* @return
* @throws SBOLValidationException if either of the following SBOL validation rules was violated: 10105, 10201.
*/
private static DocumentRoot<QName> readRDF(Reader reader) throws SBOLValidationException {
try {
XMLStreamReader xmlReader = XMLInputFactory.newInstance().createXMLStreamReader(reader);
RdfIo rdfIo = new RdfIo();
return rdfIo.createIoReader(xmlReader).read();
} catch (FactoryConfigurationError e) {
throw new SBOLValidationException("sbol-10105", e);
} catch (XMLStreamException e) {
throw new SBOLValidationException("sbol-10105", e);
} catch (CoreIoException e) {
throw new SBOLValidationException("sbol-10105", e);
} catch (ClassCastException e) {
if (e.getMessage().contains("IdentifiableDocument")) {
throw new SBOLValidationException("sbol-10201", e);
}
throw new SBOLValidationException("sbol-10105", e);
} catch (IllegalArgumentException e) {
if (e.getCause() instanceof URISyntaxException) {
throw new SBOLValidationException("sbol-10201", e);
}
throw new SBOLValidationException("sbol-10105", e);
}
}
Aggregations