unit.UniT
This class provides some methods to easily interprete (parse and execute) UniT templates.
If a UniT template should be interpreted only once (in the default encoding), exceptions should not be caught and the result should be directed to standard out/the console, call the method interprete(String fileName).
If all occuring exceptions should be caught additionally and appropriate error messages should be directed to standard error/the console, call the method interpreteAndHandleExceptions(String fileName).
If a UniT template should be interpreted multiple times, hold the Interpreter object, that will be returned and call its run method multiple times, even in multiple threads.
An alternative to immediately executing a template is: calling parseUniT(String fileName). The template will be parsed but not executed! An object of the class Interpreter will be returned, that represents the parse tree and that can be executed at any time multiple times (with the method run), even in multiple threads.
If parameters should be passed to a UniT template, a Hashtable must be passed to the run method of the Interpreter object. That Hashtable must contain the name and value of the parameters. The name of each parameter or key of each Hashtable element respectively, must be a valid Java identifier, that can be accessed in UniT source code. The identifier named "out" may only be a Writer object.
If a UniT template should be directly executed from the command line ("java unit.UniT fileName"), the main method will be used. The output will be directed to standard output/the console, exceptions will be caught and error messages will be directed to standard error/the console. Additionally the arguments array will be passed to the template as identifier "arguments".
Interpreter
Constructor Summary | |
UniT()
|
Method Summary | |
static Interpreter |
interprete(java.lang.String fileName)
Parses and executes a UniT template, the resulting output will be send to System.out. |
static Interpreter |
interprete(java.lang.String fileName,
java.util.Hashtable identifiers,
java.io.Writer out)
Parses and executes a UniT template, the resulting output will be send to the out Writer object. |
static Interpreter |
interpreteAndHandleExceptions(java.lang.String fileName)
Parses and executes a UniT template. |
static Interpreter |
interpreteAndHandleExceptions(java.lang.String fileName,
java.util.Hashtable identifiers,
java.io.Writer out,
java.io.Writer error)
Parses and executes a UniT template. |
static void |
main(java.lang.String[] arguments)
Interpretes (parses and executes) a UniT template given as first parameter at the command line, catches all exceptions and directs standard and error output to the console. |
static Interpreter |
parseUniT(java.io.Reader in,
java.lang.String nameOfInput)
Parses a UniT template from a character stream. |
static Interpreter |
parseUniTFile(java.lang.String fileName)
Parses a UniT template with the specified file name and the default encoding. |
Constructor Detail |
public UniT()
Method Detail |
public static void main(java.lang.String[] arguments)
arguments
- all arguments of the command linepublic static Interpreter interpreteAndHandleExceptions(java.lang.String fileName)
fileName
- the file name of the template, that should be executed.Interpreter.run(Hashtable)
public static Interpreter interpreteAndHandleExceptions(java.lang.String fileName, java.util.Hashtable identifiers, java.io.Writer out, java.io.Writer error)
fileName
- the file name of the template, that should be executed.identifiers
- that should be passed to the template.
That Hashtable must contain the name and value of the parameters.
The name of each parameter or key of each Hashtable element respectively,
must be a valid Java identifier, that can be accessed in UniT source code.out
- the target of the result outputerror
- the target of error messagesInterpreter.run(Hashtable)
public static Interpreter interprete(java.lang.String fileName) throws java.io.FileNotFoundException, unit.RecognitionException, unit.TokenStreamException
fileName
- the file name of the template, that should be executed.Interpreter.run(Hashtable)
public static Interpreter interprete(java.lang.String fileName, java.util.Hashtable identifiers, java.io.Writer out) throws java.io.FileNotFoundException, unit.RecognitionException, unit.TokenStreamException
fileName
- the file name of the template, that should be executed.identifiers
- that should be passed to the template.
That Hashtable must contain the name and value of the parameters.
The name of each parameter or key of each Hashtable element respectively,
must be a valid Java identifier, that can be accessed in UniT source code.out
- the target of the result outputInterpreter.run(Hashtable)
public static Interpreter parseUniTFile(java.lang.String fileName) throws java.io.FileNotFoundException, unit.RecognitionException, unit.TokenStreamException
fileName
- the file name of the UniT template, that should be parsed.Interpreter.run(Hashtable)
public static Interpreter parseUniT(java.io.Reader in, java.lang.String nameOfInput) throws unit.TokenStreamException, unit.RecognitionException
in
- the Reader object that contains the UniT template with the correct encoding.nameOfInput
- the name of the UniT template, that should be parsed.
This name will be used when refering errors within the template.Interpreter.run(Hashtable)