com.hp.hpl.jena.rdf.model.ResIterator.hasNext()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(9.4k)|赞(0)|评价(0)|浏览(87)

本文整理了Java中com.hp.hpl.jena.rdf.model.ResIterator.hasNext方法的一些代码示例,展示了ResIterator.hasNext的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ResIterator.hasNext方法的具体详情如下:
包路径:com.hp.hpl.jena.rdf.model.ResIterator
类名称:ResIterator
方法名:hasNext

ResIterator.hasNext介绍

暂无

代码示例

代码示例来源:origin: org.apache.clerezza.ext/org.apache.jena.jena-core

@Override
  public boolean hasNext() {
    if (modelListSubjects().hasNext())
      codeCoverage[7]++;
    return false;
  }
}, backStop };

代码示例来源:origin: epimorphics/elda

private boolean isMultiplyReferencedbNode(Resource r) {
    ResIterator ri = model.listSubjectsWithProperty(null, r);
    boolean multiRef = false;
    if (ri.hasNext()) {
      ri.next();
      multiRef = ri.hasNext();
    }
    ri.close();
    return multiRef;
  }
}

代码示例来源:origin: de.unibonn.iai.eis/luzzu-annotations

/**
 * Checks if a category uri exists in the metadata
 * 
 * @param categoryType - The URI of the Category Type
 * @return The URI if exists or null
 */
private Resource categoryExists(Resource categoryType){
  ResIterator resIte = this.metadata.listSubjectsWithProperty(RDF.type, categoryType);
  if (resIte.hasNext()){
    return resIte.next();
  }
  return null;
}

代码示例来源:origin: stackoverflow.com

// select all resources that are of type Parking
ResIterator blockIt = model.listResourcesWithProperty(null, model.getProperty("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"), model.getResource(parkingUri);
while (blockIt.hasNext()) {
  Resource currentParking = blockIt.next();
  // select all statements that have the current Parking entity as subject
  StmtIterator it = model.listStatements(currentParking, null, (RDFNode) null);
  while (it.hasNext()) {
     // here you will get all triples for the current Parking block
  }
}

代码示例来源:origin: org.w3/ldp-testsuite

@Test(
    groups = {SHOULD},
    description = "LDPC representations SHOULD NOT use RDF container "
        + "types rdf:Bag, rdf:Seq or rdf:List.")
@SpecTest(
    specRefUri = LdpTestSuite.SPEC_URI + "#ldpc-nordfcontainertypes",
    testMethod = METHOD.AUTOMATED,
    approval = STATUS.WG_APPROVED)
public void testNoRdfBagSeqOrList() {
  Model containerModel = getAsModel(getResourceUri());
  assertFalse(containerModel.listResourcesWithProperty(RDF.type, RDF.Bag)
      .hasNext(), "LDPC representations should not use rdf:Bag");
  assertFalse(containerModel.listResourcesWithProperty(RDF.type, RDF.Seq)
      .hasNext(), "LDPC representations should not use rdf:Seq");
  assertFalse(containerModel.listResourcesWithProperty(RDF.type, RDF.List).hasNext(),
      "LDPC representations should not use rdf:List"
  );
}

代码示例来源:origin: de.unibonn.iai.eis/luzzu-annotations

/**
 * Checks if a dimension uri exists in the metadata
 * 
 * @param dimensionType - The URI of the Dimension Type
 * @return The URI if exists or null
 */
private Resource dimensionExists(Resource dimensionType){
  ResIterator resIte = this.metadata.listSubjectsWithProperty(RDF.type, dimensionType);
  if (resIte.hasNext()){
    return resIte.next();
  }
  return null;
}

代码示例来源:origin: de.unibonn.iai.eis/luzzu-annotations

/**
   * Checks if a metric uri exists in the metadata
   * 
   * @param metricType - The URI of the Metric Type
   * @return The URI if exists or null
   */
  private Resource metricExists(Resource metricType){
    ResIterator resIte = this.metadata.listSubjectsWithProperty(RDF.type, metricType);
    if (resIte.hasNext()){
      return resIte.next();
    }
    return null;
  }
}

代码示例来源:origin: AskNowQA/AutoSPARQL

static Set<Resource> subjects(Model model,Property p, RDFNode r)
{
  Set<Resource> subjects = new HashSet<>();
  ResIterator it = model.listSubjectsWithProperty(p, r);
  while(it.hasNext()) subjects.add(it.next().asResource());
  it.close();
  return subjects;
}

代码示例来源:origin: epimorphics/elda

private List<Resource> findRoots() {
  List<Resource> roots = new ArrayList<Resource>();
  for (ResIterator i = model.listSubjects(); i.hasNext(); ) {
    Resource r = i.next();
    if (r.isAnon() && model.contains(null, null, r))
      continue;
    roots.add(r);
  }
  return roots;
}

代码示例来源:origin: epimorphics/elda

/** @return The RDF resource which is the root of statements about this page's metadata */
public RDFNodeWrapper pageRoot() {
  ResIterator i = getModel().listSubjectsWithProperty( RDF.type, API.Page );
  if (!i.hasNext()) {
    throw new EldaException( "Unexpected: page metadata has no resource with rdf:type api:Page" );
  }
  RDFNodeWrapper pageRoot = new RDFNodeWrapper( this, i.next() );
  if (i.hasNext()) {
    log.warn("unexpected: page metadata has more than one rdf:type api:Page resource - {}", i.next());
  }
  return pageRoot;
}

代码示例来源:origin: org.visallo/visallo-common-rdf

private void importRdfModel(Results results, Model model, File baseDir, GraphPropertyWorkData data, VisibilityJson visibilityJson, Visibility visibility, User user, Authorizations authorizations) {
  ResIterator subjects = model.listSubjects();
  while (subjects.hasNext()) {
    Resource subject = subjects.next();
    importSubject(results, graph, subject, baseDir, data, visibilityJson, visibility, user, authorizations);
  }
}

代码示例来源:origin: org.apache.clerezza.ext/org.apache.jena.jena-core

protected void writeRDFStatements( Model model, PrintWriter writer )
  {
  ResIterator rIter = model.listSubjects();
  while (rIter.hasNext()) writeRDFStatements( model, rIter.nextResource(), writer );
  }

代码示例来源:origin: org.apache.stanbol/org.apache.stanbol.cmsadapter.servicesapi

/**
 * @param reference
 *            Unique reference for which the {@link OntClass} is requested
 * @return {@link OntClass} if there is an already created class for cms object whose identifier got as a
 *         reference, otherwise <code>null</code>.
 */
public OntClass getOntClassByReference(String reference) throws UnsupportedPolymorphismException,
                            ConversionException {
  ResIterator it = ontModel.listResourcesWithProperty(CMSAdapterVocabulary.CMSAD_RESOURCE_REF_PROP,
    reference);
  Resource resource;
  if (it.hasNext()) {
    resource = it.next();
    return resource.as(OntClass.class);
  }
  return null;
}

代码示例来源:origin: epimorphics/elda

protected void loadAnnotations( Set<String> notThese, Set<String> seen, ResIterator ri, boolean isProperty, PrefixMapping prefixes) {
  while (ri.hasNext()) {
    Resource res = ri.next();
    String uri = res.getURI();
    if (uri != null) {
      String shortForm = null;
      seen.add( uri );
      if (!notThese.contains(uri)) {
        shortForm = setShortForms( prefixes, res, uri );
      }
      if (isProperty) {
        if (shortForm == null) shortForm = getLocalName(uri);
        createPropertyRecord( shortForm, res );
      }
    }
  }
}

代码示例来源:origin: org.apache.stanbol/org.apache.stanbol.cmsadapter.servicesapi

/**
 * Gets an {@link ObjectProperty} for the unique reference specified.
 * 
 * @param reference
 *            Unique reference for which the {@link ObjectProperty} is requested.
 * @return {@link ObjectProperty} instance if there is a valid one, otherwise <code>null</code>.
 */
public ObjectProperty getObjectPropertyByReference(String reference) throws UnsupportedPolymorphismException,
                                  ConversionException {
  ResIterator it = ontModel.listResourcesWithProperty(CMSAdapterVocabulary.CMSAD_RESOURCE_REF_PROP,
    reference);
  Resource resource;
  if (it.hasNext()) {
    resource = it.next();
    return resource.as(ObjectProperty.class);
  }
  return null;
}

代码示例来源:origin: org.apache.stanbol/org.apache.stanbol.cmsadapter.servicesapi

/**
 * Gets an {@link Individual} for the unique reference specified.
 * 
 * @param reference
 *            Unique reference for which {@link Individual} is requested.
 * @return {@link Individual} instance if there is a valid one, otherwise <code>null</code>
 */
public Individual getLooseIndividualByReference(String reference) throws UnsupportedPolymorphismException,
                                 ConversionException {
  ResIterator it = ontModel.listResourcesWithProperty(CMSAdapterVocabulary.CMSAD_RESOURCE_REF_PROP,
    reference);
  Resource resource;
  if (it.hasNext()) {
    resource = it.next();
    return resource.as(Individual.class);
  }
  return null;
}

代码示例来源:origin: org.apache.stanbol/org.apache.stanbol.cmsadapter.servicesapi

/**
 * Gets an {@link DatatypeProperty} for the unique reference specified.
 * 
 * @param reference
 *            Unique reference for which the {@link DatatypeProperty} is requested.
 * @return {@link DatatypeProperty} instance if there is a valid one, otherwise <code>null</code>.
 */
public DatatypeProperty getDatatypePropertyByReference(String reference) throws UnsupportedPolymorphismException,
                                    ConversionException {
  ResIterator it = ontModel.listResourcesWithProperty(CMSAdapterVocabulary.CMSAD_RESOURCE_REF_PROP,
    reference);
  Resource resource;
  if (it.hasNext()) {
    resource = it.next();
    return resource.as(DatatypeProperty.class);
  }
  return null;
}

代码示例来源:origin: org.apache.stanbol/org.apache.stanbol.cmsadapter.servicesapi

/**
 * Gets an {@link OntProperty} for the unique reference specified.
 * 
 * @param reference
 *            Unique reference for which the {@link OntProperty} is requested.
 * @return {@link OntProperty} instance if there is a valid one, otherwise <code>null</code>.
 */
public OntProperty getPropertyByReference(String reference) throws UnsupportedPolymorphismException,
                              ConversionException {
  ResIterator it = ontModel.listResourcesWithProperty(CMSAdapterVocabulary.CMSAD_RESOURCE_REF_PROP,
    reference);
  Resource resource;
  if (it.hasNext()) {
    resource = it.next();
    return resource.as(OntProperty.class);
  }
  return null;
}

代码示例来源:origin: stackoverflow.com

public static Model queryWithAPI() { 
  // Create a model for the output, and add the prefix mappings
  // from the input model.  This step isn't necessary, but it 
  // makes the output easier to read.
  final Model results = ModelFactory.createDefaultModel();
  results.setNsPrefixes( input );

  // Iterate through the SocialTags in the data, and for each SocialTag s, retrieve
  // the statements [s, name, ?name] and [s, importance, ?importance] from the input
  // model, and add them to the results.
  for ( final ResIterator it = input.listResourcesWithProperty( RDF.type, SocialTag ); it.hasNext(); ) {
    final Resource socialTag = it.next();
    results.add( socialTag.getProperty( importance ));
    results.add( socialTag.getProperty( name ));
  }
  return results;
}

代码示例来源:origin: epimorphics/elda

public APITester( Model model, ModelLoader loader ) {
  for (ResIterator ri = model.listSubjectsWithProperty(RDF.type, API.API); ri.hasNext();) {
    Resource api = ri.next();
    APISpec spec = new APISpec( EldaFileManager.get(), api, loader );
    specifications.put(api.getLocalName(), spec);
    for (APIEndpointSpec eps : spec.getEndpoints()) {
      APIEndpoint ep = APIFactory.makeApiEndpoint(eps);
      register(ep.getURITemplate(), ep);
    }
  }
}

相关文章