Is there a way in Apache Jena to remove all resources from the current model, which do not have any properties?
I only found how to delete certain triples, but not something like iterating the resources, checking how much properties they have, etc.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It doesn’t exist because there is no need for it to exist. The RDF data model describes a Graph based upon triples where the subject and objects map to Resources in the Jena parlance and the predicates map to properties.
It is not possible to have a resource without any properties thus there is no need for a method to remove such resources to exist.
For iterating the resources try the
listSubjects()andlistObjects()methodsTo get the number of properties associated with a specific resource you can use the
listStatements()method to get aStmtIteratorand then count the statements returned by that e.g.If you want to count a whole variety of things (e.g. number of properties for each resource) at once you may want to use a SPARQL query instead e.g.
See the documentation for how to run SPARQL queries.