Hi Steve!
Looks like you're looking for something similar to
Individual::getOntClasses, but I think there is no such method in the code.
Also, once getting statements, the type itself would be opaque.
What you can do is to call .canAs() and then .as() methods, for example
OntModel m = ...
ExtendedIterator<Individual> individuals = m.listIndividuals();
individuals.forEach(i -> {
i.listProperties().forEach(stmt -> {
Property predicate = stmt.getPredicate();
if (predicate.canAs(OntProperty.class)) {
OntProperty property = predicate.as(OntProperty.class);
}
});
});
But I think this is not what you want, but I can't think of why you
would need this?
Cheers,
Lorenz
On 31.12.22 17:45, Steve Vestal wrote:
I am using Individual#listProperties (inherited
Resource#listProperties) to get the property instances (triples) for
Individuals in an OntModel. This method returns an iterator of
Statements. The statement objects are returned as ResourceImpl java
objects, and the predicates are returned as PropertyImpl java
objects. What I would like to get as statement objects and predicates
are the OntResource and OntProperty implementations from the
OntModel. I could find no methods such as Resource#isOntResource or
Resource#asOntResource. What is a good way to list property triples
that maintains existing Ontology natures of statement objects,
predicates, subjects?