All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jspringbot.keyword.expression.VariableNodeCapture Maven / Gradle / Ivy

The newest version!
package org.jspringbot.keyword.expression;

import de.odysseus.el.tree.Node;
import de.odysseus.el.tree.impl.ast.AstIdentifier;

import java.util.HashSet;
import java.util.Set;
import java.util.Stack;

public class VariableNodeCapture {

    private static void dump(Set capture, Node node, Stack predecessors) {
        if(AstIdentifier.class.isInstance(node)) {
            capture.add(node.toString());
        }

        predecessors.push(node);
        for (int i = 0; i < node.getCardinality(); i++) {
            dump(capture, node.getChild(i), predecessors);
        }
        predecessors.pop();
    }

    public static Set capture(Node node) {
        Set captured = new HashSet();
        dump(captured, node, new Stack());

        return captured;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy