Class GenerateSource

java.lang.Object
   |
   +----GenerateSource

public class GenerateSource
extends Object
GenerateSource: generate java source code for multiple API's from a single source tree using #ifdef, #else, #endif tags.
This class generates the source code for a particular API version from java source code which has been "enriched" with several tags.
How to use the program:
From usage:
usage: GenerateSource -d output_directory -t tagname1 -t tagnameN [source files]
-d output_directory
A required parameter, the directory where the resulting files should be written to.
Note: The current version will happily accept "." as output directory or the same sourcefile as targetfile, thus overwriting all your files.
High on the TODO list.
-t tagname
Define a tag this way. Multiple tags are defined using multiple -t switches.
Valid tags start with A-Za-z and after that any number of A-Za-z0-9_ chars.

Using tags in the sourcecode:
Currently understood tags are:

#ifdef <tagname> <more tagnames>
every line after the #ifdef line is only written if any of the tagnames are defined.
Valid tags start with A-Za-z and after that any number of A-Za-z0-9_ chars.
Parsing the tagline will stop at the first invalid tag.
So a line like: "#ifdef VERSION_2_1 // only do this in VERSION_2_1" will be read as "#ifdef VERSION_2_1".
Note that '=' as the begin of a tagName is reserved for future use.
#else
with this tag the writeStatus is negated.
If the program was currently writing lines based on the previous #ifdef condition, it will stop writing.
If on the other hand the program was currently not writing lines based on the previous #ifdef condition, it will start doing so.
#endif
The effect of the previous #ifdef line will be undone

Example use:
 #ifdef TagName_1_1 TagName_1_2 // If either of TagName_1_1 or TagName_1_2
                                // is defined writing will start now
   ...
 #ifdef TagName_2_1             // from now on (TagName_1_1 or Tagname_1_2)
                                // and TagName_2_1 must be defined
  ...
 #else                          // from now on (TagName_1_1 or Tagname_1_2)
                                // and not TagName_2_1 must be defined
  ...
 #endif                         // If either of TagName_1_1 or TagName_1_2 is
                                // defined writing will take place
 

Remarks:


Variable Index

 o VALID_TAG_CHAR
 o VALID_TAG_CHAR_BEGIN

Constructor Index

 o GenerateSource(String[])

Method Index

 o execute()
 o main(String[])
 o usage()

Variables

 o VALID_TAG_CHAR_BEGIN
 public static final String VALID_TAG_CHAR_BEGIN
 o VALID_TAG_CHAR
 public static final String VALID_TAG_CHAR

Constructors

 o GenerateSource
 public GenerateSource(String args[]) throws IllegalArgumentException

Methods

 o main
 public static void main(String args[])
 o usage
 public static void usage()
 o execute
 public void execute()