1 package cve.esecutori.components.automatonB; 2 3 import java.io.*; 4 import java.util.*; 5 6 import org.jdom.*; 7 import org.jdom.input.SAXBuilder; 8 import org.jdom.output.XMLOutputter; 9 10 import cve.esecutori.components.specificaLV.*; 11 import cve.util.ConfigurationRead; 12 import cve.staticLayout.*; 13 14 import org.apache.log4j.Logger; 15 16 24 public class GenerationSentence implements IGenetarationSentence { 25 private WippogSent wip; 26 private ISpecifica specifica; 27 28 33 public GenerationSentence(ISpecifica spe)throws java.io.IOException { 34 Cve.errLog.debug(""); 35 specifica=spe; 36 wip=new WippogSent(specifica.getScheletro()); 38 } 39 40 44 public File createGS() { 45 Cve.errLog.debug(""); 46 wip.configSent (); 47 createSpe(); 48 File fileLang=wip.saveFileXml("SAVE SENTENCE FILE"); 49 return fileLang; 50 } 51 52 55 public static void main(String [] args) throws java.io.IOException { 56 String fileA=ConfigurationRead.getCveRoot()+"/VisualLanguage/cveAlf1.xml"; 58 String fileR=ConfigurationRead.getCveRoot()+"/VisualLanguage/cveRules1.xml"; 59 Specifica spe=new Specifica(fileR,fileA); 61 GenerationSentence gs=new GenerationSentence(spe); 63 gs.createGS(); 64 } 65 66 67 68 71 private void createSpe (){ 72 Cve.errLog.debug(""); 73 String idQuery; 74 Rules speRules=specifica.getRules(); 76 Collection rules=speRules.getRules(); 78 Iterator itRul=rules.iterator(); 79 while(itRul.hasNext()){ 81 Rule rule=(Rule)itRul.next(); 82 wip.openTransition(rule.getId(),rule.getComment()); 83 if (rule.getType().equals("kfree")){ 84 wip.writeProduce(rule.getPostFree(),null,true); 85 wip.writeOut(null,rule.getPostFree(),true); 86 wip.writeGet(null,rule.getPostFree(),true); 87 } else { 88 wip.writeWhen(rule.getPrecondition()); 89 wip.writeIf(rule.getPrecondition(),rule.getCondition()); 90 wip.writeProcess(rule.getAssignmentCons()); 91 wip.writeProduce(rule.getConseguent(),rule.getPrecondition(),false); 92 wip.writeOut((ElementRel)rule.getRel(),null,false); 93 wip.writeGet((ElementRel)rule.getRel(),null,false); 94 } 95 wip.closeTransition(); 96 } Collection elementNonRel=specifica.getNonRelation(); 98 Iterator itEle=elementNonRel.iterator(); 99 while(itEle.hasNext()){ 100 ElementNonRel eleAlfNonRel=(ElementNonRel)itEle.next(); 101 idQuery="Q"+"_"+eleAlfNonRel.getName(); 102 wip.openTransition(idQuery,"Query element "+eleAlfNonRel.getName()); 103 Vector app=new Vector(); 104 app.add(eleAlfNonRel); 105 wip.writeWhen(app); 106 wip.writeIfQuery(eleAlfNonRel.getNameId()); 107 wip.writeProduceQuery (app); 108 wip.writeGetQuery(eleAlfNonRel.getName()); 109 wip.closeTransition(); 110 idQuery=""; 111 } 112 } 113 114 } 115 116 | Popular Tags |