Package org.semanticweb.owlapi.io

Examples of org.semanticweb.owlapi.io.RDFTriple


        checkNotNull(node, "node cannot be null");
        if (pending.contains(node)) {
            return;
        }
        pending.add(node);
        RDFTriple candidatePrettyPrintTypeTriple = null;
        Collection<RDFTriple> triples = graph.getTriplesForSubject(node, true);
        for (RDFTriple triple : triples) {
            IRI propertyIRI = triple.getPredicate().getIRI();
            if (propertyIRI.equals(RDF_TYPE.getIRI())
                    && !triple.getObject().isAnonymous()
                    && BUILT_IN_VOCABULARY_IRIS.contains(triple.getObject()
                            .getIRI())
                    && prettyPrintedTypes.contains(triple.getObject().getIRI())) {
                candidatePrettyPrintTypeTriple = triple;
            }
        }
        if (candidatePrettyPrintTypeTriple == null) {
            writer.writeStartElement(RDF_DESCRIPTION.getIRI());
        } else {
            writer.writeStartElement(candidatePrettyPrintTypeTriple.getObject()
                    .getIRI());
        }
        if (!node.isAnonymous()) {
            writer.writeAboutAttribute(node.getIRI());
        }
        // XXX this call looks like it should be made, but only when the node id
        // is necessary
        // else {
        // writer.writeNodeIDAttribute(node);
        // }
        for (RDFTriple triple : triples) {
            if (candidatePrettyPrintTypeTriple != null
                    && candidatePrettyPrintTypeTriple.equals(triple)) {
                continue;
            }
            writer.writeStartElement(triple.getPredicate().getIRI());
            RDFNode objectNode = triple.getObject();
            if (!objectNode.isLiteral()) {
View Full Code Here


    }

    @Override
    protected void addTriple(@Nonnull RDFResource subject,
            @Nonnull RDFResourceIRI pred, @Nonnull RDFNode object) {
        graph.addTriple(new RDFTriple(checkNotNull(subject,
                "subject cannot be null"), checkNotNull(pred,
                "pred cannot be null"), checkNotNull(object,
                "object cannot be null")));
    }
View Full Code Here

            if (!triples.isEmpty()) {
                logger.trace("triples={}", triples);
            }
        }
        for (final RDFTriple triple : triples) {
            RDFTriple tripleToRender = triple;
            RDFResourceBlankNode remappedNode = null;
            if (triplesWithRemappedNodes != null) {
                remappedNode = triplesWithRemappedNodes.get(tripleToRender);
            }
            if (remappedNode != null) {
                tripleToRender = new RDFTriple(tripleToRender.getSubject(),
                        tripleToRender.getPredicate(), remappedNode);
            }
            if (!node.equals(tripleToRender.getSubject())) {
                // the node will not match the triple subject if the node itself
                // is a remapped blank node
                // in which case the triple subject needs remapping as well
                tripleToRender = new RDFTriple(node,
                        tripleToRender.getPredicate(),
                        tripleToRender.getObject());
            }
            try {
                if (!renderedStatements.contains(tripleToRender)) {
                    renderedStatements.add(tripleToRender);
                    // then we go back and get context-sensitive statements and
                    // actually pass those to the RDFHandler
                    for (Statement statement : RioUtils.tripleAsStatements(
                            tripleToRender, contexts)) {
                        writer.handleStatement(statement);
                        if (tripleToRender.getObject() instanceof RDFResource) {
                            render((RDFResource) tripleToRender.getObject());
                        }
                    }
                } else if (logger.isTraceEnabled()) {
                    logger.trace(
                            "not printing duplicate statement, or recursing on its object: {}",
View Full Code Here

public class RdfGraphComparatorTestCase {

    @Test
    public void shouldSort() {
        RDFResourceIRI iri1 = new RDFResourceIRI(IRI.create("urn:test:1"));
        RDFTriple first = new RDFTriple(iri1, iri1, iri1);
        RDFTriple second = new RDFTriple(iri1, iri1, iri1);
        assertEquals(0, first.compareTo(second));
    }
View Full Code Here

                triple("MoleOfSiliconAtom"),
                triple("MoleOfTantalumAtom"),
                triple(624417224),
                triple("MoleOfRadonAtom"),
                triple(1556170233),
                new RDFTriple(g, subtype, r(IRI(ns + "MoleOfAtom"))),
                triple("MoleOfSeleniumAtom"),
                triple("MoleOfNeonAtom"),
                triple("MoleOfKryptonAtom"),
                triple( RDF_TYPE,OWL_CLASS),
                triple("MoleOfPlatinumAtom"),
View Full Code Here

        Collections.sort(list);
    }

    @Nonnull
    private RDFTriple triple(String n) {
        return new RDFTriple(g, d, r(IRI(ns + n)));
    }
View Full Code Here

    }

    @Nonnull
    private RDFTriple triple(@Nonnull OWLRDFVocabulary p,
            @Nonnull OWLRDFVocabulary n) {
        return new RDFTriple(g, r(p.getIRI()), r(n.getIRI()));
    }
View Full Code Here

        return new RDFTriple(g, r(p.getIRI()), r(n.getIRI()));
    }

    @Nonnull
    private RDFTriple triple(int n) {
        return new RDFTriple(g, subtype, r(n));
    }
View Full Code Here

                "Test literal", null, IRI.create("urn:test:datatype:1"));
        RDFResourceBlankNode testOwlApiSubjectBNode1 = new RDFResourceBlankNode(
                IRI.create("subjectBnode1"));
        RDFResourceBlankNode testOwlApiObjectBNode1 = new RDFResourceBlankNode(
                IRI.create("objectBnode1"));
        testOwlApiTripleAllIRI = new RDFTriple(testOwlApiSubjectUri1,
                testOwlApiPredicateUri1, testOwlApiObjectUri1);
        testOwlApiTriplePlainLiteral = new RDFTriple(testOwlApiSubjectUri1,
                testOwlApiPredicateUri1, testOwlApiObjectPlainLiteral1);
        testOwlApiTripleLangLiteral = new RDFTriple(testOwlApiSubjectUri1,
                testOwlApiPredicateUri1, testOwlApiObjectLangLiteral1);
        testOwlApiTripleTypedLiteral = new RDFTriple(testOwlApiSubjectUri1,
                testOwlApiPredicateUri1, testOwlApiObjectTypedLiteral1);
        testOwlApiTripleSubjectBNode = new RDFTriple(testOwlApiSubjectBNode1,
                testOwlApiPredicateUri1, testOwlApiObjectUri1);
        testOwlApiTripleObjectBNode = new RDFTriple(testOwlApiSubjectUri1,
                testOwlApiPredicateUri1, testOwlApiObjectBNode1);
        testOwlApiTripleSubjectObjectBNode = new RDFTriple(
                testOwlApiSubjectBNode1, testOwlApiPredicateUri1,
                testOwlApiObjectBNode1);
        URI testSesameSubjectUri1 = VF.createURI("urn:test:subject:uri:1");
        URI testSesamePredicateUri1 = VF.createURI("urn:test:predicate:uri:1");
        URI testSesameObjectUri1 = VF.createURI("urn:test:object:uri:1");
View Full Code Here

    }

    @Nonnull
    private RDFTriple getRDFTriple(@Nonnull IRI subject,
            @Nonnull IRI predicate, @Nonnull IRI object) {
        return new RDFTriple(getRDFResource(subject), new RDFResourceIRI(
                predicate), getRDFResource(object));
    }
View Full Code Here

TOP

Related Classes of org.semanticweb.owlapi.io.RDFTriple

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.