Apache Commons RDF logo

Apache Commons RDF (incubating)

Commons RDF aims to provide a common library for RDF 1.1 that could be implemented by systems on the Java Virtual Machine.

The main motivation behind this simple library is revise an historical incompatibility issue. This library does not pretend to be a generic api wrapping those libraries, but a set of interfaces for the RDF 1.1 concepts that can be used to expose common RDF-1.1 concepts using common Java interfaces. In the initial phase commons-rdf is focused on a subset of the core concepts defined by RDF-1.1 (URI/IRI, Blank Node, Literal, Triple, and Graph). In particular, commons RDF aims to provide a type-safe, non-general API that covers RDF 1.1. In a future phase we may define interfaces for Datasets and Quads.

API

The class diagram on the right depicts the main interfaces which may be included in Commons RDF, specifically:

  • Graph: a graph, a set of RDF triples.
  • Triple: a RDF triple with getSubject(), getPredicate(), getObject().
  • Dataset: a dataset, of RDF quads (or if you like, a set of named graphs).
  • Quad: a RDF quad with with getGraphName(), getSubject(), getPredicate(), getObject().
  • RDFTerm: any RDF 1.1 Term which can be part of a Triple or Quad. IRIs, literals and blank nodes are collectively known as RDF terms.
  • IRI: an Internationalized Resource Identifier (e.g. representing <http://example.com/>)
  • BlankNode: a RDF-1.1 Blank Node, e.g. representing _:b1. Disjoint from IRIs and literals.
  • BlankNodeOrIRI: this interface represents the RDF Terms that may be used in the subject position of an RDF 1.1 Triple, including BlankNode and IRI.
  • Literal: a RDF-1.1 literal, e.g. representing "Hello there"@en.

The design of the API follows the terminology as defined by RDF 1.1 Concepts and Abstract Syntax, a W3C Recommendation published on 25 February 2014. The idea is that Commons RDF provide a common library for RDF 1.1 with multiple implementions for the Java Virtual Machine, allowing the portability across different Commons RDF implementations.

Commons RDF is designed for compatibility between different implementations, e.g. by defining strong equality and hash code semantics (e.g. for triple and literals ); this allows users of Commons RDF to “mix and match”, for instance querying a FooGraphImpl and directly adding its FooTripleImpls to a BarGraphImpl without any explicit convertion.

To create such instances without hard-coding an implementation, one can use:

  • RDFTermFactory: factory interface for creating instances of the above types (e.g. LiteralImpl and GraphImpl).

The API also includes a couple of “upper” interfaces which do not have the above equality semantics and bridge the graph/quad duality:

  • TripleLike: common super-interface of Triple and Quad (also a generalised triple).
  • QuadLike: a TripleLike that also has getGraphName() (a generalized quad)
  • GraphLike: common super-interface of Graph and Dataset.

See the the user guide for examples of how to interact with these interfaces.

Modules

The project is composed by two modules:

  • API defines a common library of RDF 1.1 concepts.
  • Simple provides a simple implementation, mainly for internal validation and very simple scenarios.

Both modules follow the semantic versioning principles, where version x.y.z of Simple implements version x.y of the API; i.e., the version z are backwards-compatible patches of the implementation.

Implementations of the Commons RDF API are being developed as additional modules. Contributions welcome!

Contributing

Please, take into account that this library is still work in progress, this set of interfaces are still under discussion and evolution. Therefore everybody is welcomed to join the project and contribute!

Disclaimer

Apache Commons RDF is an effort undergoing incubation at The Apache Software Foundation (ASF) sponsored by the Apache Incubator PMC. Incubation is required of all newly accepted projects until a further review indicates that the infrastructure, communications, and decision making process have stabilized in a manner consistent with other successful ASF projects. While incubation status is not necessarily a reflection of the completeness or stability of the code, it does indicate that the project has yet to be fully endorsed by the ASF.

Apache Incubator