Main { {{ public static void help1(ClassGraph cg, XPath m, String strat, String comment, Visitor vis){ Integer i1 = (Integer) cg.traverse(m, strat, vis); System.out.println(i1.intValue() + comment); System.out.println(); } public static void help2(ClassGraph cg, XPath m, String strat, String comment) { List v; v = cg.gather(m, strat); System.out.println(v.size() + comment); } public static void main(String args[]) throws Exception { XPath m = XPath.parse(System.in); // m.display(); ClassGraph cgfull = new ClassGraph(true, false); ClassGraph cg = new ClassGraph(cgfull, "from XPath bypassing -> *,tail,* to *"); Visitor countingVis = new CountingVisitor(); help1(cg, m, "from XPath via BinaryCompound to Disjunction", " disjunction in binary ", countingVis); help1(cg, m, "from XPath to Disjunction", " disjunctions ", countingVis); // Integer i2 = (Integer) cg.traverse(m, // "from XPath to Disjunction", // countingVis); // System.out.println(i2.intValue() + " disjunctions "); // System.out.println(); help2(cg, m, "from XPath via UnaryCompound to Disjunction", " list length disjunction in unary "); List v; v = cg.gather( m, "from XPath via BinaryCompound to Chi"); System.out.println(v.size() + " list length Chi in binary "); v = cg.gather( m, "from XPath bypassing BinaryCompound to UnaryCompound"); System.out.println(v.size() + " list length Unary bypassing Binary"); System.out.println("done"); } }} } CountingVisitor { {{ public void start() {c = 0; } // public void before(UnaryCompound host){ // System.out.println(host + " UnaryCompound visited"); // } public void before(Disjunction host){ // System.out.println(c + " Disjunction value of c"); c++; } public Object getReturnValue() { return new Integer(c);} }} } XPath { void display() to * (DisplayVisitor); }