Extensions available
The following is a list of extensions available bundled with the distribution. If you write your own,
please do not hesitate to send it in, and it will be included in the list, with the author's name:
"Unless" keyword
This is a simple keyword, which is basically there for testing puproses. It simply generates
a negated condition, so code like this:
unless ( [condition] )
[statement]
Will translate to:
if ( ! ( [condition] ) )
[statement]
Log4j in syntax
This extension simplifies adding log4j logging lines to the code by offering 6 new keywords:
fatal,
error,
warn,
info,
debug,
trace. The usage is simple:
debug "This is a log line, variable is: "+variable;
Will translate to:
if ( __logger.isEnabled(Level.DEBUG) )
__logger.debug("This is a log line, variable is: "+variable);
Additionally, the nescessary import lines will be added automatically to the source:
import org.apache.log4j.Logger;
import.org.apache.log4j.Level;
And the logger itself will be defined automatically, with the class as it's category name:
private static Logger logger = Logger.getLogger([class]);
Foreach loop
This extension defines (and in case of Java 5) overrides the for-each loop construct. This foreach
loop is syntactically and semantically similar to the Java 5 for-each, except, that it does not need
template class collections to work, instead it casts each item to the specified type.
for ( String item : list )
System.out.println("Item is: "+item);
Will translate to (roughly, because the temporary variables may have other names):
for ( Iterator __foreach_i0 = (list).iterator(); __foreach_i0.hasNext(); )
{
String item = (String) __foreach_i0.next();
System.out.println("Item is: "+item);
}
Of course, the extension will add the import line for the Iterator automatically. The extension is also
capable of iterating on Maps:
for ( String key, String value : map )
System.out.println(key+" : "+value);
Will translate approximately to:
for ( Iterator __foreach_i0 = (map).entrySet().iterator(); __foreach_i0.hasNext(); )
{
Map.Entry __foreach_i0_entry = (Map.Entry) __foreach_i0.next();
String key = (String) __foreach_i0_entry.getKey();
String value = (String) __foreach_i0_entry.getValue();
System.out.println(key+" : "+value);
}
Bean property
This extension offers the
property modifier, which indicates, that this member variable
will be a bean property. The extension will generate the appropriate setter and getter method for the property. So the
following declaration:
public property String str;
Will be translated to:
private String str;
public String getStr()
{
return str;
}
public void setStr(String str)
{
this.str=str;
}
Note, that the original modifier of the property was
public, not
private. This is becuse you
define the modifier for the getter setter method, not the member attribute, which will
always be
private.
So
protected property String str;
Will be translated to:
private String str;
protected String getStr()
{
return str;
}
protected void setStr(String str)
{
this.str=str;
}
Of course, you can use the full repertoir of the java language, so you can write:
public property String name,address,zip,active="true";
And all the appropriate setters and getters will be produced.
Additionally, if a boolean (or Boolean) property is encountered, an appropriate bean-style
is<Varname>() is also produced.