@Override public void addTriple(Triple t) { addTriplePath(new TriplePath(t)) ; }
ElementPathBlock triplePattern = new ElementPathBlock(); Node typ = NodeFactory.createVariable("typ"); Node sometype = ...; // Assume OK // This represents rdfs:subClassOf+ Path pathSubClassOfPlus = PathFactory.pathOneOrMore1( PathFactory.pathLink(RDFS.subClassOf.asNode()) ); // This represents the SPARQL: ?typ rdfs:subClassOf+ sometype . TriplePath subClassOfPlus = new TriplePath(typ, subClassOfPlus, sometype) triplePattern.addTriplePath(subClassOfPlus); // ... One can also add regular Triple instances afterwards query.setQueryPattern(triplePattern);
@Override public void addTriple(int index, Triple t) { addTriplePath(index, new TriplePath(t)) ; }
public static ElementPathBlock createElement(TriplePath triplePath) { ElementPathBlock result = new ElementPathBlock(); result.addTriplePath(triplePath); return result; }
@Override public void visit(ElementPathBlock el) { ElementPathBlock newBlock = new ElementPathBlock(); Iterator<TriplePath> tIter = el.patternElts(); while (tIter.hasNext()) { newBlock.addTriplePath(rewrite(tIter.next())); } push(newBlock); }
@Override public void visit(ElementPathBlock el) { ElementPathBlock newBlock = new ElementPathBlock(); Iterator<TriplePath> tIter = el.patternElts(); while (tIter.hasNext()) { newBlock.addTriplePath(rewrite(tIter.next())); } push(newBlock); }
@Override public Element transform(ElementPathBlock el) { ElementPathBlock epb = new ElementPathBlock() ; boolean changed = false ; for (TriplePath p : el.getPattern()) { TriplePath p2 = transform(p) ; changed = changed || p != p2 ; epb.addTriplePath(p2) ; } if ( changed ) return epb ; return el ; }
@Override public Element transform(ElementPathBlock el) { ElementPathBlock epb = new ElementPathBlock() ; boolean changed = false ; for (TriplePath p : el.getPattern()) { TriplePath p2 = transform(p) ; changed = changed || p != p2 ; epb.addTriplePath(p2) ; } if ( changed ) return epb ; return el ; }
public static BinaryRelation from(org.apache.jena.sparql.path.Path path) { TriplePath tp = new TriplePath(Vars.s, path, Vars.o); ElementPathBlock e = new ElementPathBlock(); e.addTriplePath(tp); BinaryRelation result = new BinaryRelationImpl(e, Vars.s, Vars.o); return result; }
@Override public void visit(OpPath opPath) { ElementPathBlock epb = new ElementPathBlock() ; epb.addTriplePath(opPath.getTriplePath()) ; ElementGroup g = currentGroup() ; g.addElement(epb) ; }