Main { public static void main(String args[]) throws Exception {{ Examples c = Examples.parse(System.in); ClassGraph cg = new ClassGraph(true,false); cg = new ClassGraph(cg, "from Examples bypassing -> *,tail,* to *"); Set dns = c.getDefinedNames(cg); Iterator it; System.out.println(" defined"); it = dns.iterator(); while (it.hasNext()) { String el = (String) it.next(); System.out.println(" defined id " + el); } System.out.println(" undefined"); Set udns = c.getUndefinedNames(cg); it = udns.iterator(); while (it.hasNext()) { String el = (String) it.next(); System.out.println(" undefined id " + el); } c.xyz(cg); TraversalGraph tg1; tg1 = new TraversalGraph( "from Collaboration to Java_MethodBody", cg); System.out.println(" TraversalGraph from Collaboration to Java_MethodBody "); System.out.println(tg1); System.out.println("========"); tg1 = new TraversalGraph( "from Collaboration bypassing QualifiedClassName to ClassName", cg); System.out.println(" TraversalGraph from Collaboration bypassing QualifiedClassName to ClassName "); System.out.println(tg1); System.out.println("========"); System.out.println("done"); System.out.println("done"); }} } Examples { {{ public Set getDefinedNames(ClassGraph cg) { final Set def = new HashSet(); List defs = cg.asList(this, "from Examples to Collaboration"); Iterator it = defs.iterator(); while (it.hasNext()) { Collaboration el = (Collaboration) it.next(); String cname = el.get_name().get_ident().toString(); def.add(cname); } return def; } public Set getUndefinedNames(ClassGraph cg) { final Set def = getDefinedNames(cg); final Set undef = new HashSet(); List used = cg.asList(this, "from Examples to QualifiedClassName"); Iterator it = used.iterator(); while (it.hasNext()) { QualifiedClassName el = (QualifiedClassName) it.next(); String cname = el.get_collname().get_ident().toString(); if (!def.contains(cname)) undef.add(cname); } return undef; } public void xyz(ClassGraph cg){ cg.traverse(this,"from Examples to Collaboration", new Visitor(){ int x; public void start(){x=0;} void before(Collaboration c){ x++; System.out.println("Collaboration " + c.get_name().get_ident() + " xyz " + x); } void after(Collaboration c){ x--; } }); } }} }