Example usage for org.apache.commons.rdf.api RDFTermFactory createLiteral

List of usage examples for org.apache.commons.rdf.api RDFTermFactory createLiteral

Introduction

In this page you can find the example usage for org.apache.commons.rdf.api RDFTermFactory createLiteral.

Prototype

default Literal createLiteral(String lexicalForm)
        throws IllegalArgumentException, UnsupportedOperationException 

Source Link

Document

Create a simple literal.

Usage

From source file:org.apache.jena.commonsrdf.examples.Ex_JenaGraphToCommonsRDFGraph.java

public static void main(String... a) {
    org.apache.jena.graph.Graph jGraph = GraphFactory.createGraphMem();
    RDFDataMgr.read(jGraph, "D.ttl");

    // "graph" is a CommonsRDF graph 
    Graph graph = JenaCommonsRDF.fromJena(jGraph);

    // Add to CommonsRDF Graph
    RDFTermFactory rft = new RDFTermFactoryJena();
    graph.add(rft.createIRI("http://example/s2"), rft.createIRI("http://example/p2"), rft.createLiteral("foo"));
    System.out.println("==== Write CommonsRDF graph\n");
    graph.getTriples().forEach(System.out::println);

    System.out.println("\n==== Write Jena graph directly\n");
    // And its in the Jena graph
    RDFDataMgr.write(System.out, jGraph, Lang.TTL);
}