Package org.apache.clerezza.rdf.core

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


    }
    switch (random) {
      case 0: // create new UriRef
        return createRandomUriRef();
      default: // get existing UriRef
        Resource existingResource;
        do {
          existingResource = getExistingResource();
          if (existingResource == null) {
            random = 0;
          }
View Full Code Here


    }   
    switch (random) {
      case 0: // create new resource
        return createRandomResource();
      default: // get existing resource
        Resource existingResource = getExistingResource();
        if (existingResource == null) {
          random = 0;
        }
        return existingResource;
    }
View Full Code Here

  public boolean performRemove(Triple triple) {
    return baseGraph.remove(replaceWithReference(triple));
  }

  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

      public void remove() {
        base.remove();
      }

      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));
View Full Code Here

   * @param triple
   * @return hash without BNode hashes
   */
  private int getBlankNodeBlindHash(Triple triple) {
    int hash = triple.getPredicate().hashCode();
    Resource subject = triple.getSubject();

    if (!(subject instanceof BNode)) {
      hash ^= subject.hashCode() >> 1;
    }
    Resource object = triple.getObject();
    if (!(object instanceof BNode)) {
      hash ^= object.hashCode() << 1;
    }

    return hash;
  }
View Full Code Here

   
 
  @Test public void tripleEquality() {
    NonLiteral subject = new UriRef("http://example.org/");
    UriRef predicate = new UriRef("http://example.org/property");
    Resource object = new PlainLiteralImpl("property value");
    Triple triple1 = new TripleImpl(subject, predicate, object);
    Triple triple2 = new TripleImpl(subject, predicate, object);
    Assert.assertEquals(triple1.hashCode(), triple2.hashCode());
    Assert.assertEquals(triple1, triple2)
  }
View Full Code Here

  }

  public Triple convertTriple(com.hp.hpl.jena.graph.Triple triple) {
    NonLiteral subject = convertNonLiteral(triple.getSubject());
    UriRef predicate = convertJenaUri2UriRef(triple.getPredicate());
    Resource object = convertJenaNode2Resource(triple.getObject());
    if (subject == null || object == null) {
      return null;
    }
    return new TripleImpl(subject, predicate, object);
  }
View Full Code Here

      final Triple triple = getTripleWithBNodeSubject(unGroundedTriples);
      if (triple == null) {
        break;
      }
      final GraphNode subjectGN = new GraphNode(triple.getSubject(), unGroundedTriples);
      Resource object = triple.getObject();
      if (object instanceof BNode) {
        object = null;
      }
      Graph context = subjectGN.getNodeContext();
      Iterator<Triple> potentialIter = mGraph.filter(null, triple.getPredicate(), object);
View Full Code Here

      return null;
    }
  }

  private String getPath(TripleCollection graph, Resource res) {
    Resource path = graph.filter((NonLiteral) res,
        GLOBALMENU.path, null).next().getObject();
    return ((Literal) path).getLexicalForm();
  }
View Full Code Here

      final Triple triple = it.next();
      Triple replacementTriple = null;
      final NonLiteral subject = triple.getSubject();
      NonLiteral subjectReplacement =
          current2ReplacementMap.get(subject);
      final Resource object = triple.getObject();
      @SuppressWarnings("element-type-mismatch")
      Resource objectReplacement = current2ReplacementMap.get(object);
      if ((subjectReplacement != null) || (objectReplacement != null)) {
        it.remove();
        if (subjectReplacement == null) {
          subjectReplacement = subject;
View Full Code Here

TOP

Related Classes of org.apache.clerezza.rdf.core.Resource

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.