private Operator findOperator(SpelNode node) { if (node instanceof Operator) { return (Operator) node; } int childCount = node.getChildCount(); for (int i = 0; i < childCount; i++) { Operator possible = findOperator(node.getChild(i)); if (possible != null) { return possible; } } return null; }
/** * Returns whether the {@link ExpressionNode} has a first child node that is not of the given type. * * @param type must not be {@literal null}. * @return */ public boolean hasfirstChildNotOfType(Class<?> type) { Assert.notNull(type, "Type must not be null!"); return hasChildren() && !node.getChild(0).getClass().equals(type); }
private static void printAST(PrintStream out, SpelNode t, String indent) { if (t != null) { StringBuilder sb = new StringBuilder(); sb.append(indent).append(t.getClass().getSimpleName()); sb.append(" value:").append(t.toStringAST()); sb.append(t.getChildCount() < 2 ? "" : " #children:" + t.getChildCount()); out.println(sb.toString()); for (int i = 0; i < t.getChildCount(); i++) { printAST(out, t.getChild(i), indent + " "); } } }
/** * Returns the child {@link ExpressionNode} with the given index. * * @param index must not be negative. * @return */ public ExpressionNode getChild(int index) { Assert.isTrue(index >= 0, "Index must be greater or equal to zero!"); return from(node.getChild(index), state); }
private List<String> findPermissions(SpelNode node) { List<String> list = new ArrayList<>(node.getChildCount()); if (startsWithIgnoreCase(node.toStringAST(), "hasRole") || startsWithIgnoreCase(node.toStringAST(), "hasAnyRole")) { for (int i = 0; i < node.getChildCount(); ++i) { list.add(remove(node.getChild(i).toStringAST(), '\'')); } } else { for (int i = 0; i < node.getChildCount(); ++i) { list.addAll(findPermissions(node.getChild(i))); } } LOGGER.debug("Found permissions: {}", list); return list; }
@Override public ExpressionNode next() { return from(node.getChild(index++)); }
/** * Returns the child {@link ExpressionNode} with the given index. * * @param index must not be negative. * @return */ public ExpressionNode getChild(int index) { Assert.isTrue(index >= 0, "Index must be greater or equal to zero!"); return from(node.getChild(index), state); }
/** * Returns whether the {@link ExpressionNode} has a first child node that is not of the given type. * * @param type must not be {@literal null}. * @return */ public boolean hasfirstChildNotOfType(Class<?> type) { Assert.notNull(type, "Type must not be null!"); return hasChildren() && !node.getChild(0).getClass().equals(type); }
@Override public ExpressionNode next() { return from(node.getChild(index++)); }
/** * {@inheritDoc} */ @Override public Iterable<Node> getAll(GraphDatabaseService database) { //In simple cases, we can fetch nodes using more efficient native syntax if(expressionNode.toStringAST().startsWith("hasLabel")) { String labelName = stripWrappingQuotes(expressionNode.getChild(0).toStringAST()); return () -> database.findNodes(Label.label(labelName)); } return new FilteringIterable<>(database.getAllNodes(), this::include); }