org.openrdf.model.Model.objects()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(7.8k)|赞(0)|评价(0)|浏览(132)

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

Model.objects介绍

[英]Returns a Set view of the objects contained in this model. The set is backed by the model, so changes to the model are reflected in the set, and vice-versa. If the model is modified while an iteration over the set is in progress (except through the iterator's own removeoperation), the results of the iteration are undefined. The set supports element removal, which removes all statements from the model for which that element is an object value, via the Iterator.remove, Set.remove, removeAll, retainAll, and clear operations. It does not support the add or addAll operations if the parameters subj or predare null.
[中]返回此模型中包含的对象的集合视图。集合由模型支持,因此对模型的更改会反映在集合中,反之亦然。如果在对集合进行迭代时修改了模型(除了通过迭代器自己的removeoperation),则迭代的结果是未定义的。该集合支持元素移除,即通过迭代器从该元素为对象值的模型中移除所有语句。移除,设置。移除、移除所有、保留和清除操作。如果参数sub或predall为null,则不支持add或addAll操作。

代码示例

代码示例来源:origin: anno4j/anno4j

public Set<? extends Value> getValues(URI pred) {
  return model.filter(self, pred, null).objects();
}

代码示例来源:origin: org.openrdf.alibaba/alibaba-repository-object

public Set<? extends Value> getValues(URI pred) {
  return model.filter(self, pred, null).objects();
}

代码示例来源:origin: org.openrdf.sesame/sesame-store

private Binding getBinding(Resource bindingNode) {
    Literal name = (Literal)model.filter(bindingNode, VARIABLE, null).objects().iterator().next();
    Value value = model.filter(bindingNode, VALUE, null).objects().iterator().next();
    return new BindingImpl(name.getLabel(), value);
  }
}

代码示例来源:origin: org.openrdf.alibaba/alibaba-repository-object

public Set<RDFProperty> getRDFProperties(URI pred) {
  Set<RDFProperty> set = new HashSet<RDFProperty>();
  for (Value value : model.filter(self, pred, null).objects()) {
    if (value instanceof Resource) {
      Resource subj = (Resource) value;
      set.add(new RDFProperty(model, subj));
    }
  }
  return set;
}

代码示例来源:origin: anno4j/anno4j

public Set<RDFProperty> getRDFProperties(URI pred) {
  Set<RDFProperty> set = new HashSet<RDFProperty>();
  for (Value value : model.filter(self, pred, null).objects()) {
    if (value instanceof Resource) {
      Resource subj = (Resource) value;
      set.add(new RDFProperty(model, subj));
    }
  }
  return set;
}

代码示例来源:origin: org.openrdf.alibaba/alibaba-repository-object

private Set<Value> findSuperClasses(Resource of, Set<Value> supers) {
  Set<Value> parent = ds.match(of, RDFS.SUBCLASSOF, null).objects();
  if (supers.addAll(parent)) {
    for (Value s : parent) {
      if (s instanceof Resource) {
        findSuperClasses((Resource) s, supers);
      }
    }
  }
  return supers;
}

代码示例来源:origin: eu.optique-project/r2rml-api-sesame-bridge

@Override
public Collection<Object> getObjects(Object graph, Object subj, Object pred) {
  Model m = ((Model) graph).filter((Resource) subj, (URI) pred, null,
      (Resource) null);
  Collection<Object> c = new HashSet<Object>();
  
  for(Value v : m.objects()){
    if(v instanceof Literal){
      Literal l = (Literal) v;
      c.add(l.stringValue());
    }else{
      c.add(v);
    }
  }
  return c;
}

代码示例来源:origin: anno4j/anno4j

private Set<Value> findSuperClasses(Resource of, Set<Value> supers) {
  Set<Value> parent = ds.match(of, RDFS.SUBCLASSOF, null).objects();
  if (supers.addAll(parent)) {
    for (Value s : parent) {
      if (s instanceof Resource) {
        findSuperClasses((Resource) s, supers);
      }
    }
  }
  return supers;
}

代码示例来源:origin: org.openrdf.sesame/sesame-store

private List<String> getBindingNames(Resource resultSetNode)
  throws RDFHandlerException
{
  List<String> bindingNames = new ArrayList<String>(16);
  Iterator<Value> varIter = model.filter(resultSetNode, RESULTVARIABLE, null).objects().iterator();
  while (varIter.hasNext()) {
    Value varName = varIter.next();
    if (varName instanceof Literal) {
      bindingNames.add(((Literal)varName).getLabel());
    }
    else {
      throw new RDFHandlerException("Value for " + RESULTVARIABLE + " is not a literal: " + varName);
    }
  }
  return bindingNames;
}

代码示例来源:origin: org.openrdf.alibaba/alibaba-repository-object

public List<? extends Value> getList(URI pred) {
  List<? extends Value> list = null;
  for (Value obj : model.filter(self, pred, null).objects()) {
    if (list == null && obj instanceof Resource) {
      list = new RDFList(model, (Resource) obj).asList();
    } else {
      List<? extends Value> other = new RDFList(model, (Resource) obj)
          .asList();
      if (!list.equals(other)) {
        other.removeAll(list);
        ((List) list).addAll(other);
      }
    }
  }
  return list;
}

代码示例来源:origin: anno4j/anno4j

public List<? extends Value> getList(URI pred) {
  List<? extends Value> list = null;
  for (Value obj : model.filter(self, pred, null).objects()) {
    if (list == null && obj instanceof Resource) {
      list = new RDFList(model, (Resource) obj).asList();
    } else {
      List<? extends Value> other = new RDFList(model, (Resource) obj)
          .asList();
      if (!list.equals(other)) {
        other.removeAll(list);
        ((List) list).addAll(other);
      }
    }
  }
  return list;
}

代码示例来源:origin: org.openrdf.sesame/sesame-model-testsuite

@Override
public Set makeEmptySet() {
  return new LinkedHashModel().filter(createURI("test"), RDF.VALUE, null).objects();
}

代码示例来源:origin: anno4j/anno4j

private void checkPropertyRanges() {
  loop: for (Statement st : ds.match(null, RDF.TYPE, RDF.PROPERTY)) {
    Resource p = st.getSubject();
    if (!ds.contains(p, RDFS.RANGE, null)) {
      for (Value sup : ds.match(p, RDFS.SUBPROPERTYOF, null).objects()) {
        for (Value obj : ds.match(sup, RDFS.RANGE, null).objects()) {
          ds.add(p, RDFS.RANGE, obj);
          continue loop;
        }
      }
      ds.add(p, RDFS.RANGE, RDFS.RESOURCE);
    }
  }
}

代码示例来源:origin: org.openrdf.alibaba/alibaba-repository-object

private void checkPropertyRanges() {
  loop: for (Statement st : ds.match(null, RDF.TYPE, RDF.PROPERTY)) {
    Resource p = st.getSubject();
    if (!ds.contains(p, RDFS.RANGE, null)) {
      for (Value sup : ds.match(p, RDFS.SUBPROPERTYOF, null).objects()) {
        for (Value obj : ds.match(sup, RDFS.RANGE, null).objects()) {
          ds.add(p, RDFS.RANGE, obj);
          continue loop;
        }
      }
      ds.add(p, RDFS.RANGE, RDFS.RESOURCE);
    }
  }
}

代码示例来源:origin: anno4j/anno4j

private void setMemberType(URI pred, URI type) {
  for (Value list : ds.match(null, pred, null).objects()) {
    if (list instanceof Resource) {
      RDFList members = new RDFList(ds, (Resource) list);
      for (Value member : members.asList()) {
        if (member instanceof Resource) {
          ds.add((Resource) member, RDF.TYPE, type);
        }
      }
    }
  }
}

代码示例来源:origin: org.openrdf.alibaba/alibaba-repository-object

private void setMemberType(URI pred, URI type) {
  for (Value list : ds.match(null, pred, null).objects()) {
    if (list instanceof Resource) {
      RDFList members = new RDFList(ds, (Resource) list);
      for (Value member : members.asList()) {
        if (member instanceof Resource) {
          ds.add((Resource) member, RDF.TYPE, type);
        }
      }
    }
  }
}

代码示例来源:origin: org.openrdf.alibaba/alibaba-repository-object

private void addParameters(Set<String> parameters, Set<Value> skip) {
  for (Resource prop : model.filter(null, RDFS.DOMAIN, self).subjects()) {
    if (isParameter(prop)) {
      parameters.add(prop.stringValue());
    }
  }
  for (Value sup : model.filter(self, RDFS.SUBCLASSOF, null).objects()) {
    if (isRDFSOrOWL(sup) || !skip.add(sup))
      continue;
    new RDFClass(model, (Resource) sup).addParameters(parameters, skip);
  }
}

代码示例来源:origin: anno4j/anno4j

private void addParameters(Set<String> parameters, Set<Value> skip) {
  for (Resource prop : model.filter(null, RDFS.DOMAIN, self).subjects()) {
    if (isParameter(prop)) {
      parameters.add(prop.stringValue());
    }
  }
  for (Value sup : model.filter(self, RDFS.SUBCLASSOF, null).objects()) {
    if (isRDFSOrOWL(sup) || !skip.add(sup))
      continue;
    new RDFClass(model, (Resource) sup).addParameters(parameters, skip);
  }
}

代码示例来源:origin: com.github.ansell.oas/oas-webservice-impl

private void assertModel(final Model parseTsv)
{
  Assert.assertFalse(parseTsv.isEmpty());
  Assert.assertEquals(4, parseTsv.subjects().size());
  Assert.assertEquals(6, parseTsv.predicates().size());
  Assert.assertEquals(9, parseTsv.objects().size());
}

代码示例来源:origin: org.openrdf.sesame/sesame-sail-dataset

@Override
  public void parse(Model model, Resource implNode)
    throws StoreConfigException
  {
    super.parse(model, implNode);
    for (Value node : model.filter(implNode, GRAPH, null).objects()) {
      URI name = model.filter((Resource)node, NAME, null).objectURI();
      String url = model.filter((Resource)node, DATASET, null).objectString();
      addGraph(name, url);
    }
    if (model.contains(implNode, CLOSED, null)) {
      closed = model.filter(implNode, CLOSED, null).objectLiteral().booleanValue();
    }
  }
}

相关文章