|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.wurbelizer.AbstractWurbiler
public class AbstractWurbiler
Provides basic functionality of a wurblet compiler.
Translates an input stream (usually a file with extension *.wrbl)
into a an output stream and a fixed source list.
The generated java-output implements the interface Wurblet.
The fixed source part of the wurblet is stored in a List of Strings which usually is
stored in serialized form in a separate file and will be deserialized by the wurbler
when running the wurblet.
By default the input stream starts at the source-level.
The backslash is recognized as wurblet-level is entered via @[ and left via ]@.
Wurblet-levels again may contain other wurblet-levels, i.e. they may be nested
resulting in a wurblet generating a wurblet which in turn generates java source
or even another wurblet.
As a shorthand for @[out.print(object);]@ the wurbiler understands the
notation @(object)@.
This may be even used in a string (e.g.: "This is line @(line)@\n");).
The backslash '\' is recognized as an escape char.
If followed by a '@', the backslash will be consumed and the @ passed to the source.
Other pairs of escapes will be passed unprocessed (e.g. '\n' or whatever).
Commands may also be embedded at the source-level via @{command par1 par2 ... parN}@.
The following commands are supported:
@{include <pathname>}@: includes a file in the current input stream.
Includes may be nested to any depth. Loops are detected.
the include pathname allows $-variables that will be replaced
at compile time.
@{package <packagename>}@: sets the package-name for the generated class.
@{import <classpath>}@: adds to the extra imports.
@{extends <parentclass>}@ sets the parent-class (default is AbstractWurblet).
@{implements <if1> ... <ifN>}@ implements interfaces.
@{indent <spaces>}@: sets the fixed source indentation.
"auto" enables autoindent., i.e. @{indent auto}@.
Autoindent is the default.
@{args <arg1> <arg2> ...}@: presets the wurblet arguments (default is from container, i.e. wurbler)
notice that @{args}@ without any arguments enables container args again.
This is especially useful for @{including} serveral wurblets in a single source-file.
Thus, if the wurblet needs args, it's a good practice to include an @{args}-line
in the wurblet-code.
@{to <outputstream>}@: sets the output stream (this is the stream the wurblet
will write the generated code to, not the output writer of the compiled wurblet!).
@{to out} resets to the default stream, which is equivalent to @{to}.
| Constructor Summary | |
|---|---|
AbstractWurbiler(Reader in,
String inName,
Writer out,
List<String> sourceList)
Creates a compiler instance. |
|
| Method Summary | |
|---|---|
boolean |
addInterface(String iface)
Adds an interface. |
int |
compile()
Compiles the wurbelizable. |
String[] |
getArgs()
Gets the presetted wurblet arguments. |
String[] |
getImports()
Gets the list of imports. |
int |
getIndent()
Gets the source indentation. |
Collection<String> |
getInterfaces()
Gets the interface list. |
Logger |
getLogger()
Gets the logger for warnings and errors. |
String |
getOutName()
Gets the outname. |
String |
getPackageName()
Gets the package name. |
String |
getParentClass()
Gets the name of the parent class. |
Reader |
getReader()
Gets the input reader. |
List<String> |
getSourceList()
Gets the list of fixed source-strings. |
Writer |
getWriter()
Gets the output writer. |
boolean |
isAutoIndent()
Gets the autoindent feature. |
void |
logError(String msg)
Logs an error message. |
void |
logWarning(String msg)
Logs a warning. |
void |
setArgs(String[] args)
Presets the wurblet arguments. |
void |
setAutoIndent(boolean autoIndent)
Sets the autoindent feature. |
void |
setImports(String[] imps)
Sets the imports. |
void |
setIndent(int indent)
Sets the indentation for code generating the source. |
void |
setLogger(Logger logger)
Sets the logger for warnings and errors. |
void |
setOutName()
Sets outname to the default. |
void |
setOutName(String outName)
Sets the name of the output stream in the generated source. |
void |
setPackageName(String packageName)
Sets the package-name. |
void |
setParentClass(String parentClass)
Sets the parent class. |
void |
setSourceList(List<String> sourceList)
Presets the source list. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public AbstractWurbiler(Reader in,
String inName,
Writer out,
List<String> sourceList)
in - the input streaminName - the name of the input stream (for diagnostics only)out - the output streamsourceList - the fixed source list (null to create it)| Method Detail |
|---|
public Writer getWriter()
public Reader getReader()
public int compile()
throws IOException
compile in interface WurbilerIOException - if the compiled output could not be createdpublic List<String> getSourceList()
getSourceList in interface Wurbilerpublic void setSourceList(List<String> sourceList)
setSourceList in interface WurbilersourceList - the source list, null if compile() should initialize itpublic int getIndent()
getIndent in interface Wurbilerpublic void setIndent(int indent)
setIndent in interface Wurbilerindent - the new indentationpublic void setAutoIndent(boolean autoIndent)
setAutoIndent in interface WurbilerautoIndent - true to enable autoindent, false to disable.public boolean isAutoIndent()
isAutoIndent in interface Wurbilerpublic void setOutName(String outName)
setOutName in interface WurbileroutName - the name of the output stream, null sets to the default value "out".public void setOutName()
setOutName in interface Wurbilerpublic String getOutName()
getOutName in interface Wurbilerpublic Logger getLogger()
getLogger in interface Wurbilerpublic void setLogger(Logger logger)
setLogger in interface Wurbilerlogger - the logger.public void logError(String msg)
msg - the error messagepublic void logWarning(String msg)
msg - the warning messagepublic String getPackageName()
getPackageName in interface Wurbilerpublic void setPackageName(String packageName)
setPackageName in interface WurbilerpackageName - the package name.public String getParentClass()
getParentClass in interface Wurbilerpublic void setParentClass(String parentClass)
setParentClass in interface WurbilerparentClass - the name of the parent classpublic boolean addInterface(String iface)
iface - the name of the interface
public Collection<String> getInterfaces()
public String[] getImports()
getImports in interface Wurbilerpublic void setImports(String[] imps)
setImports in interface Wurbilerimps - the importspublic String[] getArgs()
getArgs in interface Wurbilerpublic void setArgs(String[] args)
setArgs in interface Wurbilerargs - the wurblet args
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||