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

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


        ct.toXML(elem, r, 0, unsequenced(r), ctx);
        return true;
      }     

      // add (sequenced) sub-elements
      NodeIterator ni = ctx.getModel().getSeq(r).iterator();
      while (ni.hasNext()) {
        Statement stmt = element.asStatement((Resource) ni.nextNode());
        if (stmt.getPredicate().equals(RDF.value)) {
          // add literal value
          RDFNode value = stmt.getObject();
          if (value.isLiteral())
            elem.appendChild(doc.createTextNode(value.toString()))
View Full Code Here


    while (si.hasNext()) {
      Statement stmt = si.nextStatement();
      // don't add ordinals
      if (stmt.getPredicate().getOrdinal()==0) s.add(stmt);
    }
    NodeIterator ni = rdf.getModel().getSeq(rdf).iterator();
    while (ni.hasNext()) {
      Statement stmt = asStatement((Resource) ni.nextNode());
      if (s.contains(stmt)) s.remove(stmt);
    }
    return s;
  }
View Full Code Here

    while (subjects.hasNext() && result.size() < DataSource.MAX_INDEX_SIZE) {
      Resource r = subjects.next();
      if (r.isAnon()) continue;
      result.add(r);
    }
    NodeIterator objects = model.listObjects();
    while (objects.hasNext() && result.size() < DataSource.MAX_INDEX_SIZE) {
      RDFNode o = objects.next();
      if (!o.isURIResource()) continue;
      result.add(o.asResource());
    }
    return result;
  }
View Full Code Here

             ontPrefixCount = new ArrayList<String>(),
             ontPrefixMapping = new ArrayList<String>();
        while ( it.hasNext() ) {
            Resource curr = it.nextResource();
            totalModelTriples += Double.parseDouble( curr.getProperty( EYE.modelSize ).getLiteral().getLexicalForm() );
            NodeIterator it2 = stats.listObjectsOfProperty( curr, EYE.usedOntology );
            while ( it2.hasNext() ) {
                Resource bn = stats.createResource( it2.nextNode().asNode().getBlankNodeId() );
                String ont = bn.getProperty( EYE.ontURI ).getObject().asNode().getURI();
                String prefix = bn.getProperty( EYE.prefix ).getLiteral().getLexicalForm();
                inc( onts, ontCount, ont );
                if ( !ontPrefixes.contains( prefix ) )
                    ontPrefixMapping.add( ont );
View Full Code Here

  this.input = m;
  this.repair = r.model();
 
  Resource classType = ((OntModel)input).getProfile().CLASS();
 
  NodeIterator it = repair.listObjectsOfProperty( EYE.unknownClass );
  while( it.hasNext() )
    {
    RDFNode curr = it.nextNode();
    Resource subject = repair.listSubjectsWithProperty( EYE.unknownClass, curr ).nextResource();
      Resource stmtBnode = repair.createResource();
    repair.add( subject, EYE.repairConfidence, EYE.moderate )
          .add( subject, EYE.repairType, EYE.defineClass )
          .add( subject, EYE.checkFix, RDF.Statement )
View Full Code Here

      RDFNode numValsR = repair.listObjectsOfProperty( curr, EYE.numValues ).nextNode();
     
      int maxCard = strToInt( maxCardR.asNode().getLiteralLexicalForm() );
      int numVals = strToInt( numValsR.asNode().getLiteralLexicalForm() );
     
      NodeIterator it1b = m.listObjectsOfProperty( m.createResource( type.asNode().getURI() ), RDFS.subClassOf );
      while (it1b.hasNext() )
        {
        b = it1b.nextNode();
          try
            {
            if ( b.isAnon() )
              {
              if ( m.listObjectsOfProperty( m.createResource( b.asNode().getBlankNodeId() ), OWL.onProperty ).nextNode().equals( prop ) )
                break;
              }
            else
              if ( m.listObjectsOfProperty( m.createResource( b.asNode().getURI() ), OWL.onProperty ).nextNode().equals( prop ) )
                break;
            }
          catch (java.util.NoSuchElementException e)
            { // Not all statements returned are going to match the search above;
            } //  don't complain / warn about it!
        }
     
      // This looks misleading, but it will not be called if numVals > maxCard and owl:maxCardinality is not specified in the model!
      if ( numVals > maxCard )
        { // Increase owl:maxCardinality as needed, unless we can remove some invalid type declarations...
        // Get the rdfs:members of this failure's eye:values eye:Set
        List<String> types = new ArrayList<String>();
        List<Integer> typeCount = new ArrayList<Integer>();
        NodeIterator it1c = repair.listObjectsOfProperty( repair.createResource( repair.listObjectsOfProperty( curr, EYE.values ).nextNode().asNode().getBlankNodeId() ), RDFS.member);
        String defaultURI = "http://www.w3.org/2001/XMLSchema#String"; // This will be used later too (config file it??)
       
        while ( it1c.hasNext() )
          {
          RDFNode member = it1c.nextNode();
          String uri = member.asNode().getLiteralDatatypeURI();
          if ( uri == null )
            uri = defaultURI; // Default datatype URI
          if ( types.contains( uri ) )
            {
View Full Code Here

        {
        Resource curr = it.nextResource();
        RDFNode fix = report.listObjectsOfProperty( curr, EYE.repairType ).nextNode();
        if ( fix.equals( EYE.removeType ) )
          {
          NodeIterator it2 = repair.listObjectsOfProperty( curr, EYE.statementRemoved );
          while ( it2.hasNext() )
            {
            Resource bn = repair.createResource( it2.nextNode().asNode().getBlankNodeId() );
            Resource subj = (Resource)repair.listObjectsOfProperty( bn, RDF.subject ).nextNode();
            Property pred = input.createProperty( repair.listObjectsOfProperty( bn, RDF.predicate ).nextNode().asNode().getURI() );
            RDFNode obj = repair.listObjectsOfProperty( bn, RDF.object ).nextNode();
            output.remove( subj, pred, obj );
            }
          }
        else
          {
          RDFNode res = report.listObjectsOfProperty( curr, EYE.noConsistentTypeFor ).nextNode();
          Resource newClass = output.createResource();
          NodeIterator itb = ((OntModel)output).getBaseModel().listObjectsOfProperty( output.createResource( res.asNode().getURI() ), RDF.type );
          output.add( newClass, RDF.type, RDFS.Class );
          output.add( output.createResource( res.asNode().getURI() ), RDF.type, newClass );
          while ( itb.hasNext() )
            {
            RDFNode thisType = itb.nextNode();
            output.add( newClass, RDFS.subClassOf, thisType );
            output.remove( output.createStatement( output.createResource( res.asNode().getURI() ), RDF.type, thisType ) );
            }
          }
        }
View Full Code Here

    return false;
    }
 
  private boolean xSubClassOfY ( Resource x, Resource y )
    {
    NodeIterator it = input.listObjectsOfProperty( x, RDFS.subClassOf );
    if ( x.equals( y ) )
      return true;
    else
      while ( it.hasNext() )
        {
        RDFNode curr = it.nextNode();
        if ( !curr.equals( x ) )
          if ( curr.isURIResource() )
            {
            if ( xSubClassOfY( input.createResource( curr.asNode().getURI() ), y ) )
              return true;
View Full Code Here

    }
 
  private int getDepthOf( Resource node )
    {
    int greatestDepth = 1;
    NodeIterator it = input.listObjectsOfProperty( node, RDFS.subClassOf );
    while ( it.hasNext() )
      {
      RDFNode thisnode = it.nextNode();
      Resource curr = null;
      if ( thisnode.isURIResource() )
        curr = input.createResource( thisnode.asNode().getURI() );
      else
        curr = input.createResource( thisnode.asNode().getBlankNodeId() );
View Full Code Here

    // Remove the inference engine from the model - we don't want it replacing statements when we remove them!
    Resource subbiest = getReallySubbiestClass( RDFS.Resource, ModelFactory.createModelForGraph( input.getGraph() ) );
    if ( subbiest == null) // Fall back to Resource if worst comes to worst!
      subbiest = RDFS.Resource;
   
    NodeIterator it1 = repair.listObjectsOfProperty( EYE.hasNoType );
    while( it1.hasNext() )
      {
      RDFNode curr = it1.nextNode();
     
      Resource thisres = null;
     
      if ( curr.isURIResource() )
        thisres = repair.createResource( curr.asNode().getURI() );
View Full Code Here

TOP

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

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.