當前位置: 首頁>>代碼示例>>Java>>正文


Java StmtIterator.nextStatement方法代碼示例

本文整理匯總了Java中com.hp.hpl.jena.rdf.model.StmtIterator.nextStatement方法的典型用法代碼示例。如果您正苦於以下問題:Java StmtIterator.nextStatement方法的具體用法?Java StmtIterator.nextStatement怎麽用?Java StmtIterator.nextStatement使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.hp.hpl.jena.rdf.model.StmtIterator的用法示例。


在下文中一共展示了StmtIterator.nextStatement方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getUndefinedResources

import com.hp.hpl.jena.rdf.model.StmtIterator; //導入方法依賴的package包/類
public Collection<Resource> getUndefinedResources(Model model) {
	Set<Resource> result = new HashSet<Resource>();
	StmtIterator it = model.listStatements();
	while (it.hasNext()) {
		Statement stmt = it.nextStatement();
		if (stmt.getSubject().isURIResource()
				&& stmt.getSubject().getURI().startsWith(namespace)
				&& !resources.contains(stmt.getSubject())) {
			result.add(stmt.getSubject());
		}
		if (stmt.getPredicate().equals(RDF.type)) continue;
		if (stmt.getObject().isURIResource()
				&& stmt.getResource().getURI().startsWith(namespace)
				&& !resources.contains(stmt.getResource())) {
			result.add(stmt.getResource());
		}
	}
	return result;
}
 
開發者ID:d2rq,項目名稱:r2rml-kit,代碼行數:20,代碼來源:VocabularySummarizer.java

示例2: runQueryOnInstance

import com.hp.hpl.jena.rdf.model.StmtIterator; //導入方法依賴的package包/類
/**
 * Runs a given Jena Query on a given instance and adds the inferred triples
 * to a given Model.
 * @param queryWrapper  the wrapper of the CONSTRUCT query to execute
 * @param queryModel  the query Model
 * @param newTriples  the Model to write the triples to
 * @param instance  the instance to run the inferences on
 * @param checkContains  true to only call add if a Triple wasn't there yet
 * @return true if changes were done (only meaningful if checkContains == true)
 */
public static boolean runQueryOnInstance(QueryWrapper queryWrapper, Model queryModel, Model newTriples, Resource instance, boolean checkContains) {
	boolean changed = false;
	QueryExecution qexec = ARQFactory.get().createQueryExecution(queryWrapper.getQuery(), queryModel);
	QuerySolutionMap bindings = new QuerySolutionMap();
	bindings.add(SPIN.THIS_VAR_NAME, instance);
	Map<String,RDFNode> initialBindings = queryWrapper.getTemplateBinding();
	if(initialBindings != null) {
		for(String varName : initialBindings.keySet()) {
			RDFNode value = initialBindings.get(varName);
			bindings.add(varName, value);
		}
	}
	qexec.setInitialBinding(bindings);
	Model cm = qexec.execConstruct();
	StmtIterator cit = cm.listStatements();
	while(cit.hasNext()) {
		Statement s = cit.nextStatement();
		if(!checkContains || !queryModel.contains(s)) {
			changed = true;
			newTriples.add(s);
		}
	}
	return changed;
}
 
開發者ID:BenzclyZhang,項目名稱:BimSPARQL,代碼行數:35,代碼來源:SPINInferencesWithoutConstructor.java

示例3: getNumberOfLinks

import com.hp.hpl.jena.rdf.model.StmtIterator; //導入方法依賴的package包/類
private Integer getNumberOfLinks(String nif) {
    Model model = ModelFactory.createDefaultModel();
    model.read(new ByteArrayInputStream(nif.getBytes()), null, "TTL");
    StmtIterator iter = model.listStatements();

    Integer result = 0;

    while (iter.hasNext()) {
        Statement stm = iter.nextStatement();
        if (NIF21Format.RDF_PROPERTY_IDENTREF.equals(stm.getPredicate().toString())) {
            result += 1;
        }
    }

    return result;
}
 
開發者ID:freme-project,項目名稱:freme-ner,代碼行數:17,代碼來源:FremeNERLabelMatch.java

示例4: getAllEntityEvents

import com.hp.hpl.jena.rdf.model.StmtIterator; //導入方法依賴的package包/類
static ArrayList<String> getAllEntityEvents (Dataset dataset, String entity) {
    ArrayList<String> events = new ArrayList<String>();
    Iterator<String> it = dataset.listNames();
    while (it.hasNext()) {
        String name = it.next();
        if (!name.equals(instanceGraph) && (!name.equals(provenanceGraph))) {
            Model namedModel = dataset.getNamedModel(name);
            StmtIterator siter = namedModel.listStatements();
            while (siter.hasNext()) {
                Statement s = siter.nextStatement();
                String object = getObjectValue(s).toLowerCase();
                if (object.indexOf(entity.toLowerCase()) > -1) {
                    String subject = s.getSubject().getURI();
                    if (!events.contains(subject)) {
                        events.add(subject);
                    }
                }
            }
        }
    }
    return events;
}
 
開發者ID:newsreader,項目名稱:StreamEventCoreference,代碼行數:23,代碼來源:TrigUtil.java

示例5: getAllNoteDescriptors

import com.hp.hpl.jena.rdf.model.StmtIterator; //導入方法依賴的package包/類
public ResourceDescriptor[] getAllNoteDescriptors(String outlineUri) {
    Model outlineModel;
    try {
        outlineModel = MindRaider.outlineCustodian.getModel(outlineUri);
        Property property = RDF.type;
        String literal = MindRaiderConstants.MR_OWL_CLASS_CONCEPT;
        StmtIterator i = outlineModel.listStatements((com.hp.hpl.jena.rdf.model.Resource)null,property,outlineModel.getResource(literal));
        ArrayList<String> noteUris=new ArrayList<String>();
        while(i.hasNext()) {
            Statement s=i.nextStatement();
            noteUris.add(s.getSubject().getURI());
        }
        return getDescriptorsForNoteUris(true, outlineModel, noteUris.toArray(new String[noteUris.size()]));
    } catch (Exception e) {
        logger.debug("Unable to get resource descriptors",e); // {{debug}}
    }

    return null;
}
 
開發者ID:dvorka,項目名稱:mindraider,代碼行數:20,代碼來源:OutlineCustodian.java

示例6: createStatement

import com.hp.hpl.jena.rdf.model.StmtIterator; //導入方法依賴的package包/類
/**
 * Create a statement.
 * 
 * @param subject
 *            the resource
 * @param predicateUri
 *            the predicate url
 * @param objectUri
 *            the object url
 * @param literal
 *            the literal flag
 * @return a Statement object
 */
public Statement createStatement(Resource subject, String predicateUri,
        String objectUri, boolean literal) {
    RDFNode objectResource;
    Property predicateResource = model.createProperty(predicateUri);

    if (literal) {
        objectResource = model.createLiteral(objectUri);
    } else {
        objectResource = model.createResource(objectUri);
    }
    subject.addProperty(predicateResource, objectResource);

    StmtIterator i = model.listStatements(subject, predicateResource,
            objectResource);
    if (i.hasNext()) {
        return i.nextStatement();
    }
    JOptionPane.showMessageDialog(MindRaider.mainJFrame,
            "Unable to fetch statement.", "Error",
            JOptionPane.ERROR_MESSAGE);
    return null;
}
 
開發者ID:dvorka,項目名稱:mindraider,代碼行數:36,代碼來源:RdfModel.java

示例7: getPropertyValues

import com.hp.hpl.jena.rdf.model.StmtIterator; //導入方法依賴的package包/類
<T> List<T> getPropertyValues(final Resource resource, final String property, final Function<Statement,Optional<T>> filter) {
	Preconditions.checkState(this.model!=null);
	final StmtIterator stmts = resource.listProperties(this.model.createProperty(property));
	try {
		final List<T> values=Lists.newArrayList();
		while(stmts.hasNext()) {
			final Statement st=stmts.nextStatement();
			final Optional<T> result = filter.apply(st);
			if(result.isPresent()) {
				values.add(result.get());
			}
		}
		return values;
	} finally {
		stmts.close();
	}
}
 
開發者ID:SmartDeveloperHub,項目名稱:sdh-vocabulary,代碼行數:18,代碼來源:ModuleHelper.java

示例8: parseN3

import com.hp.hpl.jena.rdf.model.StmtIterator; //導入方法依賴的package包/類
private static void parseN3(GrabMappingsHandler handler, String infileurl) {
  Model model = ModelFactory.createDefaultModel();
  model.read(infileurl, "N3");

  AResourceImpl sub = new AResourceImpl();
  AResourceImpl pred = new AResourceImpl();
  AResourceImpl objres = new AResourceImpl();
  ALiteralImpl objlit = new ALiteralImpl();
  StmtIterator it = model.listStatements();
  while (it.hasNext()) {
    Statement stmt = it.nextStatement();
    RDFNode object = stmt.getObject();
    sub.setResource(stmt.getSubject());
    pred.setResource(stmt.getPredicate());
    
    if (object instanceof Literal) {
      objlit.setLiteral((Literal) object);
      handler.statement(sub, pred, objlit);
    } else {
      objres.setResource((Resource) object);
      handler.statement(sub, pred, objres);
    }
  }
}
 
開發者ID:ontopia,項目名稱:ontopia,代碼行數:25,代碼來源:RDFIntroSpector.java

示例9: getRequest

import com.hp.hpl.jena.rdf.model.StmtIterator; //導入方法依賴的package包/類
private List getRequest(Resource pcho)
{
    List l = new ArrayList();
    StmtIterator iter = pcho.listProperties();
    while ( iter.hasNext() )
    {
        Statement stmt = iter.nextStatement();
        RDFNode   node = stmt.getObject();
        String    uri  = stmt.getPredicate().getURI();
        if ( node.isResource() || !_fields.containsKey(uri) ) { continue; }

        String    prop = getQName(stmt.getPredicate());
        String    value = node.asLiteral().getString();
        String[]  vocs  = _fields.get(uri);
        for ( String key : normalizeInternal(value) )
        {
            Map m = new HashMap(3);
            m.put("originalField", prop + ";" + value);
            m.put("value", key);
            m.put("vocabularies",  vocs);
            l.add(m);
        }
    }
    return l;
}
 
開發者ID:hugomanguinhas,項目名稱:europeana,代碼行數:26,代碼來源:EnrichmentAPI.java

示例10: mergeResources

import com.hp.hpl.jena.rdf.model.StmtIterator; //導入方法依賴的package包/類
public static void mergeResources(Resource src, Resource trg)
{
	Property sameAs = src.getModel().getProperty(URI_SAMEAS);

	StmtIterator iter = src.listProperties();
	while ( iter.hasNext() )
	{
		Statement stmt = iter.nextStatement();

		Property p = stmt.getPredicate();
		if ( p.equals(sameAs) ) { continue; }

		trg.addProperty(p, stmt.getObject());
		iter.remove();
	}
}
 
開發者ID:hugomanguinhas,項目名稱:europeana,代碼行數:17,代碼來源:VocsUtils.java

示例11: getDefaultCortexSupport

import com.hp.hpl.jena.rdf.model.StmtIterator; //導入方法依賴的package包/類
/**
 * Retrieve the dhus system supported items for file scanning processing.
 * Is considered supported all classes having
 * <code>http://www.gael.fr/dhus#metadataExtractor</code> property
 * connection.
 * @return the list of supported class names.
 */
public static synchronized String[] getDefaultCortexSupport ()
{
   DrbCortexModel model;
   try
   {
      model = DrbCortexModel.getDefaultModel ();
   }
   catch (IOException e)
   {
      throw new UnsupportedOperationException (
         "Drb cortex not properly initialized.");
   }

   ExtendedIterator it=model.getCortexModel ().getOntModel ().listClasses ();
   List<String>list = new ArrayList<String> ();

   while (it.hasNext ())
   {
      OntClass cl = (OntClass)it.next ();

      OntProperty metadata_extractor_p = cl.getOntModel().getOntProperty(
            "http://www.gael.fr/dhus#support");

      StmtIterator properties = cl.listProperties (metadata_extractor_p);
      while (properties.hasNext ())
      {
         Statement stmt = properties.nextStatement ();
         LOGGER.debug ("Scanner Support Added for " +
            stmt.getSubject ().toString ());
         list.add (stmt.getSubject ().toString ());
      }
   }
   return list.toArray (new String[list.size ()]);
}
 
開發者ID:SentinelDataHub,項目名稱:dhus-core,代碼行數:42,代碼來源:ScannerFactory.java

示例12: bulkUpdate

import com.hp.hpl.jena.rdf.model.StmtIterator; //導入方法依賴的package包/類
/**
 * Method called to Chunk the triples into N-Sized batches and post to VIVO.
 * This is designed to work around / handle errors when posting sets of triples
 * over 10,000 to the API.
 *
 * @param namedGraph String with named graph.
 * @param changeModel Jena model with set of changes to sync to store.
 * @param changeType Either add or remove.
 * @return Boolean true if update was successful.
 * @throws IOException
 */
private Boolean bulkUpdate(String namedGraph, Model changeModel, String changeType) throws IOException {
    // Temporary model to hold
    Model tmpModel = ModelFactory.createDefaultModel();
    Integer bSize = Integer.parseInt(batchSize);
    // Use an integer to count triples rather than calling size on the model
    // during each loop.
    Integer size = 0;
    StmtIterator iter = changeModel.listStatements();
    while (iter.hasNext()) {
        Statement stmt = iter.nextStatement();  // get next statement
        tmpModel.add(stmt);
        size++;
        if (size >= bSize) {
            // Submit
            log.info("Submitting " + size + " triples to " + namedGraph);
            submitBatch(tmpModel, namedGraph, changeType);
            // Reset the tmp model.
            tmpModel.removeAll();
            // Reset the counter.
            size = 0;
        }
    }
    log.info("model size:" + tmpModel.size());
    // Submit the remaining statements, if any.
    if (tmpModel.size() > 0) {
        submitBatch(tmpModel, namedGraph, changeType);
    }
    return true;
}
 
開發者ID:lawlesst,項目名稱:karma2vivo,代碼行數:41,代碼來源:VIVOSPARQLClient.java

示例13: getUndefinedClasses

import com.hp.hpl.jena.rdf.model.StmtIterator; //導入方法依賴的package包/類
public Collection<Resource> getUndefinedClasses(Model model) {
	Set<Resource> result = new HashSet<Resource>();
	StmtIterator it = model.listStatements(null, RDF.type, (RDFNode) null);
	while (it.hasNext()) {
		Statement stmt = it.nextStatement();
		if (stmt.getObject().isURIResource()
				&& stmt.getResource().getURI().startsWith(namespace)
				&& !classes.contains(stmt.getObject())) {
			result.add(stmt.getResource());
		}
	}
	return result;
}
 
開發者ID:d2rq,項目名稱:r2rml-kit,代碼行數:14,代碼來源:VocabularySummarizer.java

示例14: getUndefinedProperties

import com.hp.hpl.jena.rdf.model.StmtIterator; //導入方法依賴的package包/類
public Collection<Property> getUndefinedProperties(Model model) {
	Set<Property> result = new HashSet<Property>();
	StmtIterator it = model.listStatements();
	while (it.hasNext()) {
		Statement stmt = it.nextStatement();
		if (stmt.getPredicate().getURI().startsWith(namespace)
				&& !properties.contains(stmt.getPredicate())) {
			result.add(stmt.getPredicate());
		}
	}
	return result;
}
 
開發者ID:d2rq,項目名稱:r2rml-kit,代碼行數:13,代碼來源:VocabularySummarizer.java

示例15: usesVocabulary

import com.hp.hpl.jena.rdf.model.StmtIterator; //導入方法依賴的package包/類
public boolean usesVocabulary(Model model) {
	StmtIterator it = model.listStatements();
	while (it.hasNext()) {
		Statement stmt = it.nextStatement();
		if (stmt.getPredicate().getURI().startsWith(namespace)) {
			return true;
		}
		if (stmt.getPredicate().equals(RDF.type) && stmt.getResource().getURI().startsWith(namespace)) {
			return true;
		}
	}
	return false;
}
 
開發者ID:d2rq,項目名稱:r2rml-kit,代碼行數:14,代碼來源:VocabularySummarizer.java


注:本文中的com.hp.hpl.jena.rdf.model.StmtIterator.nextStatement方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。