public boolean aggregatesProperty(String name) { checkArgument(status == Status.MATCH_FOUND); return currentInclude.aggregatesProperty(name); }
public void collectResults(ResultCollector results) { checkArgument(status == Status.MATCH_FOUND); //If result being collected as part of reaggregation then take path //from the stack otherwise its the current path String rootIncludePath = aggregateStack.isEmpty() ? currentPath : aggregateStack.get(0); currentInclude.collectResults(rootState.rootInclude, rootIncludePath, currentPath, matchedNodeState, results); }
public Collection<Matcher> nextSet() { checkArgument(status != Status.FAIL); if (status == Status.MATCH_FOUND){ Aggregate nextAgg = currentInclude.getAggregate(matchedNodeState); if (nextAgg != null){ int recursionLevel = aggregateStack.size() + 1; if (recursionLevel >= rootState.rootAggregate.reAggregationLimit){ return Collections.emptyList(); } List<Matcher> result = Lists.newArrayListWithCapacity(nextAgg.includes.size()); for (Include i : nextAgg.includes){ result.add(new Matcher(this, i, currentPath)); } return result; } return Collections.emptyList(); } return Collections.singleton(new Matcher(this, status, depth + 1, null, currentPath)); }
public boolean isPatternBased() { return currentInclude.isPattern(depth); }
public void collectResults(Include rootInclude, String rootIncludePath, String nodePath, NodeState nodeState, ResultCollector results) { collectResults(nodePath, nodeState, results); }
private boolean hasMore() { return depth < currentInclude.maxDepth() - 1; }
public Set<String> getRelativeNodeNames(){ //Can be computed lazily as required only for oak-run indexing for now Set<String> names = new HashSet<>(); for (IndexingRule r : definedRules) { for (Aggregate.Include i : r.aggregate.getIncludes()) { for (int d = 0; d < i.maxDepth(); d++) { if (!i.isPattern(d)) { names.add(i.getElementNameIfNotAPattern(d)); } } } } return names; }
public Matcher match(String name, NodeState nodeState) { boolean result = currentInclude.match(name, nodeState, depth); if (result){ if (hasMore()){ return new Matcher(this, Status.CONTINUE, depth, nodeState, path(name)); } else { return new Matcher(this, Status.MATCH_FOUND, depth, nodeState, path(name)); } } else { return new Matcher(this, Status.FAIL, depth); } }
@Override public boolean match(String name, NodeState nodeState, int depth) { //As per JR2 the primaryType is enforced on last element //last segment -> add to collector if node type matches if (depth == maxDepth() - 1 && primaryType != null && !matchingType(primaryType, nodeState)) { return false; } return super.match(name, nodeState, depth); }
public String getElementNameIfNotAPattern(int depth) { checkArgument(!isPattern(depth), "Element at %s is pattern instead of specific name in %s", depth, Arrays.toString(elements)); return elements[depth]; } }
/** * Returns the nodeName at current depth. This should only be called * if and only if #isPatternBased is false otherwise it would throw exception */ public String getNodeName() { return currentInclude.getElementNameIfNotAPattern(depth); }