Java Code Examples for org.openrdf.query.algebra.QueryModelNode#getParentNode()
The following examples show how to use
org.openrdf.query.algebra.QueryModelNode#getParentNode() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RuleTransformationVisitor.java From neo4j-sparql-extension with GNU General Public License v3.0 | 6 votes |
/** * Returns the rules that may be applicable for a given node. * * @param node a node * @return rules that may be applicable to the node */ private ArrayList<Rule> getRules(QueryModelNode node) { // check if there is an entry in the map if (applied.containsKey(node)) { return applied.get(node); } else { // if there is no entry in the map, // traverse branch up until root to find a reduced rule set QueryModelNode parent = node.getParentNode(); while (parent != null) { if (applied.containsKey(parent)) { return applied.get(parent); } else { parent = parent.getParentNode(); } } // if there are no reduced rule sets return the full set return rules; } }
Example 2
Source File: QueryModelNodeTree.java From neo4j-sparql-extension with GNU General Public License v3.0 | 5 votes |
/** * Returns the root of a node in a query model tree. * * @param node the node to traverse up from * @return the root of the tree */ public static QueryModelNode getRoot(QueryModelNode node) { QueryModelNode parent; parent = node; while(parent.getParentNode() != null) { parent = parent.getParentNode(); } return parent; }
Example 3
Source File: QueryModelNodeTree.java From neo4j-sparql-extension with GNU General Public License v3.0 | 5 votes |
/** * Returns the distance to the root for a node in a query model tree. * * @param node the node to traverse up from * @return the distance to the root node */ public static int getRootDistance(QueryModelNode node) { int i = 0; QueryModelNode parent; parent = node; while(parent.getParentNode() != null) { parent = parent.getParentNode(); i++; } return i; }
Example 4
Source File: ConsistencyVisitor.java From neo4j-sparql-extension with GNU General Public License v3.0 | 5 votes |
private void checkParentChild(QueryModelNode node) { QueryModelNode parent = node.getParentNode(); SeenVisitor seen = new SeenVisitor(); if (parent != null) { parent.visitChildren(seen); if (!seen.getSeen().contains(node)) { throw new IllegalStateException("Node is not a child node! " + node); } } }