// DSL for GME models language GME_model { lexicon { Reserved model | atom | fields | connections Id [a-zA-Z_][a-zA-Z0-9_]* Separator \; | \{ | \} | \, | \: | \-> ignore [\ \0x0A\0x0D\0x09]+ } attributes Vector *.inEnv, *.outEnv; Vector *.mas, *.in_ma, *.out_ma; Vector *.fields, *.in_fields, *.out_fields; Vector *.conn, *.in_con, *.out_con; //connections Entity *.ma; // ma - model_or_atom BufferedWriter START.file; rule Start { START ::= GME compute { START.outEnv=GME.outEnv; GME.inEnv=new Vector(); START.file = open("grammar.gme", START.outEnv, "\n"); }; GME ::= MODEL_OR_ATOM GME compute { GME[0].outEnv = GME[1].outEnv; GME[1].inEnv =put(GME[0].inEnv, MODEL_OR_ATOM.ma); } | MODEL_OR_ATOM compute { GME[0].outEnv =put(GME[0].inEnv, MODEL_OR_ATOM.ma); }; } rule MorA { MODEL_OR_ATOM ::= MODEL compute { MODEL_OR_ATOM.ma=MODEL.ma; } | ATOM compute { MODEL_OR_ATOM.ma=ATOM.ma; }; } rule Model { MODEL ::= model #Id \{ M_BODY \} compute { MODEL.ma=new Model(#Id.value(), M_BODY.mas, M_BODY.fields, M_BODY.conn); }; } rule Model_Body { M_BODY ::= MODELS FIELDS CONNECT compute { MODELS.in_ma = new Vector(); FIELDS.in_fields = new Vector(); CONNECT.in_con = new Vector(); M_BODY.mas = MODELS.out_ma; M_BODY.fields = FIELDS.out_fields; M_BODY.conn = CONNECT.out_con; }; } rule Models { MODELS ::= #Id \; MODELS compute { MODELS[0].out_ma = MODELS[1].out_ma; MODELS[1].in_ma = put(MODELS[0].in_ma, #Id.value()); } | epsilon compute { MODELS.out_ma=MODELS.in_ma; }; } rule Fields { FIELDS ::= fields OTHER_FIELDS \; compute { OTHER_FIELDS.in_fields = new Vector(); FIELDS.out_fields = OTHER_FIELDS.out_fields; }; } rule OtherFields { OTHER_FIELDS ::= #Id \, OTHER_FIELDS compute { OTHER_FIELDS[0].out_fields=OTHER_FIELDS[1].out_fields; OTHER_FIELDS[1].in_fields=put(OTHER_FIELDS[0].in_fields, #Id.value()); } | epsilon compute {OTHER_FIELDS.out_fields=OTHER_FIELDS.in_fields; }; } rule Connections { CONNECT ::= connections CONNECTIONS compute { CONNECT.out_con=CONNECTIONS.out_con; CONNECTIONS.in_con=CONNECT.in_con; } | epsilon compute { CONNECT.out_con=CONNECT.in_con; }; CONNECTIONS ::= #Id \: #Id \-> #Id \; CONNECTIONS compute { CONNECTIONS[0].out_con=CONNECTIONS[1].out_con; CONNECTIONS[1].in_con=put(CONNECTIONS[0].in_con, new Connection(#Id[0].value(), #Id[1].value(), #Id[2].value())); } | epsilon compute { CONNECTIONS.out_con=CONNECTIONS.in_con; }; } rule Atom { ATOM ::= atom #Id \{ FIELDS \} compute { FIELDS.in_fields = new Vector(); ATOM.ma = new Atom(#Id.value(), FIELDS.out_fields); }; } method M_Entity { abstract class Entity { abstract String getType(); abstract String getName(); } } method M_Atom { class Atom extends Entity { String name; Vector fields; Atom(String name, Vector fields) { this.name = name; this.fields = fields; } public String toString() { return "[ATOM: " + this.name + " " + fields.toString() + "]"; } public String getName(){ return this.name; } public String getType(){ return "Atom"; } public Vector getFields(){ return this.fields; } } // class } // method method M_Model { class Model extends Entity{ String name; Vector modelsORatoms; Vector fields; Vector connections; Model (String name, Vector modelsORatoms, Vector fields, Vector connections) { this.name = name; this.modelsORatoms = modelsORatoms; this.fields = fields; this.connections = connections; } public String toString(){ return "[MODEL: " + this.name + " " + modelsORatoms.toString() + " " + fields.toString() + " " + connections.toString() + "]"; } public String getName(){ return this.name; } public Vector getFields(){ return this.fields; } public String getType(){ return "Model"; } public Vector getmodelsORatoms(){ return this.modelsORatoms; } public Vector getConnections(){ return this.connections; } } } method Conn { class Connection { String name; String src; String dst; Connection (String name, String src, String dst) { this.name = name; this.src = src; this.dst = dst; } public String toString(){ return this.name + ":" + this.src + "->" + this.dst; } public String getName() { return this.name; } public String getSrc() { return this.src; } public String getDst() { return this.dst; } } } method M_insert { import java.util.*; Vector put(Vector alist, String name) { alist.add(name); return alist; } Vector put(Vector alist, Entity ma) { alist.add(ma); return alist; } Vector put(Vector alist, Connection con) { alist.add(con); return alist; } } // Lisa method method Conv2Gram { import java.io.*; import java.lang.*; import java.util.*; BufferedWriter open(String filename, Vector alist, String separator) { try { BufferedWriter outfile = new BufferedWriter (new FileWriter(filename)); BufferedWriter xmlfile = new BufferedWriter (new FileWriter("MetaModel.xml")); //output initial meta-model XML file constructs xmlfile.write(" \n"); xmlfile.write(" \n"); xmlfile.write(" \n "); xmlfile.write(" Inferred Meta-model\n "); xmlfile.write(" \n"); xmlfile.write(" Inferred Meta-model\n "); xmlfile.write(" \n"); xmlfile.write(" ParadigmSheet \n\n"); //data structures to process Models Map moa = new HashMap(); Vector moa2 = new Vector(); Vector moaNames = new Vector(); Map fields = new HashMap(); Vector fields2 = new Vector(); Vector cdy = new Vector(); //XML metamodel data structures : holds models/atoms/fields alongwith their corresponding IDs Map mModels = new HashMap(); Map mAtoms = new HashMap(); //data structures to process connections - cNames holds all connections names, indexed by Model name //cSrcs and cDsts are all possible sources and destinations, index by cNames Map cSrcs = new HashMap(); Map cDsts = new HashMap(); Map cNames = new HashMap(); Vector conNames = new Vector(); Vector src = new Vector(); Vector dst = new Vector(); //data structures to process Atoms Vector atomNames = new Vector(); //reset all data strutures cSrcs.clear(); cDsts.clear(); cNames.clear(); conNames.clear(); src.clear(); dst.clear(); moaNames.clear(); moa2.clear(); fields2.clear(); moa.clear(); atomNames.clear(); mModels.clear(); mAtoms.clear(); for (int i = 0; i < alist.size(); i++) { //main for loop Entity v = (Entity)alist.get(i); String t = v.getType(); //Case: Model if (t.equals("Model")) { Model w = (Model)v ; String name1 = w.getName(); Vector s1 = w.getFields(); Vector s2 = w.getmodelsORatoms(); Vector s3 = w.getConnections(); //process all connections for (int z = 0; z < s3.size(); z++) { Connection cc = (Connection)s3.get(z); String ccName = cc.getName(); String ccDst = cc.getDst(); String ccSrc = cc.getSrc(); // outfile.write("\n" + "Conn Name: " + ccName + " Src: " + ccSrc + " Dst: " + ccDst ); //if - connection Sources if (cSrcs.containsKey(ccName)) { Vector srcV = (Vector)cSrcs.get(ccName); srcV.add(ccSrc); cSrcs.put(ccName, srcV); } else { Vector srcV2 = new Vector(); srcV2.add(ccSrc); cSrcs.put(ccName, srcV2); } //else //if - destination Sources if (cDsts.containsKey(ccName)) { Vector dstV = (Vector)cDsts.get(ccName); dstV.add(ccDst); cDsts.put(ccName, dstV); } else { Vector dstV2 = new Vector(); dstV2.add(ccDst); cDsts.put(ccName, dstV2); } //add connection names for each model to the corresponding hashmap entry if (cNames.containsKey(name1)) { Vector cnV = (Vector)cNames.get(name1); if (cnV.indexOf(ccName) > -1) {} else { cnV.add(ccName); cNames.put(name1, cnV); } } else { Vector cnV2 = new Vector(); cnV2.add(ccName); cNames.put(name1, cnV2); } } //Connections - for //populate the vector containing subitems of a particular model moa2.clear(); for (int j = 0; j < s2.size(); j++) { moa2.add(s2.get(j)); } // for(int u = 0; u < moa2.size(); u++) { // outfile.write("\n" + "[ "+ moa2.get(u).toString() + "]" + "\n"); // } //Subitems: check if key already exists in the hashmap - if not, add the moa subitem vector - else,just append if (moa.containsKey(name1)) { Vector moa3 = (Vector)moa.get(name1); for (int k = 0; k < moa2.size(); k++) { moa3.add((String)moa2.get(k)); } moa.put(name1, moa3); } else { moaNames.add((String)name1); moa.put(name1, moa2.clone()); } //Fields: check if key already exists in the hashmap - if not, add the fields - else just append if (fields.containsKey(name1)) { Vector mfields = (Vector)fields.get(name1); for (int k = 0; k < s1.size(); k++) { if ( (mfields.indexOf(s1.get(k))) > -1 ) { } else { mfields.add(s1.get(k)); } fields.put(name1, mfields); } //for } else { fields.put(name1, s1.clone()); } } //Case: Atom else { Atom x = (Atom) v; String name2 = x.getName(); Vector ss1 = x.getFields(); if (atomNames.contains(name2)) { } else { atomNames.add(name2); } if ( fields.containsKey(name2) ) { Vector afields = (Vector)fields.get(name2); for (int k = 0; k < ss1.size(); k++) { if ( (afields.indexOf(ss1.get(k))) > -1 ) {} else { afields.add(ss1.get(k)); } fields.put(name2, afields); } //for } //if else { fields.put(name2, ss1.clone()); } } //else case Atom } //for - main /********************************************* Creating the Grammar file Use all the information about the GME models stored in the data structures to construct the grammar. Concurrently generate the meta-model xml file also *********************************************/ int ptctr = 0, cnctr = 0, srctr = 0, dtctr = 0, fdctr = 0, mactr = 0, fctr = 0; int ID = 0; //ID counter for XML file String aspectID = new String("id-0069-99999999"); //outfile.write("GME -> MODELS ATOMS \n\n"); outfile.write("GME Meta-Model Transformer Version 3.0 \n\n "); StringBuffer models = new StringBuffer("MODELS -> "); String mID = new String(); String aID = new String(); StringBuffer fID, connID, contID; //store all atom XML nodes for (int jx = 0; jx < atomNames.size(); jx++) { String instanceID2 = Integer.toString(ID); String itemID2 = new String ("id-0066-000" + instanceID2); String tempAtom = ((String)atomNames.get(jx)); mAtoms.put(tempAtom.toLowerCase(), itemID2); ID++; } //output all models for (int i = 0; i < moaNames.size(); i++) { String modelName = (String)moaNames.get(i); String instanceID = Integer.toString(ID); String itemID = new String ("id-0066-000" + instanceID); mModels.put(modelName.toLowerCase(), itemID); ID++; models.append(modelName.toUpperCase()); models.append(" MODELS |"); } models.append(" eps"); String models2 = models.toString(); //outfile.write(models2 + "\n"); String fnum = Integer.toString(fctr); String ptnum = Integer.toString(ptctr); String cnnum = Integer.toString(cnctr); String srcnum = Integer.toString(srctr); String dtnum = Integer.toString(dtctr); String fdnum = Integer.toString(fdctr); String manum = Integer.toString(mactr); //traverse model structure for (int l = 0; l < moaNames.size(); l++) { fnum = Integer.toString(fctr); manum = Integer.toString(mactr); ptnum = Integer.toString(ptctr); fdnum = Integer.toString(fdctr); cnnum = Integer.toString(cnctr); Vector xy = (Vector)moa.get(moaNames.get(l)); //all subitems for a particular model instances String moaNm = (String)moaNames.get(l); if ( mModels.containsKey(moaNm.toLowerCase()) ) { mID = (String)mModels.get(moaNm.toLowerCase()); /*mID = new StringBuffer("id-0066-000" + Integer.toString(ID)); String modelID = Integer.toString(ID);*/ xmlfile.write(" \n "); xmlfile.write(" " + moaNm + " \n "); xmlfile.write(" \n"); xmlfile.write(" false \n"); xmlfile.write(" \n"); xmlfile.write(" \n"); xmlfile.write(" false \n"); xmlfile.write(" \n"); xmlfile.write(" \n\n "); } ID++; //for each model, also create a HasApects node xmlfile.write(" \n "); xmlfile.write(" HasAspect \n "); xmlfile.write(" \n"); xmlfile.write(" \n"); xmlfile.write(" \n\n "); ID++; StringBuffer modelRule = new StringBuffer(moaNm.toUpperCase() + " " + "-> " + "<> " + moaNm.toLowerCase() + " { " + "PARTS" + ptnum + " }\n" ); StringBuffer ptsRule = new StringBuffer("PARTS" + ptnum + " ->" + " MODELATOM" + manum + " FIELDS" + fdnum + " CONNECTIONS" + cnnum + "\n"); //new code for subitem cardinality calculation cdy.clear(); for (int ui = 0; ui < alist.size(); ui++) { Entity vv = (Entity)alist.get(ui); String tt = vv.getType(); if (tt.equals("Model")) { Model ww = (Model)vv; String name2 = ww.getName(); if (name2.equals(moaNm)) { Vector ss2 = ww.getmodelsORatoms(); cdy.add(ss2); } } //if-outer } //for StringBuffer subitems = new StringBuffer(); Vector tester = new Vector(); // contain each subitem once only for (int m = 0; m < xy.size(); m++) { String item = ((String)xy.get(m)); String item2 = ((String)xy.get(m)).toUpperCase(); if (!(tester.contains(item))) { tester.add(item); subitems.append(item2); subitems.append("S"); subitems.append(" "); } } //for //for (int z = 0; z < tester.size(); z++ ) //{outfile.write(tester.get(z).toString()); outfile.write("\n"); } StringBuffer maRule = new StringBuffer("MODELATOM" + manum + " -> " + subitems.toString() + "\n"); outfile.write(modelRule.toString()); outfile.write(ptsRule.toString()); outfile.write(maRule.toString()); //iterate over tester items, and create rules int empty = 0, frequency = 0, counter = 1, infreq = 0, incounter = 0; StringBuffer item3 = new StringBuffer(); int sizee = tester.size(); //tester has each subitem only once for (int m2 = 0; m2 < tester.size(); m2++) { String item2 = (String)tester.get(m2); for (int m3 = 0; m3 < cdy.size(); m3++) { Vector items = (Vector)cdy.get(m3); for (int m4 = 0; m4 < items.size(); m4++) { String test = (String)items.get(m4); if (item2.equals(test)) { infreq++; incounter = 1; } }//innermost-for if (incounter == 0) {counter = 0;} if (infreq > 1) { frequency = infreq; } infreq = 0; incounter = 0; } // cdy - for if (counter == 0) { empty = 1; /*rule can be empty*/ } if (frequency == 0) { frequency = 1;} contID = new StringBuffer("id-0066-000" + Integer.toString(ID)); xmlfile.write(" \n "); xmlfile.write(" Containment \n "); String tempMOA = new String(); String temp = new String(); //outfile.write(item2); outfile.write("\n"); if (mModels.containsKey(item2.toLowerCase())) { tempMOA = ((String)mModels.get(item2.toLowerCase())); } else { tempMOA = ((String)mAtoms.get(item2.toLowerCase())); } //rule tests if ((frequency > 1) & (empty == 1)) { item3 = new StringBuffer(item2.toUpperCase() + "S -> " + (item2.toString()).toUpperCase() + " " + item2.toUpperCase() + "S | eps\n "); outfile.write(item3.toString()); xmlfile.write(" \n "); xmlfile.write(" 0..*\n"); xmlfile.write(" \n"); } else if ((frequency == 1) & (empty == 1)) { item3 = new StringBuffer(item2.toUpperCase() + "S -> " + (item2.toString()).toUpperCase() + " | eps\n"); outfile.write(item3.toString()); xmlfile.write(" \n "); xmlfile.write(" 0..1\n"); xmlfile.write(" \n"); } else if ((frequency == 1) & (empty == 0)) { item3 = new StringBuffer(item2.toUpperCase() + "S -> " + (item2.toString()).toUpperCase() +"\n" ); outfile.write(item3.toString()); } else if ((frequency > 1) & (empty == 0)) { item3 = new StringBuffer(item2.toUpperCase() + "S -> " + (item2.toString()).toUpperCase() + " " +item2.toUpperCase() + "S | " + (item2.toString()).toUpperCase() + "\n"); outfile.write(item3.toString()); xmlfile.write(" \n "); xmlfile.write(" 1..*\n"); xmlfile.write(" \n"); } xmlfile.write(" \n"); xmlfile.write(" \n"); xmlfile.write(" \n\n"); ID++; empty = 0; frequency = 0; counter = 1; incounter = 0; }//outermost - for //output fields fdnum = Integer.toString(fdctr); Vector yz = (Vector)fields.get(moaNames.get(l)); if (!(yz.isEmpty())) { StringBuffer fdstring = new StringBuffer(); for (int i0 = 0; i0 \n "); xmlfile.write(" " + bt.toString() + " \n "); xmlfile.write(" \n"); xmlfile.write(" false\n"); xmlfile.write(" \n"); xmlfile.write(" \n\n "); ID++; connID = new StringBuffer(Integer.toString(ID)); xmlfile.write(" \n "); xmlfile.write(" HasAttribute \n"); xmlfile.write(" \n"); xmlfile.write(" \n"); xmlfile.write(" \n\n"); ID++; fdstring.append(" "); fdstring.append(bt.toString()); fdstring.append(" "); } fdstring.append(" "); fdstring.append("\n"); StringBuffer item4 = new StringBuffer("FIELDS" + fdnum + " -> " + "<> "+ fdstring.toString() ); outfile.write(item4.toString()); } else { StringBuffer item4 = new StringBuffer("FIELDS" +fdnum +" -> " + " eps \n" ); outfile.write(item4.toString()); } //output connections cnnum = Integer.toString(cnctr); if (cNames.containsKey(moaNm)) { Vector cnm2 = (Vector)cNames.get(moaNm); //output connection names string StringBuffer item5 = new StringBuffer("CONNECTIONS" + cnnum + " -> "); for (int i3 = 0; i3 < cnm2.size(); i3++) { ++fctr; fnum = Integer.toString(fctr); srcnum = Integer.toString(srctr); dtnum = Integer.toString(dtctr); String cname = ((String)cnm2.get(i3)).toUpperCase(); StringBuffer cname2 = new StringBuffer(cname + " -> " + "<> " + cname.toLowerCase() + " : " + "SRC" + srcnum + " -> " + "DST" + dtnum + " ; " + cname + " | eps\n"); outfile.write(cname2.toString()); String connNum = Integer.toString(ID); String mdConns = new String("id-0066-000" + connNum); //output Connection name model xmlfile.write(" \n"); xmlfile.write(" " + cname.toLowerCase() + "\n"); xmlfile.write(" \n"); xmlfile.write(" false\n "); xmlfile.write(" \n "); xmlfile.write(" \n"); xmlfile.write(" false\n"); xmlfile.write(" \n"); xmlfile.write(" \n\n"); ID++; //connect Model to Connection xmlfile.write(" \n"); xmlfile.write(" Containment\n"); xmlfile.write(" \n"); xmlfile.write(" 0..*\n"); xmlfile.write(" \n"); xmlfile.write(" \n"); xmlfile.write(" \n"); xmlfile.write(" \n\n"); ID++; String cnm3 = (String)cnm2.get(i3); Vector src2 = (Vector)cSrcs.get(cnm3); StringBuffer source = new StringBuffer("SRC" + srcnum + " -> " + "<> FCO"+ fnum + "\n"); outfile.write(source.toString()); StringBuffer source2 = new StringBuffer("FCO" + fnum + " -> " ); //output FCO String fcoName = new String("FCO"+ fnum); String fcoID = new String("id-0066-000" + Integer.toString(ID)); xmlfile.write(" \n"); xmlfile.write(" " + fcoName + "\n"); xmlfile.write(" \n"); xmlfile.write(" false\n"); xmlfile.write(" \n"); xmlfile.write(" \n\n"); ID++; //Inheritance definition for FCO String inheritID = new String("id-0066-000" + Integer.toString(ID)); xmlfile.write(" \n"); xmlfile.write(" \n"); xmlfile.write(" \n\n"); ID++; //connect FCO to the inheritance structure xmlfile.write(" \n"); xmlfile.write(" BaseInheritance\n"); xmlfile.write(" \n"); xmlfile.write(" \n"); xmlfile.write(" \n\n"); ID++; //output Connector item String connector = new String("id-066-000" + Integer.toString(ID)); xmlfile.write(" \n"); xmlfile.write(" \n"); xmlfile.write(" \n\n"); ID++; //attach Connection to connector xmlfile.write(" \n"); xmlfile.write(" AssociationClass\n"); xmlfile.write(" \n"); xmlfile.write(" \n"); xmlfile.write(" \n\n"); ID++; //remove repetition of source items plus create inheritance hierarchy for source items Vector tester2 = new Vector(); String fcoItemID = new String(); for (int i4 = 0; i4 < src2.size(); i4++) { String srz = (String)src2.get(i4); String srcItem = srz.toLowerCase(); if (!(tester2.contains(srz))) { source2.append(srz.toUpperCase()); source2.append("|"); tester2.add(srz); if (mModels.containsKey(srcItem)) { fcoItemID = ((String)mModels.get(srcItem)); } else { fcoItemID = ((String)mAtoms.get(srcItem)); } xmlfile.write(" \n"); xmlfile.write(" DerivedInheritance\n"); xmlfile.write(" \n"); xmlfile.write(" \n"); xmlfile.write(" \n\n"); ID++; } } source2.deleteCharAt((source2.length())-1); source2.append("\n"); fctr = fctr + 1; fnum = Integer.toString(fctr); Vector tester3 = new Vector(); //remove repetition of destination items Vector dst2 = (Vector)cDsts.get(cnm3); StringBuffer dest = new StringBuffer("DST" + dtnum + " -> " + "<> FCO" + fnum + "\n"); StringBuffer dest2 = new StringBuffer("FCO" + fnum + " -> "); outfile.write(dest.toString()); String fcoName2 = new String("FCO"+ fnum); String fcoID2 = new String("id-0066-000" + Integer.toString(ID)); xmlfile.write(" \n"); xmlfile.write(" " + fcoName2 + "\n"); xmlfile.write(" \n"); xmlfile.write(" false\n"); xmlfile.write(" \n"); xmlfile.write(" \n\n"); ID++; //Inheritance definition for FCO String inheritID2 = new String("id-0066-000" + Integer.toString(ID)); xmlfile.write(" \n"); xmlfile.write(" \n"); xmlfile.write(" \n\n"); ID++; //connect FCO to the inheritance structure xmlfile.write(" \n"); xmlfile.write(" BaseInheritance\n"); xmlfile.write(" \n"); xmlfile.write(" \n"); xmlfile.write(" \n\n"); ID++; //attach source(FCO) to connector String src2conn = new String ("id-066-000" + Integer.toString(ID)); xmlfile.write(" \n"); xmlfile.write(" SourceToConnector\n"); xmlfile.write(" \n"); xmlfile.write(" src\n"); xmlfile.write(" \n"); xmlfile.write(" \n"); xmlfile.write(" 0..*\n"); xmlfile.write(" \n"); xmlfile.write(" \n"); xmlfile.write(" \n"); xmlfile.write(" \n\n"); ID++; //attach connector to destination(FCO) String src2conn2 = new String ("id-066-000" + Integer.toString(ID)); xmlfile.write(" \n"); xmlfile.write(" ConnectorToDestination\n"); xmlfile.write(" \n"); xmlfile.write(" dst\n"); xmlfile.write(" \n"); xmlfile.write(" \n"); xmlfile.write(" 0..*\n"); xmlfile.write(" \n"); xmlfile.write(" \n"); xmlfile.write(" \n"); xmlfile.write(" \n\n"); ID++; for (int i5 = 0; i5 < dst2.size(); i5++) { String dzt = (String)dst2.get(i5); if (!(tester3.contains(dzt))) { dest2.append(dzt.toUpperCase()); dest2.append("|"); tester3.add(dzt); String dstItem = dzt.toLowerCase(); if (mModels.containsKey(dstItem)) { fcoItemID = ((String)mModels.get(dstItem)); } else { fcoItemID = ((String)mAtoms.get(dstItem)); } xmlfile.write(" \n"); xmlfile.write(" DerivedInheritance\n"); xmlfile.write(" \n"); xmlfile.write(" \n"); xmlfile.write(" \n\n"); ID++; } } dest2.deleteCharAt((dest2.length())-1); dest2.append("\n"); outfile.write(source2.toString()); outfile.write(dest2.toString()); item5.append(cname); item5.append(" "); ++srctr; ++dtctr; } item5.append("\n"); outfile.write(item5.toString()); } //contains-key else { StringBuffer item5 = new StringBuffer("CONNECTIONS" + cnnum + " -> " + "eps\n"); outfile.write(item5.toString()); } ++ptctr; ++cnctr; ++fdctr; ++mactr; } //output all atoms StringBuffer atoms = new StringBuffer("\n\nATOMS -> "); for (int j = 0; j < atomNames.size(); j++) { String atomName = ((String)atomNames.get(j)).toUpperCase(); atoms.append(atomName); atoms.append(" ATOMS |"); } atoms.append(" eps"); String atoms2 = atoms.toString(); //outfile.write(atoms2 + "\n"); outfile.write("\n\n"); for (int w = 0; w < atomNames.size(); w++) { fdnum = Integer.toString(fdctr); String atoms0 = ((String)atomNames.get(w)).toUpperCase(); String atomNm = ((String)atomNames.get(w)).toLowerCase(); if ( mAtoms.containsKey(atomNm) ) { aID = (String)mAtoms.get(atomNm); xmlfile.write(" \n "); xmlfile.write(" " + atomNm + " \n "); xmlfile.write(" \n"); xmlfile.write(" false \n"); xmlfile.write(" \n"); xmlfile.write(" \n"); xmlfile.write(" false \n"); xmlfile.write(" \n"); xmlfile.write(" \n\n "); } StringBuffer atname = new StringBuffer(atoms0 + " -> " + "<> "+ atoms0.toLowerCase() + "{ FIELDS" + fdnum + " }\n"); outfile.write(atname.toString()); Vector zz = (Vector) fields.get(atomNames.get(w)); if (!(zz.isEmpty())) { StringBuffer fld = new StringBuffer("FIELDS" + fdnum + " -> " + "<> "); for (int w2 = 0; w2 < zz.size(); w2++) { String flds = (String)zz.get(w2); String fldID = Integer.toString(ID); fID = new StringBuffer("id-0066-000" + Integer.toString(ID)); xmlfile.write(" \n "); xmlfile.write(" " + flds.toString() + " \n "); xmlfile.write(" \n"); xmlfile.write(" false \n"); xmlfile.write(" \n"); xmlfile.write(" \n\n "); ID++; connID = new StringBuffer( Integer.toString(ID)); xmlfile.write(" \n "); xmlfile.write(" HasAttribute \n"); xmlfile.write(" \n"); xmlfile.write(" \n"); xmlfile.write(" \n\n"); ID++; fld.append(flds); fld.append(" "); } fld.append("\n\n"); outfile.write(fld.toString()); } else { StringBuffer fld = new StringBuffer("FIELDS" + fdnum + " -> eps\n\n"); outfile.write(fld.toString()); } ++fdctr; } outfile.write(separator); outfile.close(); xmlfile.write(" \n"); xmlfile.write(" Connectivity\n"); xmlfile.write(" \n\n"); xmlfile.write(" \n"); xmlfile.write(" \n"); xmlfile.write(" \n"); xmlfile.close(); return outfile; } catch (IOException e) { e.printStackTrace(); } return null; } } //method Conv2Gram } // language GME_Model