Schcmp{ traversal printClass(DisplayVisitor dV) { to *; } traversal toClassDef(ClistVisitor cV) {to ClassDef;} traversal toClassnames(ClassNameVisitor cV) {to Classname;} void print_temp() (@ PrintWriter w = new PrintWriter(System.out, true); this.printClass(new DisplayVisitor(w)); w.flush(); @) void compare(Schcmp b) (@ ClistVisitor cVA = new ClistVisitor(); ClistVisitor cVB = new ClistVisitor(); this.toClassDef(cVA); b.toClassDef(cVB); ClassDef_List classlistA = cVA.get_clist(); ClassDef_List classlistB = cVB.get_clist(); System.out.println("\n"); ClassNameVisitor cNVA = new ClassNameVisitor(classlistB,false,true); this.toClassnames(cNVA); if(cNVA.get_same()) System.out.println("\tNo Differences"); @) } ClistVisitor{ init (@ clist=new ClassDef_List(null); @) before ClassDef (@ if(clist.isEmpty()) clist.push(host); else clist.addElement(host); //System.out.println("The classname is "+ host.get_classname().get_s_classname()); @) } ClassNameVisitor{ init (@ inlist=false; same=true; @) before Classname (@ java.util.Enumeration cl=classlist.elements(); while(cl.hasMoreElements()){ ClassDef classdef= (ClassDef) cl.nextElement(); //System.out.println("ClassDef List B: "+ classdef.get_classname().get_s_classname()); //System.out.println("Host :"+ host.get_s_classname()); if(classdef.get_classname().get_s_classname().equals(host.get_s_classname())){ inlist=true; } } if(!inlist){ System.out.println("\t"+host.get_s_classname()); same=false; } @) after ClassDef (@ inlist=false; @) } Main { (@ public static void main(String[] argv) throws Exception { try { // Check arg list //if (argv.length != 2 ) schcmp.PrintHelp(); // Check input files File schema1 = new File(argv[0]); if (!schema1.exists()) { System.err.println("Could not find "+argv[0]); throw new FileNotFoundException(); } File schema2 = new File(argv[1]); if (!schema2.exists()) { System.err.println("Could not find "+argv[1]); throw new FileNotFoundException(); } Schcmp schemaA = Schcmp.parse(new FileInputStream(schema1)); Schcmp schemaB = Schcmp.parse(new FileInputStream(schema2)); //printout the Schema of both A and B //schemaA.print_temp(); //schemaB.print_temp(); System.out.print("\nThe classes unique to "+argv[0]+":"); schemaA.compare(schemaB); System.out.print("\nThe classes unique to "+argv[1]+":"); schemaB.compare(schemaA); } catch (ParseError e) { System.err.println("Failed to parse file."); e.printStackTrace(); System.exit(1); } catch (FileNotFoundException e) { System.err.println("\nPlease check and see if the file name exists. "); System.exit(1); } } @) }