The jelly-titanium-rdf-api module integrates Jelly with the minimalistic Titanium RDF API. This API is by itself not a fully-fledged RDF library, but is rather intended as an interoperability bridge.
If you are already using Jena or RDF4J, you should use the jelly-jena or jelly-rdf4j module instead. This way you'll get better performance and more features.
Installation
jelly-titanium-rdf-api is available on Maven Central. To include it in your project, add the following dependency to your pom.xml:
packageeu.neverblink.jelly.examples;importcom.apicatalog.rdf.nquads.NQuadsReader;importcom.apicatalog.rdf.nquads.NQuadsWriter;importeu.neverblink.jelly.convert.titanium.TitaniumJellyReader;importeu.neverblink.jelly.convert.titanium.TitaniumJellyWriter;importeu.neverblink.jelly.examples.shared.Example;importjava.io.*;publicclassTitaniumRdfApiimplementsExample{publicstaticvoidmain(String[]args)throwsException{newTitaniumRdfApi().run(args);}publicvoidrun(String[]args)throwsException{// Obtain the input file name (Jelly) and output file (N-Quads)varinputFile=newFile(getClass().getResource("/jelly/weather.jelly").toURI());varnquadsOutput=newFile("weather-titanium.nq");System.out.println("Converting "+inputFile+" to "+nquadsOutput+" ...");// Open the I/O streamstry(varfis=newFileInputStream(inputFile);varfos=newFileWriter(nquadsOutput)){varjellyReader=TitaniumJellyReader.factory();// Parse the entire Jelly file and immediately write the N-Quads to the output filejellyReader.parseAll(newNQuadsWriter(fos),fis);}System.out.println("Conversion complete, N-Quads file saved.");// Now let's try the reverse – parse an N-Quads file and write it as JellyvarnquadsInput=newFile("weather-titanium.nq");varjellyOutput=newFile("weather-titanium.jelly");System.out.println("Converting "+nquadsInput+" to "+jellyOutput+" ...");// Open the I/O streamstry(varfis=newFileReader(nquadsInput);varfos=newFileOutputStream(jellyOutput);// IMPORTANT: the Jelly writer must be closed before the output stream is closed,// otherwise the Jelly file will be incomplete. You can also do this manually with// the jellyWriter.close() method.varjellyWriter=TitaniumJellyWriter.factory(fos)){// Parse the entire N-Quads file and immediately write the Jelly to the output filenewNQuadsReader(fis).provide(jellyWriter);}System.out.println("Conversion complete, Jelly file saved.");}}
Low-level usage
Titanium RDF API does not implement types for RDF primitives, so the Jelly integration with it is a bit different from the ones for Jena and RDF4J. Currently, the Pekko Streams API is not supported, and the JellyConverterFactory for Titanium is not part of the public API.
But, you can still access a part of the low-level API directly. This would be useful if you wanted to integrate Titanium with Kafka or some other custom serialization pipeline.
Jelly-JVM implements the RdfQuadConsumer interface, so you can hook it up to any library that does the same. This includes formats like: JSON-LD, CBOR-LD, N-Quads.