Search code examples
javardfsemantic-webjenaontology

how to retrieve value of an object in RDF when we have subject and properties using jena without sparql?


I want to retrieve my RDF statement's object value and I know how to iterate all of my classes and their respective properties but I don't know how can I access to their objects?

for example :

OntModel rdfModel = ModelFactory.createOntologyModel();
        rdfModel.read("mydata.rdf").read("myontology.rdf");
ExtendedIterator<OntClass> instances =  rdfModel.listClasses();
        while(instances.hasNext())
        {

            OntClass cls = instances.next();
            System.out.println("class name :" + cls.getURI());

            ExtendedIterator<OntProperty> prop = rdfModel.listOntProperties();
            while(prop.hasNext())
            {
                OntProperty ppp = prop.next();
                if (ppp.hasDomain(cls))
                {
                    System.out.println("the properties are :" + ppp.getURI());
                }
            }

now I want to have access to each and every object which have a relation to a property of an interated class.

how should I do that?


Solution

  • You can use OntClass.listProperties(Property). Javadocs are your friend.