rdf - Retrieving object and predicate for a subject without sparql -


i retrieved subject through model using getsubject() , subject want create relation respective object , predicate. how retrieve object , predicate particular subject through jena , without sparql?

to predicates , objects of particular subject given model m:

// resource had: resource subject; // = m.getresource(namespace + "subject");  // creates 'list' (iterator) on satements containing subject stmtiterator stmtiterator = m.liststatements(subject, null, (rdfnode) null);  // while have not processed these statements: while (stmtiterator.hasnext()){       // grab next statement      statement s = stmtiterator.next();       // retrieve predicate(property) , object statement      property predicate = s.getpredicate();      resource object = s.getobject();       // predicate      // object } 

however if mean want grab predicate , subject model add subject retrieved:

property property = m.getproperty(namespace + "propertyname"); resource object = m.getresource(namespace + "objectname"); subject.addproperty(property, object); 

Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -