Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

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
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2017-09-21 05:12 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (242 votes). Check out past polls.