Package org.apache.clerezza.rdf.core

Examples of org.apache.clerezza.rdf.core.Triple



  @Test
  public void testRemoveSingleTriple() throws Exception {
    MGraph graph = getEmptyMGraph();
    final Triple triple= createTriple(
        "http://example.org/ontology/Person",
        "http://example.org/ontology/hasName",
        "http://example.org/people/alice");
    Assert.assertTrue(graph.add(triple));
    Assert.assertTrue(graph.remove(triple));
View Full Code Here


  }

  @Test
  public void testRemoveSameTripleTwice() throws Exception {
    MGraph graph = getEmptyMGraph();
    final Triple tripleAlice= createTriple(
        "http://example.org/ontology/Person",
        "http://example.org/ontology/hasName",
        "http://example.org/people/alice");
    final Triple tripleBob= createTriple(
        "http://example.org/ontology/Person",
        "http://example.org/ontology/hasName",
        "http://example.org/people/bob");
    Assert.assertTrue(graph.add(tripleAlice));
    Assert.assertTrue(graph.add(tripleBob));
View Full Code Here

    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

  }

  @Test
  public void testContainsIfContained() throws Exception {
    MGraph graph = getEmptyMGraph();
    final Triple triple= createTriple(
        "http://example.org/ontology/Person",
        "http://example.org/ontology/hasName",
        "http://example.org/people/alice");
    Assert.assertTrue(graph.add(triple));
    Assert.assertTrue(graph.contains(triple));
View Full Code Here


  @Test
  public void testContainsIfEmpty() throws Exception {
    MGraph graph = getEmptyMGraph();
    final Triple triple= createTriple(
        "http://example.org/ontology/Person",
        "http://example.org/ontology/hasName",
        "http://example.org/people/alice");
    Assert.assertFalse(graph.contains(triple));
  }
View Full Code Here


  @Test
  public void testContainsIfNotContained() throws Exception {
    MGraph graph = getEmptyMGraph();
    final Triple tripleAdd= createTriple(
        "http://example.org/ontology/Person",
        "http://example.org/ontology/hasName",
        "http://example.org/people/alice");
    final Triple tripleTest= createTriple(
        "http://example.org/ontology/Person",
        "http://example.org/ontology/hasName",
        "http://example.org/people/bob");
    Assert.assertTrue(graph.add(tripleAdd));
    Assert.assertFalse(graph.contains(tripleTest));
View Full Code Here


  @Test
  public void testFilterSingleEntry() throws Exception {
    MGraph graph = getEmptyMGraph();
    final Triple triple= createTriple(
        "http://example.org/ontology/Person",
        "http://example.org/ontology/hasName",
        "http://example.org/people/alice");
    Assert.assertTrue(graph.add(triple));
View Full Code Here


  @Test
  public void testFilterByObject() throws Exception {
    MGraph graph = getEmptyMGraph();
    final Triple tripleAlice= createTriple(
        "http://example.org/ontology/Person",
        "http://example.org/ontology/hasName",
        "http://example.org/people/alice");
    final Triple tripleBob= createTriple(
        "http://example.org/ontology/Person",
        "http://example.org/ontology/hasName",
        "http://example.org/people/bob");
    Assert.assertTrue(graph.add(tripleAlice));
    Assert.assertTrue(graph.add(tripleBob));
View Full Code Here

   * @param iterator
   */
  public SimpleTripleCollection(Iterator<Triple> iterator) {
    triples = new HashSet<Triple>();
    while (iterator.hasNext()) {
      Triple triple = iterator.next();
      triples.add(triple);
    }
  }
View Full Code Here

  public Iterator<Triple> performFilter(final NonLiteral subject, final UriRef predicate, final Resource object) {
    final List<Triple> tripleList = new ArrayList<Triple>();
    synchronized (triples) {
      Iterator<Triple> baseIter = triples.iterator();
      while (baseIter.hasNext()) {
        Triple triple = baseIter.next();
        if ((subject != null)
            && (!triple.getSubject().equals(subject))) {
          continue;
        }
        if ((predicate != null)
            && (!triple.getPredicate().equals(predicate))) {
          continue;
        }
        if ((object != null)
            && (!triple.getObject().equals(object))) {
          continue;
        }
        tripleList.add(triple);
      }
View Full Code Here

TOP

Related Classes of org.apache.clerezza.rdf.core.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.