Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Tool for generate CODE.

Reply
Thread Tools

Tool for generate CODE.

 
 
FWE
Guest
Posts: n/a
 
      12-27-2005
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?
>From stupid person i have created this java class:

i've created a "SalvaVita" class giving the information about variables
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[i]+" "+nomeCampi[i]+",";
}
resultBegin+=tipiCampi[i]+" "+nomeCampi[i]+"){\n";

for(i=0;i<(numeroCampi);i++){
resultBegin+=" this."+nomeCampi[i]+" = "+nomeCampi[i]+";\n";
}
resultEnd =" }\n";
return resultBegin + resultEnd;
}
}

 
Reply With Quote
 
 
 
 
Raymond DeCampo
Guest
Posts: n/a
 
      01-01-2006
FWE wrote:
> 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?
>>From stupid person i have created this java class:

> i've created a "SalvaVita" class giving the information about variables
> 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?
>


Best practice in this case is to have classes that extend the generated
classes and specialize those. Then re-generating the generated classes
will not affect the specializations.

For example, generate a SalvaVistaBase class via the tool. Then create
a SalvaVista extending SalvaVistaBase. Add the specialized code to
SalvaVista. Only use the SalvaVista class in your application. When
the schema changes, re-generate SalvaVistaBase.

HTH,
Ray

--
XML is the programmer's duct tape.
 
Reply With Quote
 
 
 
 
Oliver Wong
Guest
Posts: n/a
 
      01-09-2006

"FWE" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
>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?


It sounds like you want to generate code which you will them immediately
use in your application (as opposed to, for example, giving your client a
program which will generate .class files for them). If that's the case, you
might want to try JET.

JET code looks like JSP or PHP code, in that it's code that is embedded
into arbitrary text streams. The JET plugin for Eclipse provides a builder
so that as part of the build process, the JET code is executed, generating
the Java code, which in turn gets compiled all in the background and
automatically.

http://www.eclipse.org/articles/Arti...tutorial1.html

- Oliver


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Failed to generate a user instance of SQL Server. Only an integratedconnection can generate a user instance. Harlan Messinger ASP .Net 2 03-28-2010 06:51 PM
How to generate warnings when How generate a warning when int is converted to bool or vice versa? PengYu.UT@gmail.com C++ 3 04-06-2006 11:24 PM
How to generate variable labels for same component within a generate loop Weng Tianxiang VHDL 5 02-16-2006 01:45 PM
Generate local resource tool Gawel ASP .Net 0 01-13-2006 02:56 PM
I want a simple browser-based tool that will generate the Add, Chg, and Delete routines Keith A. Rowe ASP .Net 2 02-14-2004 03:05 AM



Advertisments