Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Java Code Generation using Perl

by SamRS (Initiate)
on Feb 01, 2002 at 07:03 UTC ( [id://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
    http://www.brainbench.com

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.

    Chris
    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.
    TableGen

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://142621]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2024-04-25 21:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found