Package org.apache.clerezza.rdf.core

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


                     * Anonymous implementation of an Adapter that converts the filtered Triples of the
                     * resulting graph to RdfRepresentations
                     */
                    @Override
                    public RdfRepresentation adapt(Triple value, Class<RdfRepresentation> type) {
                        Resource object = value.getObject();
                        if (object == null) {
                            return null;
                        } else if (object instanceof UriRef) {
                            return valueFavtory.createRdfRepresentation((UriRef) object, resultGraph);
                        } else {
                            log.warn("Unable to create representation for FieldQueryResult " + object
                                     + " because this Resource is not of Type UriRef (type: "
                                     + object.getClass() + ") -> result gets ignored");
                            return null;
                        }
                    }
                }, RdfRepresentation.class);
        return resultIterator;
View Full Code Here


        if (size() == 0) {
            random = 0;
        }
        switch (random) {
            case 0: // create new NonLiteral
                Resource newResource;
                do {
                    newResource = createRandomResource();
                } while (!(newResource instanceof NonLiteral));
                return (NonLiteral) newResource;
            default: // get existing NonLiteral
                Resource existingResource;
                do {
                    existingResource = getExistingResource();
                    if (existingResource == null) {
                        random = 0;
                    }
View Full Code Here

        }
        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

        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

        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);
        Assert.assertEquals(language, ((PlainLiteral)gotValue).getLanguage());
    }
View Full Code Here

    final NonLiteral oSubject = triple.getSubject();

    NonLiteral subject = oSubject instanceof BNode ?
      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

  private void appendResourceOrVariable(StringBuffer s, ResourceOrVariable n) {
    if (n.isVariable()) {
      appendVariable(s, n.getVariable());
    } else {
      Resource r = n.getResource();
      if (r instanceof BNode) {
        s.append("_:").append(r.toString().replace("@", "."));
      } else {
        s.append(r.toString());
      }
    }
  }
View Full Code Here

    try {
      Iterator<Triple> typeStmts = contentMGraph.filter(uri, RDF.type, null);

      while (typeStmts.hasNext()) {
        Triple triple = typeStmts.next();
        Resource typeStmtObj = triple.getObject();
        if (!(typeStmtObj instanceof UriRef)) {
          throw new RuntimeException(
              "RDF type is expected to be a URI but is " + typeStmtObj
              + "(in " + triple + ")");
        }
View Full Code Here

      }

    });
    final Iterator<Resource> entriesIter = titledContent.getObjects(DISCOBITS.contains);
    while (entriesIter.hasNext()) {
      Resource resource = entriesIter.next();
      entries.add(new GraphNode((NonLiteral) resource,titledContent.getGraph()));
    }
    final List<GraphNode> result = new ArrayList<GraphNode>();
    for (GraphNode graphNode : entries) {
      Iterator<Resource> holded = graphNode.getObjects(DISCOBITS.holds);
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.