Example usage for org.apache.commons.rdf.api BlankNode ntriplesString

List of usage examples for org.apache.commons.rdf.api BlankNode ntriplesString

Introduction

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

Prototype

String ntriplesString();

Source Link

Document

Return the term serialised as specified by the RDF-1.1 N-Triples Canonical form.

Usage

From source file:example.UserGuideTest.java

@Test
public void blanknode() throws Exception {
    BlankNode bnode = factory.createBlankNode();
    System.out.println(bnode.equals(bnode));
    System.out.println(bnode.equals(factory.createBlankNode()));

    BlankNode b1 = factory.createBlankNode("b1");

    System.out.println(b1.ntriplesString());

    System.out.println(b1.equals(factory.createBlankNode("b1")));
    System.out.println(b1.equals(new SimpleRDFTermFactory().createBlankNode("b1")));

    System.out.println(bnode.uniqueReference());
}

From source file:example.UserGuideTest.java

@Test
public void creating() throws Exception {
    BlankNode aliceBlankNode = factory.createBlankNode();
    IRI nameIri = factory.createIRI("http://example.com/name");
    Literal aliceLiteral = factory.createLiteral("Alice");
    Triple triple = factory.createTriple(aliceBlankNode, nameIri, aliceLiteral);

    System.out.println(aliceBlankNode.ntriplesString());
    System.out.println(nameIri.ntriplesString());
    System.out.println(aliceLiteral.ntriplesString());

}

From source file:org.trellisldp.rdfa.LabelledTripleTest.java

@Test
public void testBnodes() {
    final BlankNode bn1 = rdf.createBlankNode();
    final BlankNode bn2 = rdf.createBlankNode();
    final Triple triple = rdf.createTriple(bn1, DC.subject, bn2);
    final LabelledTriple t = new LabelledTriple(triple, null, null);
    assertEquals(bn1.ntriplesString(), t.getSubject(), "Subject bnode value doesn't match!");
    assertEquals(bn2.ntriplesString(), t.getObject(), "Object bnode value doesn't match!");
    assertEquals(bn2.ntriplesString(), t.getObjectLabel(), "Object bnode label doesn't match!");
}