@Override public void visit(P_Link pathNode) { output(pathNode.getNode()) ; }
@Override public Path transform(P_ReverseLink path, Node node) { Path result = new P_Link(node); return result; }
/** * 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); }
public static Path pathLink(Node property) { return new P_Link(property) ; }
/** * 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); }
/** 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_ReverseLink path) { result = new P_Link(path.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 ; }
public static P_Path0 createStep(Node predicate, boolean isFwd) { P_Path0 result = isFwd ? new P_Link(predicate) : new P_ReverseLink(predicate); return result; }
@Override public void visit(P_Link pathNode) { output(pathNode.getNode()) ; }
@Override public Path make(ItemList list) { BuilderLib.checkLength(2, 2, list, "path link: wanted 1 argument") ; return new P_Link(list.get(1).getNode()) ; } };
@Override public void visit(P_Link path) { result = new P_ReverseLink(path.getNode()); }
@Override public Path transform(P_NegPropSet path, List<Node> fwdNodes, List<Node> bwdNodes) { P_NegPropSet result = new P_NegPropSet(); for(Node node : fwdNodes) { result.add(new P_ReverseLink(node)); } for(Node node : bwdNodes) { result.add(new P_Link(node)); } return result; }
@Override public void visit(P_Link path) { rsb.nav(path.getNode(), reverse); }
public static P_NegPropSet createNegPropSet(List<Node> fwdNodes, List<Node> bwdNodes) { P_NegPropSet result = new P_NegPropSet(); for(Node node : fwdNodes) { result.add(new P_Link(node)); } for(Node node : bwdNodes) { result.add(new P_ReverseLink(node)); } return result; }
@Override public void visit(P_Link path) { Node newNode = applyNodeTransform(path.getNode()); Path newPath = pathTransform.transform(path, newNode); stack.push(newPath); }
result = new P_Link(NodeFactory.createURI(uri + localName));