// gcdsave.beh // Last modified - feb 15 '98 // Author - Kedar Patankar // This converts graph object to string which is later stored on hard disk. //*******************Class UGraph ********************************/ UGraph { traversal saveGraph(SaveGraphVisitor sgv) { to *; } (@ /** Returns the string representation of the gcd(graph) object */ public String GetGraphString() { SaveGraphVisitor sgv= new SaveGraphVisitor(new String()); this.saveGraph(sgv); return sgv.get_graphString(); } @) //next part for extracting the marked subgraph in text form traversal saveMarkedGraph(SelectMarkedVisitor v) { to *; } /** Returns the string representation of those portions of the gcd(graph) object which are marked due to the strategy */ public String GetMarkedGraphString() (@ { SelectMarkedVisitor v = new SelectMarkedVisitor(false, false, false," "," "); this.saveMarkedGraph(v); return v.get_graphString(); } @) } //******************end UGraph************************************/ //*************************************************************************************/ //******************* VISITORS USED IN THE APPLCIATION ********************************/ //*************************************************************************************/ //******************SaveGraphVisitor************************************/ SaveGraphVisitor { before UGraph (@ graphString = graphString + "#Class #Dictionary #Graph\n"; @) before Package (@ graphString = graphString + "\npackage "; @) before { PackageName, Name } (@ graphString = graphString + host.toString();@) before Import (@ graphString = graphString + "import ";@) after Import (@ graphString = graphString + ";\n";@) before ImportAllClasses (@ graphString = graphString + ".*";@) /* before DirName (@ graphString = graphString + host.get_name() ; @)*/ /* before -> Nonempty_Package , next , Nonempty_Package (@ graphString = graphString + "." ; @)*/ after Package (@ graphString = graphString + ";\n" ; @) before JavaCode (@ graphString = graphString + "\n(@" + host.get_code() + "@" + ")\n"; @) before UVertex_List (@ graphString = graphString + "#Vertex #List\n"; @) before UConstVertex (@ graphString = graphString +"\n#ConstVertex "; @) before UBefore (@ graphString = graphString + "#Before \"" + host.get_syntax() + "\" "; @) before UAfter (@ graphString = graphString + "#After \"" + host.get_syntax() + "\" "; @) before UAltVertex (@ graphString = graphString + "\n#AltVertex "; @) before PublicIdentifier (@ graphString = graphString + "#public "; @) before FinalIdentifier (@ graphString = graphString + "#final "; @) before YaParse (@ graphString = graphString + "#parse "; @) before NopParse (@ graphString = graphString + "#noparse "; @) before UInterface (@ graphString = graphString + "\n#Interface "; @) before PublicModifier (@ graphString = graphString + "#public "; @) before UTermConstVertex (@ graphString = graphString +"\n#TermConstVertex "; @) before UTermInterface (@ graphString = graphString +"\n#TermInterface "; @) before UVertexName (@ graphString = graphString + host.get_name() +" "; @) before Coordinates (@ graphString = graphString + " { "; @) before X (@ graphString = graphString + host.get_x() +" "; @) before Y (@ graphString = graphString + host.get_y() +" "; @) after Coordinates (@ graphString = graphString + "} "; @) before IEdge_List (@ graphString = graphString + "#Incoming "; @) before UID (@ graphString = graphString + host.get_id() + " " ; @) before { -> Nonempty_IEdge_List,next,Nonempty_IEdge_List , -> Nonempty_OEdge_List,next,Nonempty_OEdge_List } (@ graphString = graphString + ", "; @) before OEdge_List (@ graphString = graphString + "#Outgoing "; @) before UEdge_List (@graphString = graphString + "\n#Edge #List\n"; @) before UAltEdge (@ graphString = graphString + "\n#AltEdge "; @) before UExtendEdge (@ graphString = graphString + "\n#ExtendEdge "; @) before UImplEdge (@ graphString = graphString + "\n#ImplEdge "; @) before UConstEdge (@ graphString = graphString + "\n#ConstEdge "; @) before UEdgeName (@ graphString = graphString + host.get_name() +" "; @) before Cardinality (@ graphString = graphString + "#Cardinality "; @) before Lower (@ graphString = graphString + host.get_l(); @) before Upper (@ graphString = graphString + "..\"" + host.get_u() + "\" "; @) after Cardinality (@ graphString = graphString + " "; @) before FinalMod (@ graphString = graphString + "#final"; @) before StaticMod (@ graphString = graphString + "#static"; @) before ReadOnlyMod (@ graphString = graphString + "#read-only"; @) before PrivateMod (@ graphString = graphString + "#private"; @) } SelectMarkedVisitor { (@ Hashtable vtable; Hashtable etable; @) before UGraph (@ host.idToVertexTable = new Hashtable(); host.idToEdgeTable = new Hashtable(); host.hashinit(host.idToVertexTable , host.idToEdgeTable); // System.out.println("in getCdString"); vtable = host.idToVertexTable ; etable = host.idToEdgeTable ; graphString = graphString + "#Class #Dictionary #Graph\n"; @) before Package (@ graphString = graphString + "\npackage "; @) before { PackageName, Name } (@ graphString = graphString + host.toString();@) before Import (@ graphString = graphString + "import ";@) after Import (@ graphString = graphString + ";\n";@) before ImportAllClasses (@ graphString = graphString + ".*";@) /* before DirName (@ graphString = graphString + host.get_name() ; @)*/ /* before -> Nonempty_Package , next , Nonempty_Package (@ graphString = graphString + "." ; @)*/ after Package (@ graphString = graphString + ";\n" ; @) before JavaCode (@ graphString = graphString + "\n(@" + host.get_code() + "@" + ")\n"; @) before UVertex_List (@ graphString = graphString + "#Vertex #List\n"; @) around UVertex(@ subtraversal.apply();@) around UConstVertex (@ if(host.isMarked()) { graphString = graphString +"\n#ConstVertex "; subtraversal.apply(); } @) around UBefore (@ graphString = graphString + "#Before \"" + host.get_syntax() + "\" "; subtraversal.apply();@) around UAfter (@ graphString = graphString + "#After \"" + host.get_syntax() + "\" "; subtraversal.apply();@) around UAltVertex (@ graphString = graphString + "\n#AltVertex "; subtraversal.apply();@) around PublicIdentifier (@ graphString = graphString + "#public "; subtraversal.apply();@) around FinalIdentifier (@ graphString = graphString + "#final "; subtraversal.apply();@) around YaParse (@ graphString = graphString + "#parse "; subtraversal.apply();@) around NopParse (@ graphString = graphString + "#noparse "; subtraversal.apply();@) around UInterface (@ graphString = graphString + "\n#Interface "; subtraversal.apply();@) around PublicModifier (@ graphString = graphString + "#public "; subtraversal.apply();@) around UTermConstVertex (@ graphString = graphString +"\n#TermConstVertex "; subtraversal.apply();@) around UTermInterface (@ graphString = graphString +"\n#TermInterface "; subtraversal.apply();@) around UVertexName (@ graphString = graphString + host.get_name() +" "; subtraversal.apply();@) around Coordinates (@ graphString = graphString + " { "; subtraversal.apply();@) around X (@ graphString = graphString + host.get_x() +" "; subtraversal.apply();@) around Y (@ graphString = graphString + host.get_y() +" "; subtraversal.apply();@) after Coordinates (@ graphString = graphString + "} "; @) before {IEdge_List , OEdge_List } (@ bflag = true; //in either I/OEdge_List cflag = false; //dont put a comma anyEdgeflag = false; //not a single edge yet ioeString = " "; @) after IEdge_List //graphString = graphString + "#Incoming "; (@ bflag = false; if(anyEdgeflag) { ioeString = "#Incoming " + ioeString; graphString = graphString + ioeString; } @) after OEdge_List (@ bflag = false; if(anyEdgeflag) { ioeString = "#Outgoing " + ioeString; graphString = graphString + ioeString; } @) around UID (@ if (!bflag) { graphString = graphString + host.get_id() + " " ; subtraversal.apply(); } else //in either I/OEdge_List if( ((UEdge)etable.get(host)).isMarked() ) { if(cflag) { ioeString = ioeString +" , "+ host.get_id() + " " ; } else { ioeString = ioeString + host.get_id() + " " ; } cflag = true; //put a comma from now on anyEdgeflag = true; //now atleast one edge in list subtraversal.apply(); } @) /* around { -> Nonempty_IEdge_List,next,Nonempty_IEdge_List , -> Nonempty_OEdge_List,next,Nonempty_OEdge_List } (@ graphString = graphString ; subtraversal.apply();@) */ around UEdge_List (@graphString = graphString + "\n#Edge #List\n"; subtraversal.apply();@) around UEdge(@ subtraversal.apply();@) around UAltEdge (@ graphString = graphString + "\n#AltEdge "; subtraversal.apply();@) around UExtendEdge (@ graphString = graphString + "\n#ExtendEdge "; subtraversal.apply();@) around UImplEdge (@ graphString = graphString + "\n#ImplEdge "; subtraversal.apply();@) around UConstEdge (@ if(host.isMarked()) { graphString = graphString + "\n#ConstEdge "; subtraversal.apply(); } @) around UEdgeName (@ graphString = graphString + host.get_name() +" "; subtraversal.apply();@) around Cardinality (@ graphString = graphString + "#Cardinality "; subtraversal.apply();@) around Lower (@ graphString = graphString + host.get_l(); subtraversal.apply();@) around Upper (@ graphString = graphString + "..\"" + host.get_u() + "\" "; subtraversal.apply();@) after Cardinality (@ graphString = graphString + " "; @) around FinalMod (@ graphString = graphString + "#final"; subtraversal.apply();@) around StaticMod (@ graphString = graphString + "#static"; subtraversal.apply();@) around ReadOnlyMod (@ graphString = graphString + "#read-only"; subtraversal.apply();@) around PrivateMod (@ graphString = graphString + "#private"; subtraversal.apply();@) } /* SelectMarkedVisitor { around {UVertex, UEdge} // around {UConstVertex, UAltVertex, UInterface, UTermConstVertex, UTermInterface, UConstEdge, UAltEdge, UExtendEdge, UImplEdge} (@ if(host.isMarked()) subtraversal.apply(); @) }*/ // gcdsave.beh // Last modified - Aug 27 '97 // Author - Binoy // This converts graph object to string which is later stored on hard disk. // uses generic PrintVisitor //*******************Class UGraph ********************************/ //UGraph //{ // (@ // public String GetGraphString() // { // StringWriter w = new StringWriter(); // this.universal_trv0(new PrintVisitor(new PrintWriter(w))); // return w.toString(); // } // @) //} // //******************end UGraph************************************/