Package org.apache.clerezza.rdf.core.impl

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


  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

  @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

    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

    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

   * @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

  }

  private Triple replaceWithReference(Triple triple) {
    Resource object = triple.getObject();
    if (needsReplacing(object)) {
      return new TripleImpl(triple.getSubject(), triple.getPredicate(),
          replace((TypedLiteral) object));
    } else {
      return triple;
    }
  }
View Full Code Here

      private Triple replaceReference(Triple triple) {
        Resource object = triple.getObject();
        if (object instanceof UriRef) {
          String uriString = ((UriRef) object).getUnicodeString();
          if (uriString.startsWith(UriHashPrefix)) {
            return new TripleImpl(triple.getSubject(), triple.getPredicate(),
                getLiteralForUri(uriString));
          }
        }
        return triple;
      }
View Full Code Here

          readLock.unlock();
        }
      }
    }
    node.addProperty(PLATFORM.instance, platformInstance);
    graph.add(new TripleImpl(platformInstance, RDF.type, PLATFORM.Instance));
    graph.add(new TripleImpl(platformInstance, PLATFORM.languages, listNode));
    graph.add(new TripleImpl(listNode, RDF.type, LANGUAGE.LanguageList));
    if (!copyToNode) {
      node = new GraphNode(node.getNode(), new UnionMGraph(graph, configGraph));
    }
    return node;
  }
View Full Code Here

    }
    BNode listNode = new BNode();
    Lock writeLock = systemGraph.getLock().writeLock();
    writeLock.lock();
    try {
      systemGraph.add(new TripleImpl(instance, PLATFORM.languages, listNode));
    } finally {
      writeLock.unlock();
    }
    return listNode;
  }
View Full Code Here

TOP

Related Classes of org.apache.clerezza.rdf.core.impl.TripleImpl

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.