CCMapsGenerator.java 2.18 KB
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
package jcircus.complexcomms;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;

public class CCMapsGenerator {
private String code = "";
private String packageDecl;
private String path;
private String procName;
private String paper;
private String src;
private String complement;
private int index;
public CCMapsGenerator (String paper, String src, String projectDir, String specName, String procName, int index, String complement) {
this.packageDecl = "package " + /*specName + "." +*/ paper + "." + src + "." + paper + "." + "ccmaps" + ";\n";
//this.path = projectDir + "\\" + paper + "\\" + src + "\\" + paper + "\\ccmaps\\CCMaps_" + complement + procName + "_" + index + ".java";
this.path = projectDir + "/" + paper + "/" + src + "/" + paper + "/ccmaps/CCMaps_" + complement + procName + "_" + index + ".java";
this.procName = procName;
this.index = index;
this.paper = paper;
this.src = src;
this.complement = complement;
}
public void concatCode (String str) {
this.code = this.code + str;
}
public String totalCode () {
return
this.packageDecl +
"import java.util.HashMap;\n" +
"import java.math.BigInteger;\n" +
"import java.util.Vector;\n" +
"import newjcircusutil.multisync.GeneralChannel;\n" +
"import " + this.paper + "." + src + "." + paper + ".channels.*;\n" +
"import " + this.paper + "." + src + "." + paper + ".typing.*;\n" +
"public class CCMaps_" + complement + procName + "_" + this.index + " {\n" +
" /*public int abs (String chan, int element, BigInteger bi) {\n" +
" return this.env_channels.get(chan).elementAt(element).indexOf(bi);\n" +
" }*/\n" +
this.code
+ "}\n";
}
public void generate() {
try {
BufferedWriter bw = new BufferedWriter (new FileWriter (this.path));
bw.write(this.totalCode());
bw.close();
} catch (IOException e) {
e.printStackTrace();
}
}
//Modelo do codigo que serĂ¡ gerado:
/*
* public class CCMaps {
* HashMap <String, Vector <Vector <BigInteger>>> env_channels = new HashMap <String, Vector <Vector <BigInteger>>> ();
* public void makeEnvChannels () {
*
* }
* }
* */
}