Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

86 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Titanium RDF API

A collection of straightforward micro-interfaces for processing RDF statements and facilitating seamless interoperability and data exchange across various libraries.

Maven Central javadoc License

Examples

This section demonstrates how to directly utilize the micro-interfaces for both RDF 1.1 processing and advanced RDF 1.2 data emission.

RDF Flat Quads

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
);

RDF Triple Terms

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();

🎉 Supported By

Add an implementation that supports this API - open a PR!

📦 Installation

<dependency>
    <groupId>com.apicatalog</groupId>
    <artifactId>titanium-rdf-api</artifactId>
    <version>${rdf.api.version}</version>
</dependency>

🤝 Contributing

Contributions of all kinds are welcome - whether it’s code, documentation, testing, or community support! Please open PR or issue to get started.

📚 Resources

💼 Commercial Support

Commercial support and consulting are available. For inquiries, please contact: filip26@gmail.com

About

A collection of universal RDF 1.1 and RDF 1.2 micro-interfaces enabling fast, high-performance processing, seamless interoperability, and data exchange across various libraries.

Topics

Resources

Security policy

Stars

9 stars

Watchers

2 watching

Forks

Releases

Used by

Contributors

Languages