A visitor class for visiting the node. This class also provides the default action (i.e. nop) for each of the child class of the Node. An actual visitor should extend this class and supply the visit method for the nodes that it cares.
| 2836 | * that it cares. |
| 2837 | */ |
| 2838 | public static class Visitor { |
| 2839 | |
| 2840 | /** |
| 2841 | * Constructs a new Visitor instance. |
| 2842 | */ |
| 2843 | public Visitor() { |
| 2844 | } |
| 2845 | |
| 2846 | /** |
| 2847 | * This method provides a place to put actions that are common to all nodes. It is a NO-OP by default. Override |
| 2848 | * this in the child visitor class if needed. |
| 2849 | * |
| 2850 | * @param n The node to visit |
| 2851 | * @throws JasperException if an error occurs while visiting the node |
| 2852 | */ |
| 2853 | protected void doVisit(Node n) throws JasperException { |
| 2854 | // NOOP by default |
| 2855 | } |
| 2856 | |
| 2857 | /** |
| 2858 | * Visit the body of a node, using the current visitor |
| 2859 | * |
| 2860 | * @param n The node to visit |
| 2861 | * @throws JasperException if an error occurs while visiting the body |
| 2862 | */ |
| 2863 | protected void visitBody(Node n) throws JasperException { |
| 2864 | if (n.getBody() != null) { |
| 2865 | n.getBody().visit(this); |
| 2866 | } |
| 2867 | } |
| 2868 | |
| 2869 | /** |
| 2870 | * Visits a root node. |
| 2871 | * |
| 2872 | * @param n The root node to visit |
| 2873 | * @throws JasperException if an error occurs while visiting the node |
| 2874 | */ |
| 2875 | public void visit(Root n) throws JasperException { |
| 2876 | doVisit(n); |
| 2877 | visitBody(n); |
| 2878 | } |
| 2879 | |
| 2880 | /** |
| 2881 | * Visits a JSP root node. |
| 2882 | * |
| 2883 | * @param n The JSP root node to visit |
| 2884 | * @throws JasperException if an error occurs while visiting the node |
| 2885 | */ |
| 2886 | public void visit(JspRoot n) throws JasperException { |
| 2887 | doVisit(n); |
| 2888 | visitBody(n); |
| 2889 | } |
| 2890 | |
| 2891 | /** |
| 2892 | * Visits a page directive node. |
| 2893 | * |
| 2894 | * @param n The page directive node to visit |
| 2895 | * @throws JasperException if an error occurs while visiting the node |
nothing calls this directly
no outgoing calls
no test coverage detected