Cd_graph { {{ public void checkInheritanceCycle(final ClassGraph cg) { //everything in construct_ns of the Neighbors_wc objects is noise Strategy s = new Strategy("from Cd_graph bypassing {-> *,construct_ns, *} to Vertex"); cg.traverse(this, s, new Visitor() { public Vector keyList; //this is a list of keys we will be adding to the hash table public Map hashCheck; //keys are classes that inherit, values are a list classes the key inherits from public Vector getKeyList(String key) {return (Vector) hashCheck.get(String.valueOf(key));} public void start() {hashCheck = new HashMap();} public void before(Alternat_ns host) {keyList = new Vector();} public void before(Vertex host) { String vname = host.get_vertex_name().toString(); // Add this vertex name to the keyList if (keyList != null) keyList.add(vname); } public void after (Adjacency host) { // if the keyList is null, then there is no work to be done if (keyList != null) { Vector valueList = new Vector(); String sourceName = host.get_source().get_vertex_name().toString(); buildInheritsFromList(sourceName, sourceName, valueList); Iterator i = keyList.iterator(); while (i.hasNext()) { String checkingKey = (String) i.next(); if (valueList.contains(checkingKey)){ String message = new String(" *** ERROR: Cyclic inheritance from "); for (int list = valueList.size() - 1; list >= 0; list--) message = message + "class " + valueList.get(list) + " to "; message = message + "class " + checkingKey; System.out.println(message); System.out.print("...Fatal error, aborting."); System.exit(1); } // add the entry to the hash table hashCheck.put(checkingKey, valueList.clone()); } // end for loop valueList = null; keyList = null; } }// End after adjacency public void buildInheritsFromList(String sourceName, String stopAtVertex, Vector valueList){ //This is a recursive function that builds valueList. It takes a sourceName, and adds all classes it inherits from, //along with all classes that those classes inherit from valueList.add(sourceName); if (hashCheck.keySet().contains(sourceName)){ if (!getKeyList(sourceName).contains(stopAtVertex)){ String nextValue = (String) getKeyList(sourceName).get(0); buildInheritsFromList(nextValue, stopAtVertex, valueList); } } } }); } }} }