Examples of TripleImpl


Examples of org.apache.clerezza.rdf.core.impl.TripleImpl

   
    @Test
    public void testAddCountAndGetTriples() {
        MGraph graph = getEmptyMGraph();
        Assert.assertEquals(0, graph.size());
        final TripleImpl triple1 = new TripleImpl(uriRef1, uriRef2, uriRef1);
        graph.add(triple1);
        Assert.assertEquals(1, graph.size());
        Iterator<Triple> tripleIter = graph.filter(uriRef1, uriRef2, uriRef1);
        Assert.assertTrue(tripleIter.hasNext());
        Triple tripleGot = tripleIter.next();
        Assert.assertEquals(triple1, tripleGot);
        Assert.assertFalse(tripleIter.hasNext());
        BNode bnode = new BNode() {};
        graph.add(new TripleImpl(bnode, uriRef1, uriRef3));
        graph.add(new TripleImpl(bnode, uriRef1, uriRef4));
        tripleIter = graph.filter(null, uriRef1, null);
        Set<NonLiteral> subjectInMatchingTriples = new HashSet<NonLiteral>();
        Set<Resource> objectsInMatchingTriples = new HashSet<Resource>();
        while (tripleIter.hasNext()) {
            Triple triple = tripleIter.next();
            subjectInMatchingTriples.add(triple.getSubject());
            objectsInMatchingTriples.add(triple.getObject());
        }
        Assert.assertEquals(1, subjectInMatchingTriples.size());
        Assert.assertEquals(2, objectsInMatchingTriples.size());
        Set<Resource> expectedObjects = new HashSet<Resource>();
        expectedObjects.add(uriRef3);
        expectedObjects.add(uriRef4);
        Assert.assertEquals(expectedObjects, objectsInMatchingTriples);
        graph.add(new TripleImpl(bnode, uriRef4, bnode));
        tripleIter = graph.filter(null, uriRef4, null);
        Assert.assertTrue(tripleIter.hasNext());
        Triple retrievedTriple = tripleIter.next();
        Assert.assertFalse(tripleIter.hasNext());
        Assert.assertEquals(retrievedTriple.getSubject(), retrievedTriple.getObject());
View Full Code Here

Examples of org.apache.clerezza.rdf.core.impl.TripleImpl

   
    @Test
    public void testRemoveAllTriples() {
        MGraph graph = getEmptyMGraph();
        Assert.assertEquals(0, graph.size());
        graph.add(new TripleImpl(uriRef1, uriRef2, uriRef3));
        graph.add(new TripleImpl(uriRef2, uriRef3, uriRef4));
        Assert.assertEquals(2, graph.size());
        graph.clear();
        Assert.assertEquals(0, graph.size());
    }
View Full Code Here

Examples of org.apache.clerezza.rdf.core.impl.TripleImpl

    @Test
    public void testUseTypedLiterals() {
        MGraph graph = getEmptyMGraph();
        Assert.assertEquals(0, graph.size());
        Literal value = new TypedLiteralImpl("<elem>value</elem>",xmlLiteralType);
        final TripleImpl triple1 = new TripleImpl(uriRef1, uriRef2, value);
        graph.add(triple1);
        Iterator<Triple> tripleIter = graph.filter(uriRef1, uriRef2, null);
        Assert.assertTrue(tripleIter.hasNext());
        Resource gotValue = tripleIter.next().getObject();
        Assert.assertEquals(value, gotValue);
View Full Code Here

Examples of org.apache.clerezza.rdf.core.impl.TripleImpl

    public void testUseLanguageLiterals() {
        MGraph graph = getEmptyMGraph();
        Assert.assertEquals(0, graph.size());
        Language language = new Language("it");
        Literal value = new PlainLiteralImpl("<elem>value</elem>",language);
        final TripleImpl triple1 = new TripleImpl(uriRef1, uriRef2, value);
        graph.add(triple1);
        Iterator<Triple> tripleIter = graph.filter(uriRef1, uriRef2, null);
        Assert.assertTrue(tripleIter.hasNext());
        Resource gotValue = tripleIter.next().getObject();
        Assert.assertEquals(value, gotValue);
View Full Code Here

Examples of org.apache.clerezza.rdf.core.impl.TripleImpl

    @Test
    public void testRemoveViaIterator() {
        MGraph graph = getEmptyMGraph();
        Assert.assertEquals(0, graph.size());
        final TripleImpl triple1 = new TripleImpl(uriRef1, uriRef2, uriRef1);
        graph.add(triple1);
        final TripleImpl triple2 = new TripleImpl(uriRef1, uriRef2, uriRef4);
        graph.add(triple2);
        Assert.assertEquals(2, graph.size());
        Iterator<Triple> iterator = graph.iterator();
        while (iterator.hasNext()) {
            iterator.next();
View Full Code Here

Examples of org.apache.clerezza.rdf.core.impl.TripleImpl

        MGraph graph = getEmptyMGraph();
        BNode bNode = new BNode();
        final UriRef HAS_NAME = new UriRef("http://example.org/ontology/hasName");
        final PlainLiteralImpl name = new PlainLiteralImpl("http://example.org/people/alice");
        final PlainLiteralImpl name2 = new PlainLiteralImpl("http://example.org/people/bob");
        final Triple tripleAlice = new TripleImpl(bNode, HAS_NAME, name);
        final Triple tripleBob = new TripleImpl(bNode, HAS_NAME, name2);
        Assert.assertTrue(graph.add(tripleAlice));
        Assert.assertTrue(graph.add(tripleBob));
        Iterator<Triple> result = graph.filter(null, HAS_NAME, name);
        Assert.assertEquals(bNode, result.next().getSubject());
    }
View Full Code Here

Examples of org.apache.clerezza.rdf.core.impl.TripleImpl

        MGraph mGraph = getEmptyMGraph();
        TestGraphListener listener = new TestGraphListener();
        mGraph.addGraphListener(listener, new FilterTriple(uriRef1, uriRef2, null),
                1000);

        Triple triple0 = new TripleImpl(uriRef2, uriRef2, literal1);
        Triple triple1 = new TripleImpl(uriRef1, uriRef2, uriRef1);
        Triple triple2 = new TripleImpl(uriRef1, uriRef2, literal1);
        Triple triple3 = new TripleImpl(uriRef1, uriRef2, bnode1);
        mGraph.add(triple0);
        mGraph.add(triple1);
        mGraph.add(triple2);
        mGraph.add(triple3);
        Thread.sleep(1500);
View Full Code Here

Examples of org.apache.clerezza.rdf.core.impl.TripleImpl

     * @param object  the object.
     * @throws IllegalArgumentException  If an attribute is <code>null</code>.
     */
    private Triple createTriple(String subject, String predicate,
            String object) {
        return new TripleImpl(new UriRef(subject), new UriRef(predicate),
                new UriRef(object));
    }
View Full Code Here

Examples of org.apache.clerezza.rdf.core.impl.TripleImpl

      map.get((BNode)oSubject) : oSubject;

    Resource oObject = triple.getObject();
    Resource object = oObject instanceof BNode ?
      map.get((BNode)oObject) : oObject;
    return new TripleImpl(subject, triple.getPredicate(), object);
  }
View Full Code Here

Examples of org.apache.clerezza.rdf.core.impl.TripleImpl

    Graph jenaGraph = new JenaGraph(mGraph);
    Model model = ModelFactory.createModelForGraph(jenaGraph);
    model.add(DC.title, RDFS.label, "title");
    MGraph rewrappedMGraph = new JenaGraphAdaptor(jenaGraph);
    Assert.assertEquals(1, rewrappedMGraph.size());
    rewrappedMGraph.add(new TripleImpl(new BNode(), SKOS.prefLabel,
        LiteralFactory.getInstance().createTypedLiteral("foo")));
    Assert.assertEquals(2, rewrappedMGraph.size());
    Assert.assertEquals(2, mGraph.size());
    rewrappedMGraph.clear();
    Assert.assertEquals(0, rewrappedMGraph.size());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.