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

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


      final TripleConsumer tc, int id) {
    final StmtIterator sit = model.listStatements();
    final HashMap<Resource, Integer> blanknodeNames = new HashMap<Resource, Integer>();
    int number=0;
    while (sit.hasNext()) {
      final Statement s = sit.next();

      Literal subject, predicate, object;

      subject = printResource2Literal(s.getSubject(), blanknodeNames, id);

      predicate = printResource2Literal(s.getPredicate(), blanknodeNames, id);

      if (s.getObject().isLiteral())
        object = printNTripleLiteral2Literal((com.hp.hpl.jena.rdf.model.Literal) s
            .getObject());
      else
        object = printResource2Literal((Resource) s.getObject(),
            blanknodeNames, id);

      final lupos.datastructures.items.Triple t = new lupos.datastructures.items.Triple(
          subject, predicate, object);
View Full Code Here


      builder.append(": ");
     
      StmtIterator iter = model.listStatements(null, model.getProperty(propertyUrl), (Resource)null);
     
      while (iter.hasNext()) {
        Statement stmt = iter.nextStatement();
        builder.append(stmt.getObject().asNode().getLiteralValue().toString());
      }
      builder.append("\n");     
    }
    logger.debug(builder.toString());   
       
View Full Code Here

        visited.add(r) ;

        StmtIterator sIter = r.listProperties() ;
        for ( ; sIter.hasNext() ; )
        {
            Statement stmt = sIter.nextStatement() ;
            closure(stmt, closureBlob, visited, test) ;
        }
    }
View Full Code Here

        // Now remove statements where their object is not of this type from this cardinality failure
        StmtIterator it1e = input.listStatements( input.createResource( repair.listObjectsOfProperty( curr, EYE.cardinalityFailure ).nextNode().asNode().getURI() ), input.createProperty( repair.listObjectsOfProperty( curr, EYE.onProperty ).nextNode().asNode().getURI() ), (RDFNode)null );
        Model remStat = ModelFactory.createDefaultModel();
        while ( it1e.hasNext() && numVals > maxCard ) // No sense removing more statements than we absolutely have to
          {
          Statement testing = it1e.nextStatement();
          String datatype = testing.getObject().asNode().getLiteralDatatypeURI();
          if ( datatype == null )
            datatype = defaultURI;
          if ( datatype != decided )
            {
            Resource bn = repair.createResource();
            remStat.add( curr, EYE.statementRemoved, bn )
                  .add( bn, RDF.type, RDF.Statement )
                  .add( bn, RDF.subject, testing.getSubject() )
                  .add( bn, RDF.predicate, testing.getPredicate() )
                  .add( bn, RDF.object, testing.getObject() );
            numVals--;
            }
          }
       
        if ( remStat.size() > 0 )
View Full Code Here

    Model out = ModelFactory.createDefaultModel();
    StmtIterator it = in.listStatements( null, RDFS.subClassOf, (RDFNode)null );
    int greatestDepth = 0;
    while ( it.hasNext() )
      {
      Statement curr = it.nextStatement();
      if ( in.listSubjectsWithProperty( RDFS.subClassOf, curr.getSubject() ).toList().size() <= 1 )
        {
        out.add( curr );
        out.add( input.listStatements( curr.getSubject(), null, (RDFNode)null ) );
        int temp = getDepthOf( curr.getSubject() );
        if ( temp > greatestDepth )
          greatestDepth = temp;
        }
      }
    it = out.listStatements();
    Model torem = ModelFactory.createDefaultModel();
    while ( it.hasNext() )
      {
      Statement curr = it.nextStatement();
      if ( getDepthOf( curr.getSubject() ) < greatestDepth )
        torem.add( curr );
      }
    out.remove( torem );
    return out;
    }
View Full Code Here

   
    StmtIterator it = repair.listStatements(null, EYE.cardinalityFailure, (RDFNode)null);
   
    while ( it.hasNext() )
      {
      Statement currFailure = it.nextStatement();
      Resource subj = currFailure.getSubject();
      NodeIterator it2 = repair.listObjectsOfProperty( subj, EYE.repairType );
      while ( it2.hasNext() )
        {
        RDFNode curr = it2.nextNode();
        if ( curr.equals( EYE.decreaseNumProperties ) )
View Full Code Here

    Model toDel = ModelFactory.createDefaultModel();
    Resource newUri = output.createResource( to );
    StmtIterator it = output.listStatements( output.createResource( from ), null, (RDFNode)null );
    while ( it.hasNext() )
      {
      Statement curr = it.nextStatement();
      toDel.add( curr );
      toAdd.add( newUri, curr.getPredicate(), curr.getObject() );
      }
   
    it = output.listStatements( null, null, output.createResource( from ) );
    while ( it.hasNext() )
      {
      Statement curr = it.nextStatement();
      toDel.add( curr );
      toAdd.add( curr.getSubject(), curr.getPredicate(), newUri );
      }
   
    output.remove( toDel );
    output.add( toAdd );
   
View Full Code Here

      StmtIterator it = input.listStatements((Resource)null, input.createProperty( curr.asNode().getURI() ), (RDFNode)null);
      Model toDel = ModelFactory.createDefaultModel();
      Model toAdd = ModelFactory.createDefaultModel();
      while( it.hasNext() )
        {
        Statement torem = it.nextStatement();
        toDel.add( torem );
        toAdd.add( torem.getSubject(), toAdd.createProperty( replacement ), torem.getObject() );
        }
     
      // Replace all instances of statement object curr in input with replacement
      it = input.listStatements((Resource)null, (Property)null, input.createResource( curr.asNode().getURI() ));
      while( it.hasNext() )
        {
        Statement torem = it.nextStatement();
        toDel.add( torem );
        toAdd.add( torem.getSubject(), torem.getPredicate(), toAdd.createResource( replacement ) );
        }
     
      input.remove( toDel );
      input.add( toAdd );
      }
View Full Code Here

          Model toAdd = ModelFactory.createDefaultModel();
          String replacement = it2.nextNode().asNode().getLiteralLexicalForm();
         
          while( it3.hasNext() )
            {
            Statement torem = it3.nextStatement();
            toDel.add( torem );
            toAdd.add( torem.getSubject(), toAdd.createProperty( replacement ), torem.getObject() );
            }
         
          input.remove( toDel );
          input.add( toAdd );
          }
View Full Code Here

  private  void loadRelationsWeight() {
    Model model = getRDFModel();
    StmtIterator itr = model.listStatements();

    while(itr.hasNext()) {
      Statement stmt = itr.nextStatement();
      Double weight = new Double(stmt.getObject().toString());
      weightTable.put(stmt.getSubject().getURI(), weight);
    }
    this.weightTable.put(DEFAULT_URI,DEFAULT_VALUE);
  }
View Full Code Here

TOP

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

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.