This is the base package to provide JSON-LD integration with other Java RDF libraries.
If you're creating a module for a RDF library that isn't already supported by the jsonld-java integration modules you can create your module directly in the jsonld-java project. This will allow other people who may be interested in your module to find it easier and allow it to be released along with the core code and updated by the comunity.
See https://help.github.com/articles/fork-a-repo for details on forking a repository.
Make sure you have m2e installed.
File->Import- Select
Existing Maven Projects Browseto the directory you clonedjsonld-javatoSelect AllFinish
- Right click on the
jsonld-java-integrationproject and selectNew->Project - Select
Maven Module - Enter a
Module Namewhich matches the RDF Library you're integrating (e.g.jena) Next->Next(you should now be at theSpecify Archetype parameterspage- Change
Packagetocom.github.jsonldjava.YOURMODULE Finish
Make the generated pom.xml match the one listed below.
Delete the App.java and AppTest.java files.
After cloning your fork of jsonld-java, create a new directory for your module under /jsonld-java/integration/<your module>.
Here is the basic outline for what your module's pom.xml should look like
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<artifactId>jsonld-java-integration</artifactId>
<groupId>com.github.jsonld-java</groupId>
<version>0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jsonld-java-{your module}</artifactId>
<name>JSONLD Java :: {your module name}</name>
<description>JSON-LD Java integration module for {RDF Library your module integrates}</description>
<packaging>jar</packaging>
<developers>
<developer>
<name>{YOU}</name>
</developer>
</developers>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jsonld-java</artifactId>
<version>${project.version}</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jsonld-java</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Make sure you edit the following:
project/artifactId: set this tojsonld-java-{module id}, where{module id}usually represents the RDF library you're integrating (e.g.jsonld-java-jena)project/name: set this toJSONLD Java :: {Module Name}, wher{module name}is usually the name of the RDF library you're integrating.project/descriptionproject/developers/developer/...: Give youself credit by filling in the developer field. At least put your<name>in (see here for all available options).project/dependencies/...: remember to add any dependencies your project needs
For Example: Follow the first few steps in the section above to import the whole jsonld-java project or only your new module into eclipse.
The interface com.github.jsonldjava.core.RDFParser is used to parse RDF from the library into the JSONLD-Java internal RDF format. See the documentation in RDFParser.java for details on how to implement this interface.
The interface com.github.jsonldjava.core.JSONLDTripleCallback is used to generate a representation of the JSON-LD input in the RDF library. See the documentation in JSONLDTripleCallback.java for details on how to implement this interface.
A JSONLD RDF parser is a class that can parse your frameworks' RDF model and generate JSON-LD.
There are two ways to use your RDFParser implementation.
Register your parser with the JSONLD class and set options.format when you call fromRDF
JSONLD.registerRDFParser("format/identifier", new YourRDFParser());
Object jsonld = JSONLD.fromRDF(yourInput, new Options("") {{ format = "format/identifier" }});
or pass an instance of your RDFParser into the fromRDF function
Object jsonld = JSONLD.fromRDF(yourInput, new YourRDFParser());
A JSONLD triple callback is a class that can populate your framework's RDF model from JSON-LD - being called for each triple (technically quad).
Pass an instance of your TripleCallback to JSONLD.toRDF
Object yourOutput = JSONLD.toRDF(jsonld, new YourTripleCallback());
Your framework might have its own system of readers and writers, where you should register JSON-LD as a supported format. Remember that here the "parse" direction is opposite of above, a 'reader' in e.g. Jena will be a class that can parse JSON-LD and populate a Jena model.
It's helpful to have a test or two for your implementations to make sure they work and continue to work with future versions.
Write a README.md file under jsonld-java/integration/<your module>/ with instrutions on how to use your module.
Once you've committed your code, and pushed it into your github fork you can issue a Pull Request so that we can pull your new module into the jsonld-java codebase.