Generate Java
code Quick Start
Simply take a look
to "net.sourceforge.framecode.format.test" package: it
contains several test runnable classes that generate sample Java
classes.
Modify the code
for file placing and run it.
Creating your
own language model
For single line
code: extend the class "net.sourceforge.framecode.base.Code".
For blocks
you have several choices:
If you have a
block with a header and a footer (think about "for"
statement) extend "net.sourceforge.framecode.base.OneBlock".
If you have a
set of lines without header and footer (simple sequence of code
lines) extend net.sourceforge.framecode.base.NoHeaderBlockCode.
If you have a
set of blocks with a header and a footer (think about a Java
class with a header [the declaration], a footer [curly closing
bracket] and a set of blocks [the block for fields and the block
for methods]) extend
net.sourceforge.framecode.base.BaseCodeBlock.
If you have a
set of blocks without header and footer, extend
net.sourceforge.framecode.base.NoHeaderBlockSet.
If you need
to define a comment block, extend
net.sourceforge.framecode.base.Comment.
In all other
situations, take a look
to: net.sourceforge.framecode.base.Formattable
interface; net.sourceforge.framecode.base.FormattableCode
utility class; net.sourceforge.framecode.base.PlainBlock class
(for an example of an all-purpose block).
Creating your
own formatter
If you need to
format the code in some different way, implement the
net.sourceforge.framecode.format.Formatter interface, or extend
the net.sourceforge.framecode.format.CommentAwareFormatter class.
Take a look
to: net.sourceforge.framecode.format.PlainFormatter and
net.sourceforge.framecode.format.JavaFormatter for an example.
|