public RuleSystem toRules(TriplePath tp, boolean rightRecursion, String triplePredicateName, String negatedPropertySetPredName) { String predPrefix = "P"; Set<String> predNames = HashSetFactory.make(); predNames.add(triplePredicateName); predNames.add(negatedPropertySetPredName); int startSuffix = OCUtils.nextAvailableSuffixVariable(predNames, predPrefix)+1; NewVariableGenerator predgen = new NewVariableGenerator(predPrefix, startSuffix); PathToRules visitor = new PathToRules(predgen, triplePredicateName, negatedPropertySetPredName, rightRecursion);; tp.getPath().visit(visitor); return visitor.getResult(); }
public PathBlock reduce(TriplePath triplePath) { PathBlock x = new PathBlock() ; reduce(x, varAlloc, triplePath.getSubject(), triplePath.getPath(), triplePath.getObject()) ; return x ; }
public PathBlock reduce(TriplePath triplePath) { PathBlock x = new PathBlock() ; reduce(x, varAlloc, triplePath.getSubject(), triplePath.getPath(), triplePath.getObject()) ; return x ; }
@Override public Op transform(OpPath opPath) { TriplePath tp = opPath.getTriplePath() ; Op op = transformPath(opPath, tp.getSubject(), tp.getPath(), tp.getObject() ) ; // And combine adjacent triple patterns. return op ; }
void reduce(PathBlock x, PathBlock pathBlock, VarAlloc varAlloc ) { for ( TriplePath tp : pathBlock ) { if ( tp.isTriple() ) { x.add(tp) ; continue ; } reduce(x, varAlloc, tp.getSubject(), tp.getPath(), tp.getObject()) ; } }
void reduce(PathBlock x, PathBlock pathBlock, VarAlloc varAlloc ) { for ( TriplePath tp : pathBlock ) { if ( tp.isTriple() ) { x.add(tp) ; continue ; } reduce(x, varAlloc, tp.getSubject(), tp.getPath(), tp.getObject()) ; } }
public static boolean triplePathIso(TriplePath tp1, TriplePath tp2, NodeIsomorphismMap isoMap) { if ( tp1.isTriple() ^ tp2.isTriple() ) return false ; if ( tp1.isTriple() ) return Utils.tripleIso(tp1.asTriple(), tp2.asTriple(), isoMap) ; else return Utils.nodeIso(tp1.getSubject(), tp2.getSubject(), isoMap) && Utils.nodeIso(tp1.getObject(), tp2.getObject(), isoMap) && tp1.getPath().equalTo(tp2.getPath(), isoMap) ; }
public static boolean triplePathIso(TriplePath tp1, TriplePath tp2, NodeIsomorphismMap isoMap) { if ( tp1.isTriple() ^ tp2.isTriple() ) return false ; if ( tp1.isTriple() ) return Iso.tripleIso(tp1.asTriple(), tp2.asTriple(), isoMap) ; else return Iso.nodeIso(tp1.getSubject(), tp2.getSubject(), isoMap) && Iso.nodeIso(tp1.getObject(), tp2.getObject(), isoMap) && tp1.getPath().equalTo(tp2.getPath(), isoMap) ; }
public static void outputPlain(IndentedWriter out, TriplePath tp, SerializationContext naming) { boolean oneLiner = oneLiner(tp.getPath()) ; if ( oneLiner ) { WriterNode.output(out, tp.getSubject(), naming) ; out.print(" ") ; WriterPath.output(out, tp.getPath(), naming) ; out.print(" ") ; WriterNode.output(out, tp.getObject(), naming) ; } else { nl(out, false); WriterNode.output(out, tp.getSubject(), naming) ; nl(out); WriterPath.output(out, tp.getPath(), naming) ; nl(out); WriterNode.output(out, tp.getObject(), naming) ; } }
public static void outputPlain(IndentedWriter out, TriplePath tp, SerializationContext naming) { boolean oneLiner = oneLiner(tp.getPath()) ; if ( oneLiner ) { WriterNode.output(out, tp.getSubject(), naming) ; out.print(" ") ; WriterPath.output(out, tp.getPath(), naming) ; out.print(" ") ; WriterNode.output(out, tp.getObject(), naming) ; } else { nl(out, false); WriterNode.output(out, tp.getSubject(), naming) ; nl(out); WriterPath.output(out, tp.getPath(), naming) ; nl(out); WriterNode.output(out, tp.getObject(), naming) ; } }
public static TriplePath substitute(TriplePath triplePath, Binding binding) { if ( triplePath.isTriple() ) return new TriplePath(Substitute.substitute(triplePath.asTriple(), binding)) ; Node s = triplePath.getSubject() ; Node o = triplePath.getObject() ; Node s1 = substitute(s, binding) ; Node o1 = substitute(o, binding) ; TriplePath tp = triplePath ; if ( s1 != s || o1 != o ) tp = new TriplePath(s1, triplePath.getPath(), o1) ; return tp ; }
public static TriplePath substitute(TriplePath triplePath, Binding binding) { if ( triplePath.isTriple() ) return new TriplePath(Substitute.substitute(triplePath.asTriple(), binding)) ; Node s = triplePath.getSubject() ; Node o = triplePath.getObject() ; Node s1 = substitute(s, binding) ; Node o1 = substitute(o, binding) ; TriplePath tp = triplePath ; if ( s1 != s || o1 != o ) tp = new TriplePath(s1, triplePath.getPath(), o1) ; return tp ; }
public static QueryIterator execTriplePath(Binding binding, TriplePath triplePath, ExecutionContext execCxt) { if ( triplePath.isTriple() ) { // Fake it. This happens only for API constructed situations. Path path = new P_Link(triplePath.getPredicate()) ; triplePath = new TriplePath(triplePath.getSubject(), path, triplePath.getObject()) ; } return execTriplePath(binding, triplePath.getSubject(), triplePath.getPath(), triplePath.getObject(), execCxt) ; }
public static QueryIterator execTriplePath(Binding binding, TriplePath triplePath, ExecutionContext execCxt) { if ( triplePath.isTriple() ) { // Fake it. This happens only for API constructed situations. Path path = new P_Link(triplePath.getPredicate()) ; triplePath = new TriplePath(triplePath.getSubject(), path, triplePath.getObject()) ; } return execTriplePath(binding, triplePath.getSubject(), triplePath.getPath(), triplePath.getObject(), execCxt) ; }
public TriplePath copySubstitute(TriplePath triple) { Node newSubj = replace(triple.getSubject()); Node newObj = replace(triple.getObject()); Path path = triple.getPath(); TriplePath newTriple; if (path!=null) { newTriple = new TriplePath(newSubj, path, newObj); } else { Node pred = replace(triple.getPredicate()); assert pred!=null : triple; //assert pred.isURI() : "predicate must be an IRI: "+ triple; newTriple = new TriplePath(new Triple(newSubj, pred, newObj)); } return newTriple; } public Triple copySubstitute(Triple triple) {
@Override public Op transform(OpPath opPath) { TriplePath tp = opPath.getTriplePath() ; Node s = tp.getSubject() ; Node s1 = transform.convert(s) ; Node o = tp.getObject() ; Node o1 = transform.convert(o) ; if ( s1 == s || o1 == o ) // No change. return opPath ; Path path = tp.getPath() ; TriplePath tp2 ; if ( path != null ) tp2 = new TriplePath(s1, path, o1) ; else { Triple t = new Triple(s1, tp.getPredicate(), o1) ; tp2 = new TriplePath(t) ; } return new OpPath(tp2) ; }
public Element transform(TriplePath tp,boolean bestEffort, NewVariableGenerator vargen, boolean[] resultHasPropertyPaths) { Triple t = tp.asTriple(); if (t!=null) { // this is a simple triple ElementTriplesBlock ret =new ElementTriplesBlock(); ret.addTriple(t); return ret; } assert !tp.isTriple(); assert tp.getPredicate()==null: tp; JenaPathRewrite pr = new JenaPathRewrite(tp.getSubject(), tp.getObject(), bestEffort, vargen); tp.getPath().visit(pr); if (resultHasPropertyPaths!=null) { resultHasPropertyPaths[0] = pr.resultWithPropertyPaths(); } return pr.getResult(); }
@Override public Op transform(OpPath opPath) { TriplePath tp = opPath.getTriplePath() ; Node s = tp.getSubject() ; Node s1 = transform.convert(s) ; Node o = tp.getObject() ; Node o1 = transform.convert(o) ; if ( s1 == s && o1 == o ) // No change. return super.transform(opPath) ; Path path = tp.getPath() ; TriplePath tp2 ; if ( path != null ) tp2 = new TriplePath(s1, path, o1) ; else { Triple t = new Triple(s1, tp.getPredicate(), o1) ; tp2 = new TriplePath(t) ; } return new OpPath(tp2) ; }
PathWriter.write(out, tp.getPath(), context.getPrologue()) ; out.print(" ") ; printObject(tp.getObject()) ;
PathWriter.write(out, tp.getPath(), context.getPrologue()) ; out.print(" ") ; printObject(tp.getObject()) ;