Class GenerateSource

java.lang.Object
  |
  +--GenerateSource

public class GenerateSource
extends java.lang.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:


Field Summary
static java.lang.String VALID_TAG_CHAR
           
static java.lang.String VALID_TAG_CHAR_BEGIN
           
 
Constructor Summary
GenerateSource(java.lang.String[] args)
           
 
Method Summary
 void execute()
           
static void main(java.lang.String[] args)
           
static void usage()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VALID_TAG_CHAR_BEGIN

public static final java.lang.String VALID_TAG_CHAR_BEGIN

VALID_TAG_CHAR

public static final java.lang.String VALID_TAG_CHAR
Constructor Detail

GenerateSource

public GenerateSource(java.lang.String[] args)
               throws java.lang.IllegalArgumentException
Method Detail

main

public static void main(java.lang.String[] args)

usage

public static void usage()

execute

public void execute()