Adjacency { (@ protected Adjacency myparent = null; protected Set parents = new HashSet(); public void set_myparent (Adjacency a) { myparent = a; } public Adjacency get_myparent() { return myparent; } public void add_parents(Ident i) { parents.add(i); } public Set get_parents() { return parents; } @) } PrintAdjVisitor{ (@ void before (Adjacency host) { Adjacency p = host.get_myparent(); if (p!=null) System.out.println(p.get_source().get_vertex_name()); } @) } CheckCycleVisitor{ (@ boolean pass = true; Set aSet = new HashSet(); Set cycleSet = new HashSet(); void before (Adjacency host) { if (!cycleSet.contains(host)) { Adjacency adjTemp = host.get_myparent(); //Assuming there is a single inheritance boolean cycle = false; while (adjTemp != null) { if (adjTemp == host) { cycle = true; break; } else if (aSet.contains(adjTemp)) break; else { aSet.add(adjTemp); adjTemp = adjTemp.get_myparent(); } } if (cycle) { System.out.print("*** Error *** Cyclic inheritance from Class "+host.get_source().get_vertex_name()); Adjacency temp_parent = host; do { temp_parent = temp_parent.get_myparent(); cycleSet.add(temp_parent); System.out.print(" to Class "+temp_parent.get_source().get_vertex_name()); } while (temp_parent != host); System.out.println(); pass = false; } aSet.clear(); } } public boolean isPass() { return pass; } @) } SetParentVisitor { (@ protected TraversalGraph tg = new TraversalGraph("from Cd_graph bypassing {->*,myparent,*} to Adjacency",Main.cg1); protected List adjList = Main.cg1.gather(Main.m, "from Cd_graph to Adjacency"); void before (Adjacency host) { List aList = Main.cg1.gather(host, "from Adjacency through Term_Bar_list to Vertex"); Ident host_i= host.get_source().get_vertex_name(); Iterator iList = aList.iterator(); while (iList.hasNext()) { Ident i = ((Vertex)iList.next()).get_vertex_name(); Iterator iadjList = adjList.iterator(); while (iadjList.hasNext()) { Adjacency a = (Adjacency) iadjList.next(); if (i.equals(a.get_source().get_vertex_name())) { a.set_myparent(host); a.add_parents(host.get_source().get_vertex_name()); } } } } @) }