All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class org.webmacro.engine.ParsedString

java.lang.Object
   |
   +----java.util.Vector
           |
           +----org.webmacro.engine.ParsedString

public final class ParsedString
extends Vector
implements Macro
A parsed string is a vector of strings and macros. When parsing, it begins with a quotation mark and extends until a matching close quotation mark (single or double quotes accepted, the close quote must match the open quote).

When parsing, you can use the escape character to protect values that might otherwise be interepreted. The escape character is \

It usually contains a series of strings and variables. If you put a Macro into it, the Macro.evaluate()/Macro.write() method will be used to include its contents. If you include a non-Macro, its Object.toString() method will be used instead.

Unix users should note that there is no difference between double and single quotes with parsed string. It is more like the quoting used for HTML attributes. Internal variables are alway evaluated.

Examples:

    #include 'this is a parsed string with a $variable in it'
    #include "use double quotes and you can put don't in it"
    #include "use the escape char to write \$10 in a ParsedString"
 
Here the text inside the quotes is the ParsedString.


Method Index

 o evaluate(Object)
Return the value of the parsed string, after substituting all contained variables and removing the quotation marks.
 o main(String[])
test harness
 o parse(ParseTool)
Beginning with the quotation mark, parse everything up until the close quotation mark.
 o write(Writer, Object)
Write the parsed string out.

Methods

 o evaluate
 public Object evaluate(Object data) throws InvalidContextException
Return the value of the parsed string, after substituting all contained variables and removing the quotation marks.

Throws: InvalidContextException
is required data is missing
 o write
 public final void write(Writer out,
                         Object data) throws InvalidContextException, IOException
Write the parsed string out. Performs the same operation as evaluate(context) but writes it to the stream. Although this is required by the Macro superclass, we don't expect it to be used much since a parsed string does not really appear in a Block (it appears as the argument to a function or directive.)

Throws: InvalidContextException
is required data is missing
Throws: IOException
if could not write to output stream
 o parse
 public static final Object parse(ParseTool in) throws ParseException, IOException
Beginning with the quotation mark, parse everything up until the close quotation mark. It is a parse error if EOL or EOF happen before the end of the close quotation mark. The parsed string can begin with either a single or double quotation mark, and then it must end with the same mark.

Throws: ParseException
on unrecoverable parse error
Throws: IOException
on failure to read from parseTool
 o main
 public static void main(String args[])
test harness


All Packages  Class Hierarchy  This Package  Previous  Next  Index