Skip to content

Commit

Permalink
Fix loading of RDF4J parsers
Browse files Browse the repository at this point in the history
  • Loading branch information
tkuhn committed Mar 15, 2019
1 parent 3f37d43 commit 209c3b9
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions src/main/java/org/nanopub/NanopubImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,33 +67,31 @@ public class NanopubImpl implements NanopubWithNs, Serializable {
private static final long serialVersionUID = -1514452524339132128L;

static {
tryToLoadParserFactory("org.openrdf.rio.trig.TriGParserFactory");
tryToLoadParserFactory("org.eclipse.rdf4j.rio.trig.TriGParserFactory");
RDFWriterRegistry.getInstance().add(new CustomTrigWriterFactory());
tryToLoadParserFactory("org.openrdf.rio.nquads.NQuadsParserFactory");
tryToLoadWriterFactory("org.openrdf.rio.nquads.NQuadsWriterFactory");
tryToLoadParserFactory("org.openrdf.rio.trix.TriXParserFactory");
tryToLoadWriterFactory("org.openrdf.rio.trix.TriXWriterFactory");
tryToLoadParserFactory("org.openrdf.rio.jsonld.JSONLDParserFactory;");
tryToLoadWriterFactory("org.openrdf.rio.jsonld.JSONLDWriterFactory");
tryToLoadParserFactory("org.eclipse.rdf4j.rio.nquads.NQuadsParserFactory");
tryToLoadWriterFactory("org.eclipse.rdf4j.rio.nquads.NQuadsWriterFactory");
tryToLoadParserFactory("org.eclipse.rdf4j.rio.trix.TriXParserFactory");
tryToLoadWriterFactory("org.eclipse.rdf4j.rio.trix.TriXWriterFactory");
tryToLoadParserFactory("org.eclipse.rdf4j.rio.jsonld.JSONLDParserFactory");
tryToLoadWriterFactory("org.eclipse.rdf4j.rio.jsonld.JSONLDWriterFactory");
}

private static void tryToLoadParserFactory(String className) {
try {
RDFParserFactory pf = (RDFParserFactory) Class.forName(className).newInstance();
RDFParserRegistry.getInstance().add(pf);
} catch (ClassNotFoundException ex) {
} catch (IllegalAccessException ex) {
} catch (InstantiationException ex) {
} catch (ClassNotFoundException | IllegalAccessException | InstantiationException ex) {
throw new RuntimeException(ex);
};
}

private static void tryToLoadWriterFactory(String className) {
try {
RDFWriterFactory wf = (RDFWriterFactory) Class.forName(className).newInstance();
RDFWriterRegistry.getInstance().add(wf);
} catch (ClassNotFoundException ex) {
} catch (IllegalAccessException ex) {
} catch (InstantiationException ex) {
} catch (ClassNotFoundException | IllegalAccessException | InstantiationException ex) {
throw new RuntimeException(ex);
};
}

Expand Down

0 comments on commit 209c3b9

Please sign in to comment.