Package com.hp.hpl.jena.rdf.model

Examples of com.hp.hpl.jena.rdf.model.RDFNode


      String propName = null, propUri = null;
      String valueName = null, valueUri = null;
     
      while ( varNames.hasNext() ) {
        String varName = varNames.next().toString();
        RDFNode rdfNode = sol.get(varName);
       
        if ( rdfNode.isAnon() ) {
          continue;
        }
       
        if ( varName.equals("prop") ) {
          if ( rdfNode.isResource() ) {
            Resource r = (Resource) rdfNode;
            propName = r.getLocalName();
            propUri = r.getURI();
          }
          else {
            propName = rdfNode.toString();
           
            // if propName looks like a URL, associate the link also:
            try {
              new URL(propName);
              propUri = propName;
            }
            catch (MalformedURLException ignore) {
            }
          }
        }
        else if ( varName.equals("value") ) {
          if ( rdfNode.isResource() ) {
            Resource r = (Resource) rdfNode;
            valueName = r.getLocalName();
            valueUri = r.getURI();
          }
          else {
            valueName = rdfNode.toString();
            // if valueName looks like a URL, associate the link also:
            try {
              new URL(valueName);
              valueUri = valueName;
            }
View Full Code Here


      String right = null;
     
      Iterator<?> varNames = sol.varNames();
      while ( varNames.hasNext() ) {
        String varName = String.valueOf(varNames.next());
        RDFNode rdfNode = sol.get(varName);
       
        if ( rdfNode.isAnon() ) {
          continue;
        }
       
        String varValue = String.valueOf(rdfNode);
        if ( varValue == null ) {
View Full Code Here

   
    Resource s = ResourceFactory.createResource(entityUri);
    StmtIterator stmts = ontModel.listStatements(s, null, (RDFNode) null);
    for ( Statement stmt : stmts.toList() ) {
   
      RDFNode rdfNode = stmt.getObject();
      if ( rdfNode.isAnon() ) {
        continue;
      }
      Property prop = stmt.getPredicate();
     
      // ...
     
      String propName = prop.getLocalName();
      String propUri = prop.getURI();
      String valueName = null;
      String valueUri = null;
     
      if ( rdfNode.isResource() ) {
        Resource r = (Resource) rdfNode;
        valueName = r.getLocalName();
        valueUri = r.getURI();
        if (valueName == null || valueName.trim().length() == 0) {
          // The localName is empty, so use the URI for the valueName.
          // This was first noted with the BODC vocabularies, which use names
          // ending with slash (/).
          valueName = valueUri;
        }
      }
      else {
        valueName = rdfNode.toString();
        // if valueName looks like a URL, associate the link also:
        try {
          new URL(valueName);
          valueUri = valueName;
        }
View Full Code Here

       
        StmtIterator sIter = server.listProperties(JA.loadClass) ;
        for( ; sIter.hasNext(); )
        {
            Statement s = sIter.nextStatement() ;
            RDFNode rn = s.getObject() ;
            String className = null ;
            if ( rn instanceof Resource )
            {
                String uri = ((Resource)rn).getURI() ;
                if ( uri == null )
View Full Code Here

    {
        String ln = property.substring(property.indexOf(':')+1) ;
        ResultSet rs = query("SELECT * { ?svc "+property+" ?x}", svc.getModel(), "svc", svc) ;
        if ( ! rs.hasNext() )
            throw new FusekiConfigException("No "+ln+" for service "+nodeLabel(svc)) ;
        RDFNode x = rs.next().get("x") ;
        if ( rs.hasNext() )
            throw new FusekiConfigException("Multiple "+ln+" for service "+nodeLabel(svc)) ;
        return x ;
    }
View Full Code Here

    {
        if ( r == null )
            return "NULL ";
        if ( r.hasProperty(RDFS.label))
        {
            RDFNode n = r.getProperty(RDFS.label).getObject() ;
            if ( n instanceof Literal )
                return ((Literal)n).getString() ;
        }
       
        if ( r.isAnon() )
View Full Code Here

    private void indexObject(Resource skos_concept, Document conceptDoc,
            ObjectProperty property, String field) {
        StmtIterator stmt_iter = skos_concept.listProperties(property);
        while (stmt_iter.hasNext()) {
            RDFNode concept = stmt_iter.nextStatement().getObject();

            if (!concept.canAs(Resource.class)) {
                System.err.println("Error when indexing relationship of concept "
                        + skos_concept.getURI() + " .");
                continue;
            }

            Resource resource = concept.as(Resource.class);

            Field conceptField = new Field(field, resource.getURI(),
                    TextField.TYPE_STORED);

            conceptDoc.add(conceptField);
View Full Code Here

   */
  public QueryRow next() {
    QuerySolution qs = this.resultSet.nextSolution();
    QueryRowImpl row = new QueryRowImpl();
    for(String v : this.table.getVariables()) {
      RDFNode node = qs.get(v);
      assert node != null : "null node for varname " + v
              + ". Do you have unbound variables in the query?";
      try {
        row.put(v, TypeConversion.toRDF2Go((node == null ? null : node.asNode())));
      } catch(ModelRuntimeException e) {
        throw new ModelRuntimeException(e);
      }
    }
    return row;
View Full Code Here

            for ( ; rs.hasNext() ; )
            {
                QuerySolution rb = rs.nextSolution() ;
               
                // Get title - variable names do not include the '?' (or '$')
                RDFNode x = rb.get("title") ;
               
                // Check the type of the result value
                if ( x.isLiteral() )
                {
                    Literal titleStr = (Literal)x  ;
                    System.out.println("    "+titleStr) ;
                }
                else
View Full Code Here

                    description.append( text + "\n");
                    description.append( "Culprit = " + PrintUtil.print(t.getSubject()) +"\n");
                    for (int j = 2; j < rFunc.getArgLength(); j++) {
                        description.append( "Implicated node: " + PrintUtil.print(rFunc.getArgs()[j]) + "\n");
                    }
                    RDFNode culprit = forConversion.asRDFNode( t.getSubject() );
                    report.add(nature.equalsIgnoreCase("error"), type, description.toString(), culprit);
                }
            }
        }
       
View Full Code Here

TOP

Related Classes of com.hp.hpl.jena.rdf.model.RDFNode

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.