/** Return as a triple when the path is a simple, 1-link, else return null */ public Triple asTriple() { if ( triple != null ) return triple ; if ( path instanceof P_Link ) triple = new Triple(subject, ((P_Link)path).getNode(), object) ; return triple ; }
@Override public void visit(P_Link pathNode) { output(pathNode.getNode()) ; }
public TriplePath(Node s, Path path, Node o) { this.subject = s ; this.object = o ; if ( path instanceof P_Link ) { this.predicate = ((P_Link)path).getNode() ; triple = new Triple(subject, this.predicate , o) ; } else this.predicate = null ; this.path = path ; }
@Override public void visit(P_Link pathNode) { output(pathNode.getNode()) ; }
@Override public Path transform(P_Link path, Node node) { Path result = path.getNode() == node ? path : new P_Link(node) ; return result; }
@Override public void visit(P_Link path) { result = new P_ReverseLink(path.getNode()); }
@Override public void visit(P_Link path) { rsb.nav(path.getNode(), reverse); }
@Override public void visit(P_Link path) { Node newNode = applyNodeTransform(path.getNode()); Path newPath = pathTransform.transform(path, newNode); stack.push(newPath); }
@Override public void visit(P_Link pathNode) { Iterator<Node> nodes = engine.doOne(node, pathNode.getNode()) ; fill(nodes) ; }
@Override public void visit(P_Link pathNode) { Op op = new OpTriple(new Triple(subject, pathNode.getNode(), object)) ; result = op ; }
@Override public void visit(P_Link pathNode) { push(new P_Link(changeNode(pathNode.getNode()))); }
@Override public void visit(P_Link pathNode) { push(new P_Link(changeNode(pathNode.getNode()))); }
/** * Constructs a PathEvaluator for an arbitrary SPARQL path (except single forward properties). * @param path the path * @param shapesModel the shapes Model */ public PathEvaluator(Path path, Model shapesModel) { this.jenaPath = path; isInverse = jenaPath instanceof P_Inverse && ((P_Inverse)jenaPath).getSubPath() instanceof P_Link; if(isInverse) { P_Link link = (P_Link) ((P_Inverse)jenaPath).getSubPath(); predicate = shapesModel.getProperty(link.getNode().getURI()); } }
if ( ! isPropertyFunction(link.getNode(), execCxt.getContext()) ) { Iterator<Triple> sIter = graph.find(null, link.getNode(), null) ; return Iter.iter(sIter).distinctAdjacent().map(Triple::getSubject).distinct() ; if ( ! isPropertyFunction(link.getNode(), execCxt.getContext()) ) { Iterator<Triple> sIter = graph.find(null, link.getNode(), null) ; return Iter.iter(sIter).distinctAdjacent().map(Triple::getObject).distinct() ;
if (p instanceof P_Link) return ((P_Link)p).getNode();
if (p instanceof P_Link) return ((P_Link)p).getNode();
/** * Attempts to parse a given string into a Jena Path. * Throws an Exception if the string cannot be parsed. * @param string the string to parse * @param model the Model to operate on (for prefixes) * @return a Path or a Resource if this is a URI */ public static Object getJenaPath(String string, Model model) throws QueryParseException { Query query = ARQFactory.get().createQuery(model, "ASK { ?a \n" + string + "\n ?b }"); Element element = query.getQueryPattern(); if(element instanceof ElementGroup) { Element e = ((ElementGroup)element).getElements().get(0); if(e instanceof ElementPathBlock) { Path path = ((ElementPathBlock) e).getPattern().get(0).getPath(); if(path instanceof P_Link && ((P_Link)path).isForward()) { return model.asRDFNode(((P_Link)path).getNode()); } else { return path; } } else if(e instanceof ElementTriplesBlock) { return model.asRDFNode(((ElementTriplesBlock) e).getPattern().get(0).getPredicate()); } } throw new QueryParseException("Not a SPARQL 1.1 Path expression", 2, 1); }
Node node = ((P_Link) path).getNode(); if (node.isURI()) { return model.createResource(node.getURI());
/** * Attempts to parse a given string into a Jena Path. * Throws an Exception if the string cannot be parsed. * @param string the string to parse * @param model the Model to operate on (for prefixes) * @return a Path or a Resource if this is a URI */ public static Object getJenaPath(String string, Model model) throws QueryParseException { Query query = ARQFactory.get().createQuery(model, "ASK { ?a \n" + string + "\n ?b }"); Element element = query.getQueryPattern(); if(element instanceof ElementGroup) { Element e = ((ElementGroup)element).getElements().get(0); if(e instanceof ElementPathBlock) { Path path = ((ElementPathBlock) e).getPattern().get(0).getPath(); if(path instanceof P_Link && ((P_Link)path).isForward()) { return model.asRDFNode(((P_Link)path).getNode()); } else { return path; } } else if(e instanceof ElementTriplesBlock) { return model.asRDFNode(((ElementTriplesBlock) e).getPattern().get(0).getPredicate()); } } throw new QueryParseException("Not a SPARQL 1.1 Path expression", 2, 1); }
Node node = ((P_Link) path).getNode(); if (node.isURI()) { return model.createResource(node.getURI());