Package org.jrdf.graph

Examples of org.jrdf.graph.Triple


        return handler.createMolecule(pid, mid);
    }

    public ClosableIterator<Molecule> findMolecules(SubjectNode subject, PredicateNode predicate, ObjectNode object)
        throws GraphException {
        Triple triple = new TripleImpl(subject, predicate, object);
        return findMolecules(triple);
    }
View Full Code Here


            iterator.close();
        }
    }

    public Molecule addRootTriple(Molecule molecule, Triple rootTriple) throws GraphException {
        Triple headTriple = molecule.getHeadTriple();
        Long[] tripleAsLongs = localizer.localizeTriple(headTriple);
        ClosableIterator<Long> iterator = readableIndex.findMoleculeIDs(tripleAsLongs);
        try {
            while (iterator.hasNext()) {
                final Long mid = iterator.next();
View Full Code Here

    public boolean hasNext() {
        return nextTriple != null;
    }

    public Triple next() {
        final Triple currentTriple = nextTriple;
        parseNext();
        if (currentTriple != null) {
            return currentTriple;
        } else {
            throw new NoSuchElementException();
View Full Code Here

    public Triple next() {
        if (null == currentBytes) {
            throw new NoSuchElementException();
        }
        nextCalled = true;
        Triple triple = handler.createTriple(fromBytes(currentBytes, TRIPLES));
        bytesToRemove = currentBytes;
        getNextBytes();
        return triple;
    }
View Full Code Here

        ObjectNode city = graph.getElementFactory().createLiteral("Bedford");
        print("Search for city ('Bedford'): ", graph.find(ANY_SUBJECT_NODE, ANY_PREDICATE_NODE, city));

        //search for any subject that has an address
        PredicateNode hasAddress = graph.getElementFactory().createURIReference(HAS_ADDRESS);
        Triple findAddresses = tripleFactory.createTriple(ANY_SUBJECT_NODE, hasAddress, ANY_OBJECT_NODE);
        print("Search for subjects that have an address: ", graph.find(findAddresses));
    }
View Full Code Here

        print("Search for subjects that have an address: ", graph.find(findAddresses));
    }

    private void getAllTriples(TripleFactory tripleFactory, Graph graph) throws GraphException {
        //get all Triples
        Triple findAll = tripleFactory.createTriple(ANY_SUBJECT_NODE, ANY_PREDICATE_NODE, ANY_OBJECT_NODE);
        ClosableIterable<Triple> allTriples = graph.find(findAll);
        try {
            print("Search for all triples: ", allTriples);
        } finally {
            allTriples.iterator().close();
View Full Code Here

        tripleFactory.reifyTriple(addressStatement, statement);

        //insert a statement about the original statement
        URIReference manager = elementFactory.createURIReference(new URI("http://example.org/managerid#65"));
        URIReference hasConfirmed = elementFactory.createURIReference(new URI("http://example.org/terms#hasConfirmed"));
        Triple confirmationStatement = tripleFactory.createTriple(manager, hasConfirmed, statement);
        graph.add(confirmationStatement);

        //print the contents
        print("Graph contains (after reification): ", graph);
    }
View Full Code Here

        print("Graph contains (after remove): ", graph);
    }

    private void performQuery(Graph graph) throws InvalidQuerySyntaxException, GraphException,
        XMLStreamException, URISyntaxException {
        final Triple triple = person.asTriple(new URI("http://example.org/terms#hasConfirmed"),
            new URI("http://example.org/statement#address1"));
        graph.add(triple);
        print("Graph now contains: ", graph);
        SparqlConnection connection = JRDF_FACTORY.getNewSparqlConnection();
        String query =
View Full Code Here

        if (null == graph) {
            throw new IllegalArgumentException("Graph is null.");
        }

        //find all statements
        Triple findAll = graph.getTripleFactory().createTriple(ANY_SUBJECT_NODE, ANY_PREDICATE_NODE, ANY_OBJECT_NODE);
        ClosableIterable<Triple> allTriples = graph.find(findAll);

        //print them
        print(message, allTriples);
View Full Code Here

    public void setStatementHandler(final StatementHandler newStatementHandler) {
        sh = newStatementHandler;
    }

    public void handleTriple(final CharSequence line) {
        final Triple triple = tripleParser.parseTriple(line);
        if (triple != null) {
            sh.handleStatement(triple.getSubject(), triple.getPredicate(), triple.getObject());
        }
    }
View Full Code Here

TOP

Related Classes of org.jrdf.graph.Triple

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.