本文整理了Java中org.apache.jena.rdf.model.Model.listSubjects()
方法的一些代码示例,展示了Model.listSubjects()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Model.listSubjects()
方法的具体详情如下:
包路径:org.apache.jena.rdf.model.Model
类名称:Model
方法名:listSubjects
[英]List all resources which are subjects of statements.
Subsequent operations on those resource may modify this model.
[中]列出所有作为陈述主题的资源。
对这些资源的后续操作可能会修改此模型。
代码示例来源:origin: google/data-transfer-project
/** Gets a given resource (including the #this reference) from a model. **/
public static Resource getResource(String url, Model model) {
List<Resource> matchingSubjects = model.listSubjects()
.filterKeep(s -> s.getURI() != null)
.filterKeep(s -> s.getURI().equalsIgnoreCase(url)
|| s.getURI().equalsIgnoreCase(url + "#this")).toList();
if (matchingSubjects.isEmpty()) {
return null;
}
checkState(matchingSubjects.size() == 1,
"Model %s didn't contain %s",
model,
url);
return matchingSubjects.get(0);
}
代码示例来源:origin: google/data-transfer-project
/** Utility method for debugging model problems. **/
@SuppressWarnings("unused")
public static void describeModel(Model model) {
model.listSubjects().forEachRemaining(
r -> {
logger.info(r.toString());
StmtIterator props = r.listProperties();
props.forEachRemaining(p -> logger.info("\t" + p.getPredicate() + " " + p.getObject()));
}
);
}
}
代码示例来源:origin: google/data-transfer-project
private List<VCard> parseAddressBook(Resource selfResource, SolidUtilities utilities)
throws IOException {
String peopleUri = selfResource.getProperty(NAME_EMAIL_INDEX_PROPERTY).getResource().getURI();
Model peopleModel = utilities.getModel(peopleUri);
List<VCard> vcards = new ArrayList<>();
ResIterator subjects = peopleModel.listSubjects();
while (subjects.hasNext()) {
Resource subject = subjects.nextResource();
Model personModel = utilities.getModel(subject.getURI());
Resource personResource = SolidUtilities.getResource(subject.getURI(), personModel);
if (personResource == null) {
throw new IllegalStateException(subject.getURI() + " not found in " + subject.toString());
}
vcards.add(parsePerson(personResource));
}
return vcards;
}
代码示例来源:origin: apache/jena
private ResIterator modelListSubjects() {
ResIterator resIt = model.listSubjects();
openResIterators.add(resIt);
return resIt;
}
代码示例来源:origin: org.apache.jena/jena-core
private ResIterator modelListSubjects() {
ResIterator resIt = model.listSubjects();
openResIterators.add(resIt);
return resIt;
}
代码示例来源:origin: com.powsybl/powsybl-triple-store-impl-jena
private static Resource[] subjectsTypes(Model model) {
Set<Resource> types = new HashSet<>();
ResIterator rs = model.listSubjects();
while (rs.hasNext()) {
Resource r = rs.nextResource();
Statement s = type(r);
if (s != null) {
types.add(s.getObject().asResource());
}
}
return types.toArray(new Resource[0]);
}
代码示例来源:origin: org.aksw.rdfunit/rdfunit-model
private Model reanonimisePathBlankNodes(Resource resource, RDFNode rdfNode) {
Model pathModel = ModelFactory.createDefaultModel();
pathModel.add(rdfNode.getModel());
pathModel.add(resource, SHACL.resultPath, rdfNode);
ImmutableSet<Resource> resources = ImmutableSet.copyOf(pathModel.listSubjects());
resources.stream()
.filter(Resource::isAnon)
.filter(r -> r != resource)
.forEach(r -> ResourceUtils.renameResource(r, null));
return pathModel;
}
}
代码示例来源:origin: AKSW/RDFUnit
private Model reanonimisePathBlankNodes(Resource resource, RDFNode rdfNode) {
Model pathModel = ModelFactory.createDefaultModel();
pathModel.add(rdfNode.getModel());
pathModel.add(resource, SHACL.resultPath, rdfNode);
ImmutableSet<Resource> resources = ImmutableSet.copyOf(pathModel.listSubjects());
resources.stream()
.filter(Resource::isAnon)
.filter(r -> r != resource)
.forEach(r -> ResourceUtils.renameResource(r, null));
return pathModel;
}
}
代码示例来源:origin: apache/jena
protected void writeRDFStatements( Model model, PrintWriter writer )
{
ResIterator rIter = model.listSubjects();
while (rIter.hasNext()) writeRDFStatements( model, rIter.nextResource(), writer );
}
代码示例来源:origin: 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: apache/jena
private Set<Node> gsp(RDFConnection conn, String graphName) {
Set<Node> results = new HashSet<>();
Model model = graphName == null ? conn.fetch() : conn.fetch(graphName);
// Extract subjects.
Set<Node> seen =
SetUtils.toSet(
Iter.asStream(model.listSubjects())
.map(Resource::asNode)
);
return seen;
}
代码示例来源:origin: org.apache.jena/jena-fuseki-main
private Set<Node> gsp(RDFConnection conn, String graphName) {
Set<Node> results = new HashSet<>();
Model model = graphName == null ? conn.fetch() : conn.fetch(graphName);
// Extract subjects.
Set<Node> seen =
SetUtils.toSet(
Iter.asStream(model.listSubjects())
.map(Resource::asNode)
);
return seen;
}
代码示例来源:origin: apache/jena
@Override
public SecuredResIterator listSubjects() throws ReadDeniedException, AuthenticationRequiredException {
checkRead();
ExtendedIterator<Resource> rIter = holder.getBaseItem().listSubjects();
if (!canRead(Triple.ANY)) {
rIter = rIter.filterKeep(new ResourceFilter());
}
return new SecuredResIterator(holder.getSecuredItem(), rIter);
}
代码示例来源:origin: apache/jena
public void testListSubjects()
{
fill(model);
final List<Resource> L = model.listSubjects().toList();
Assert.assertEquals(TestObjects.numberSubjects, L.size());
final Set<Resource> wanted = subjectSet(TestObjects.numberSubjects);
Assert.assertEquals(wanted, GraphTestBase.iteratorToSet(L.iterator()));
}
代码示例来源:origin: org.apache.jena/jena-core
public void testListSubjects()
{
fill(model);
final List<Resource> L = model.listSubjects().toList();
Assert.assertEquals(TestObjects.numberSubjects, L.size());
final Set<Resource> wanted = subjectSet(TestObjects.numberSubjects);
Assert.assertEquals(wanted, GraphTestBase.iteratorToSet(L.iterator()));
}
代码示例来源:origin: apache/jena
private Set<Node> gsp(String user, String password, String graphName) {
Set<Node> results = new HashSet<>();
try (RDFConnection conn = RDFConnectionFactory.connectPW(baseUrl, user, password)) {
Model model = graphName == null ? conn.fetch() : conn.fetch(graphName);
// Extract subjects.
Set<Node> seen =
SetUtils.toSet(
Iter.asStream(model.listSubjects())
.map(r->r.asNode())
);
return seen;
}
}
代码示例来源:origin: org.apache.jena/jena-fuseki-main
private Set<Node> gsp(String user, String password, String graphName) {
Set<Node> results = new HashSet<>();
try (RDFConnection conn = RDFConnectionFactory.connectPW(baseUrl, user, password)) {
Model model = graphName == null ? conn.fetch() : conn.fetch(graphName);
// Extract subjects.
Set<Node> seen =
SetUtils.toSet(
Iter.asStream(model.listSubjects())
.map(r->r.asNode())
);
return seen;
}
}
代码示例来源:origin: apache/jena
public void testListSubjectsWorksAfterRemoveProperties()
{
final Model m = ModelHelper.modelWithStatements(this,
"p1 before terminal; p2 before terminal");
m.createResource("eh:/p1").removeProperties();
ModelHelper.assertIsoModels(
ModelHelper.modelWithStatements(this, "p2 before terminal"), m);
Assert.assertEquals(ModelHelper.resourceSet("p2"), m.listSubjects()
.toSet());
}
代码示例来源:origin: org.apache.jena/jena-core
public void testListSubjectsWorksAfterRemoveProperties()
{
final Model m = ModelHelper.modelWithStatements(this,
"p1 before terminal; p2 before terminal");
m.createResource("eh:/p1").removeProperties();
ModelHelper.assertIsoModels(
ModelHelper.modelWithStatements(this, "p2 before terminal"), m);
Assert.assertEquals(ModelHelper.resourceSet("p2"), m.listSubjects()
.toSet());
}
代码示例来源:origin: apache/jena
public void testListSubjectsWorksAfterRemovePropertiesWIthLots()
{
final Model m = ModelHelper.modelWithStatements(this,
"p2 before terminal");
for (int i = 0; i < 100; i += 1)
{
ModelHelper.modelAdd(m, "p1 hasValue " + i);
}
m.createResource("eh:/p1").removeProperties();
ModelHelper.assertIsoModels(
ModelHelper.modelWithStatements(this, "p2 before terminal"), m);
Assert.assertEquals(ModelHelper.resourceSet("p2"), m.listSubjects()
.toSet());
}
}
内容来源于网络,如有侵权,请联系作者删除!