Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Java Code Generation using Perl

by SamRS (Initiate)
on Feb 01, 2002 at 07:03 UTC ( #142621=perlquestion: print w/replies, xml ) Need Help??
SamRS has asked for the wisdom of the Perl Monks concerning the following question:

Hi, Where can i get information/source codes/sites(If it already exists) for automatically generating java Code(Template . ie; it can select fields from a table ..see it's descriptions and then generate a source code) using perl. for eg: The generated code may look as follows: where Employee is the table connected to. The fields EMPLOYEE NUMBER etc has been made as private. Function templates can also be written such as getEmployeeNbr(). class Employee { private int employeeNbr; private String designationCde; ... private String lastNme; public int getEmployeeNbr() { return employeeNbr; }

Replies are listed 'Best First'.
Re: Java Code Generation using Perl
by clemburg (Curate) on Feb 01, 2002 at 11:19 UTC

    Advanced Perl Programming has a good section on "Template-Driven Code Generation" (Chapter 17) that should serve your needs.

    Christian Lemburg
    Brainbench MVP for Perl

Re: Java Code Generation using Perl
by lachoy (Parson) on Feb 02, 2002 at 06:05 UTC

    I've written a system generate Entity and Session beans using the Template Toolkit. Works great. First step is to use JDBC to generate a textfile of information about the tables -- JDBC has access to much more metadata than DBI. Then a perl script and a series of classes use the Template Toolkit along with the data to build the various beans and deployment descriptors.

    The nice thing about using this system is that it makes designing much more flexible. If we want to use a different way to represent relationships between tables/beans, we just code it once and regenerate the beans. And it enables us to quickly accommodate changes to the database schema as well, or even create a metadata text file based on versions of the database.

    Let me know if you have any specific questions.

    M-x auto-bs-mode

Re: Java Code Generation using Perl
by trs80 (Priest) on Feb 02, 2002 at 02:46 UTC
    Well it isn't Perl, it is Java, but it works nicely.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://142621]
Approved by root
[erix]: go to the bottom of this page: Seekers of Perl Wisdom
[karlgoethebier]: thao4: Si tout le reste échoue demande en francais ;-) There are some French speaking monks in the monastry...
[erix]: weird: a dev version perl (perl-5.27.9) is released, but git doesn't contain a perl-5.27.10 yet
[karlgoethebier]: ...not me ;-)

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (11)
As of 2018-02-21 10:04 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (276 votes). Check out past polls.