public void testTriple()

in commons-rdf-examples/src/example/UserGuideTest.java [131:157]


    public void testTriple() throws Exception {
        BlankNodeOrIRI subject = factory.createBlankNode();
        IRI predicate = factory.createIRI("http://example.com/says");
        RDFTerm object = factory.createLiteral("Hello");
        Triple triple = factory.createTriple(subject, predicate, object);

        BlankNodeOrIRI subj = triple.getSubject();
        System.out.println(subj.ntriplesString());

        IRI pred = triple.getPredicate();
        System.out.println(pred.getIRIString());

        RDFTerm obj = triple.getObject();
        System.out.println(obj.ntriplesString());

        if (subj instanceof IRI) {
            String s = ((IRI) subj).getIRIString();
            System.out.println(s);
        }
        if (obj instanceof Literal) {
            IRI type = ((Literal) obj).getDatatype();
            System.out.println(type);
        }

        // Equal triples must have same s,p,o
        System.out.println(triple.equals(factory.createTriple(subj, pred, obj)));
    }