Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Does there exist a Java library with an API for generating a java source file?

Posted on 2011-10-26
4
Medium Priority
?
429 Views
Last Modified: 2013-11-13
I know there are many different source code generators out there. Most use XML or some structured text as a template. I am looking for a library that has an API for constructing simple java class sources...
I.E.
JavaSourceBuilder builder = new JavaSourceBuilder(Type.CLASS);
builder.setName("MyClass");
builder.setPackage("com.mydomain");
builder.addField(new FieldBuilder(Modifier.PRIVATE, String.class, "name"));
....
System.out.println(builder.toString());

0
Comment
Question by:Uncle_J
  • 2
4 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 37032893
Generating java source from what - a class file, xml...?
0
 

Author Comment

by:Uncle_J
ID: 37032956
From code. The example I gave in my description is what a possible implementation may look like. There are tools like this for building XML documents, HTML, etc... Any for Java source?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 37033213
I must say i've never seen one
0
 
LVL 4

Accepted Solution

by:
stachenov earned 2000 total points
ID: 37039938
According to this SO question, there are at least two such libraries, one of which is Eclipse-specific, the other seems to be even supported by Sun.
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Suggested Courses

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question