@Override public void visit(final ElementPathBlock el) { for (Iterator<TriplePath> iterator = el.patternElts(); iterator.hasNext();) { TriplePath tp = iterator.next(); if (inOptionalClause) { optionalTriplePattern.add(tp.asTriple()); } else { if (tp.isTriple()) { triplePattern.add(tp.asTriple()); } } } }
@Override public void visit(ElementPathBlock el) { Iterator<TriplePath> triplePaths = el.patternElts(); while (triplePaths.hasNext()) { TriplePath tp = triplePaths.next(); if(tp.isTriple()) { Triple triple = tp.asTriple(); triplePatterns.add(triple); } } } });
@Override public void visit(ElementPathBlock el) { for (Iterator<TriplePath> iter = el.patternElts() ; iter.hasNext() ; ) { TriplePath tp = iter.next() ; // If it's triple-izable, then use the triple. if ( tp.isTriple() ) VarUtils.addVarsFromTriple(acc, tp.asTriple()) ; else VarUtils.addVarsFromTriplePath(acc, tp) ; } }
public static void collectQuads(ElementPathBlock element, Context context, List<Quad> result) { Node graphNode = context.getGraphNode(); for(TriplePath triplePath : element.getPattern().getList()) { Triple triple = triplePath.asTriple(); if(triple == null) { logger.warn("Omitted non-simple triple"); } Quad quad = new Quad(graphNode, triple); result.add(quad); } }
@Override public void visit(ElementPathBlock el) { Iterator<TriplePath> triplePaths = el.patternElts(); while (triplePaths.hasNext()) { TriplePath tp = triplePaths.next(); if(tp.isTriple()) { Triple triple = tp.asTriple(); Node subject = triple.getSubject(); if(subject.equals(source)) { outgoingTriples.add(triple); } } } } });
@Override public void visit(ElementPathBlock el) { // TODO Paths not handled yet List<TriplePath> triplePaths = el.getPattern().getList(); for(TriplePath triplePath : triplePaths) { Triple triple = triplePath.asTriple(); Quad quad = new Quad(defaultGraphName, triple); quads.add(quad); } //throw new RuntimeException("Not implemented"); }
public static void collectQuads(ElementPathBlock element, Context context, List<Quad> result) { Node graphNode = context.getGraphNode(); for(TriplePath triplePath : element.getPattern().getList()) { Triple triple = triplePath.asTriple(); if(triple == null) { logger.warn("Omitted non-simple triple"); } Quad quad = new Quad(graphNode, triple); result.add(quad); } }
@Override public void visit(ElementPathBlock el) { for (Iterator<TriplePath> iter = el.patternElts() ; iter.hasNext() ; ) { TriplePath tp = iter.next() ; // If it's triple-izable, then use the triple. if ( tp.isTriple() ) { VarUtils.addVarsFromTriple(vars, tp.asTriple()) ; } else { VarUtils.addVarsFromTriplePath(vars, tp) ; } } }
public static void collectQuads(ElementPathBlock element, Context context, List<Quad> result) { Node graphNode = context.getGraphNode(); for(TriplePath triplePath : element.getPattern().getList()) { Triple triple = triplePath.asTriple(); if(triple == null) { logger.warn("Omitted non-simple triple"); } Quad quad = new Quad(graphNode, triple); result.add(quad); } }
@Override public void visit(ElementPathBlock el) { for (Iterator<TriplePath> iter = el.patternElts() ; iter.hasNext() ; ) { TriplePath tp = iter.next() ; // If it's triple-izable, then use the triple. if ( tp.isTriple() ) { VarUtils.addVarsFromTriple(vars, tp.asTriple()) ; } else { VarUtils.addVarsFromTriplePath(vars, tp) ; } } }
@Override public int hashCode() { if ( hash == -1 ) { if ( isTriple() ) hash = asTriple().hashCode() ; else hash = (subject.hashCode()<<2) ^ path.hashCode() ^ (object.hashCode()<<1) ; } return hash ; }
@Override public boolean equals(Object other) { if ( this == other) return true ; if ( ! ( other instanceof TriplePath) ) return false ; TriplePath tp = (TriplePath)other ; // True if one is true and one is false if ( tp.isTriple() ^ this.isTriple() ) return false ; if ( isTriple() ) return asTriple().equals(tp.asTriple()) ; else return subject.equals(tp.subject) && object.equals(tp.object) && path.equals(tp.path) ; }
@Override public void visit(ElementPathBlock el) { Iterator<TriplePath> triplePaths = el.patternElts(); while (triplePaths.hasNext()) { TriplePath tp = triplePaths.next(); if(tp.isTriple()) { Triple triple = tp.asTriple(); Node subject = triple.getSubject(); if(subject.equals(source) && triple.getObject().isVariable()) { outgoingTriples.add(triple); } } } } });
protected void insert(TripleCollector target, ElementPathBlock source) { for ( TriplePath path : source.getPattern() ) { if ( path.isTriple() ) { target.addTriple(path.asTriple()) ; } else { target.addTriplePath(path) ; } } }
@Override public void visit(ElementPathBlock el) { for (Iterator<TriplePath> it = el.patternElts(); it.hasNext();) { Triple t = it.next().asTriple(); if (t.getSubject().isURI()) { resources.add(t.getSubject().getURI()); } if (t.getPredicate().isURI()) { resources.add(t.getPredicate().getURI()); } if (t.getObject().isURI()) { resources.add(t.getObject().getURI()); } } }
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) ; }
@Override public void visit(ElementPathBlock el) { for (final TriplePath pth : el.getPattern().getList()) { if ( ! pth.isTriple()) { throw new QueryParseException("Paths not permitted in data quad", -1, -1) ; } } iter = iter.andThen( WrappedIterator.create(el.getPattern().getList().iterator()) .mapWith( pth -> pth.asTriple() ) .mapWith( MAP )); }
@Override public void visit(ElementPathBlock el) { for (final TriplePath pth : el.getPattern().getList()) { if ( ! pth.isTriple()) { throw new QueryParseException("Paths not permitted in data quad", -1, -1) ; } } iter = iter.andThen( WrappedIterator.create(el.getPattern().getList().iterator()) .mapWith( pth -> pth.asTriple() ) .mapWith( MAP )); }
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; }
@Test public void bNodeSPARQL_Query_1() { String qs = "SELECT * { ?s ?p <_:ABC>}"; Query query = QueryFactory.create(qs); Element el = ((ElementGroup)query.getQueryPattern()).get(0); ElementPathBlock epb = (ElementPathBlock)el; TriplePath tp = epb.getPattern().get(0); Triple t = tp.asTriple(); assertEquals("ABC", t.getObject().getBlankNodeLabel()); }