A collection of straightforward micro-interfaces for processing RDF statements and facilitating seamless interoperability and data exchange across various libraries.
This section demonstrates how to directly utilize the micro-interfaces for both RDF 1.1 processing and advanced RDF 1.2 data emission.
This example shows how to implement and use the RdfQuadConsumer interface to process incoming RDF statements, utilizing the static helper methods to validate data types.
// 1. Implement a custom consumer
var logger = (subject, predicate, object, datatype, language, graph) -> {
// Use static helpers to identify language-tagged strings
if (RdfQuadConsumer.isLangString(datatype, language)) {
System.out.println("Language string detected: " + object + "@" + language);
} else if (RdfQuadConsumer.isBlank(subject)) {
System.out.println("Blank node subject detected: " + subject);
}
// Additional processing logic here
};
// 2. Feed quads into the consumer
logger.quad(
"http://example.org/subject",
"http://example.org/predicate",
"Ahoj",
RdfQuadConsumer.DATATYPE_DIR_LANG_STRING,
"cs",
"ltr",
null
);This example demonstrates how to use the RdfQuadEmitter interface to produce nested Triple Terms.
// Initialize a writer or processor implementing RdfQuadEmitter
RdfQuadEmitter emitter = ...;
// 1. Emitting a standard flat quad using convenience methods
emitter.quad(
"http://example.org/subject",
"http://example.org/predicate",
"http://example.org/object",
"http://example.org/graph"
);
// 2. Streaming a quad with a directional language-tagged literal (Czech, Left-to-Right)
emitter.beginQuad("http://example.org/graph");
emitter.subject("http://example.org/subject");
emitter.predicate("http://example.org/predicate");
emitter.literal("Ahoj", RdfQuadEmitter.DATATYPE_DIR_LANG_STRING, "cs", "ltr");
emitter.endQuad();
// 3. Emitting an RDF 1.2 Triple Term in the subject position (<< :s :p :o >> :p2 :o2)
emitter.beginQuad(); // Default graph
emitter.beginSubject();
emitter.subject("http://example.org/s");
emitter.predicate("http://example.org/p");
emitter.object("http://example.org/o");
emitter.endSubject();
emitter.predicate("http://example.org/p2");
emitter.object("http://example.org/o2");
emitter.endQuad();- Apache Jena
- Jelly-JVM – high-performance binary RDF serialization format
- Titanium JSON-LD
- Titanium RDF N-QUADS
- Titanium RDF Dataset Canonicalization
- Titanium RDF Primitives
Add an implementation that supports this API - open a PR!
<dependency>
<groupId>com.apicatalog</groupId>
<artifactId>titanium-rdf-api</artifactId>
<version>${rdf.api.version}</version>
</dependency>Contributions of all kinds are welcome - whether it’s code, documentation, testing, or community support! Please open PR or issue to get started.
Commercial support and consulting are available. For inquiries, please contact: filip26@gmail.com