F
FWE
I work with eclipse. I must generate java code in relation to some
variables . I want create java class that reflect table in mysql data
base with function of read,update,insert,delete. EMF can help me to do
this? Reading documentation about EMF i have understood that from UML,
XMI and from java class it generate code but if i customize function?
number that i must use.
In "Load" function i insert into two vectors the type of variables and
the name of variables.(In future "Load" will get information from file
or other..)
After i have created many function but i have cited only one
"generateConstructor()" that return a string that represents a
constructor function.
Anyone can help me?
public class SalvaVita {
private int numeroCampi;
private String nomeTabella;
private String[] nomeCampi;
private String[] tipiCampi;
public SalvaVita(int numeroCampi) {
this.numeroCampi = numeroCampi;
nomeCampi = new String[numeroCampi];
tipiCampi = new String[numeroCampi];
}
public void Load(){
nomeTabella="Azienda";
nomeCampi[0]="ID";
// ...
tipiCampi[0]="int";
// ...
}
public String generateConstructor(){
String resultBegin,resultEnd;
resultBegin = " public " + nomeTabella+"(";
int i;
for(i=0;i<(numeroCampi-1);i++){
resultBegin+=tipiCampi+" "+nomeCampi+",";
}
resultBegin+=tipiCampi+" "+nomeCampi+"){\n";
for(i=0;i<(numeroCampi);i++){
resultBegin+=" this."+nomeCampi+" = "+nomeCampi+";\n";
}
resultEnd =" }\n";
return resultBegin + resultEnd;
}
}
variables . I want create java class that reflect table in mysql data
base with function of read,update,insert,delete. EMF can help me to do
this? Reading documentation about EMF i have understood that from UML,
XMI and from java class it generate code but if i customize function?
i've created a "SalvaVita" class giving the information about variablesFrom stupid person i have created this java class:
number that i must use.
In "Load" function i insert into two vectors the type of variables and
the name of variables.(In future "Load" will get information from file
or other..)
After i have created many function but i have cited only one
"generateConstructor()" that return a string that represents a
constructor function.
Anyone can help me?
public class SalvaVita {
private int numeroCampi;
private String nomeTabella;
private String[] nomeCampi;
private String[] tipiCampi;
public SalvaVita(int numeroCampi) {
this.numeroCampi = numeroCampi;
nomeCampi = new String[numeroCampi];
tipiCampi = new String[numeroCampi];
}
public void Load(){
nomeTabella="Azienda";
nomeCampi[0]="ID";
// ...
tipiCampi[0]="int";
// ...
}
public String generateConstructor(){
String resultBegin,resultEnd;
resultBegin = " public " + nomeTabella+"(";
int i;
for(i=0;i<(numeroCampi-1);i++){
resultBegin+=tipiCampi+" "+nomeCampi+",";
}
resultBegin+=tipiCampi+" "+nomeCampi+"){\n";
for(i=0;i<(numeroCampi);i++){
resultBegin+=" this."+nomeCampi+" = "+nomeCampi+";\n";
}
resultEnd =" }\n";
return resultBegin + resultEnd;
}
}