java code generation tool-good one

F

f

In my project, I need to write a lot of class like:

public class Data1{
double d1;
double d2;

double getD1(){
return d1;
}

double getD2(){
return d2;
}
}

public class data2{
int g1;
int g2;
int g3;

int getG1(){
return g1;
}

int getG2(){
return g2;
}

int getG3(){
return g3;
}
}

public class data3{
short aaa1;

short getAAA1(){
return aaa1;
}
}

I need to write a huge collection of code which have very clear
patterns. I am wondering if there is a tool to automatically generate
the code. For example, I write a template:

public class <<class_name>>{
<<LOOP>>
<<data_type>> <<data_name>>;
<<END_LOOP>>

<<LOOP>>
<<data_type>> get<<data_name>>(){
return <<data_name>>;
};
};

and the tool can generate the java source code for me?

Thanks,

ff
 
H

Harald Hein

f said:
In my project, I need to write a lot of class like:

Are you sure? I would redo the application architecture if I find
myself in that position. Especially I would look very hard on
inheritance and the collection classes.
and the tool can generate the java source code for me?

It is trivial to write on. It should also be possible to deploy some of
the many macro or preprocessors that are out there and which are in use
for ages.
 
M

MSeries

f said:
and the tool can generate the java source code for me?

Thanks,

ff

I wrote something years ago that allows you to specify your attributes in an
XML document and will generate the class from it. Here is the url to my page
http://web.ukonline.co.uk/mseries/ClassWriter.html, the download contains
source and the jar

there are samples in the download, look at myClass.xml and myClass.java.

Please note this was done for my own benefit and the folks with whom I was
working at the time - give it a go, if you don't like it then don't use
it/amend it yourself.
 
B

brougham5

and the tool can generate the java source code for me?

Does your code editor support macros? That's a good place to start.

If it doesn't, I'd start by looking for a different editor.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top