Parse a string by replacing all the properties and attributes.
This routine looks for Properties with the format
PROPERTY(name) . These will be replaced with the value of
the property provided from the supplied properties instance (
properties.get("name") ).
The routine also identifies attributes, identified by the format string
ATTRIBUTE({name:}attribute{,default}) .
In this case {name:} is an optional name (which defaults to the attribute
name, if it is not supplied. This format string will be replaced by
setting the attribute with the given name to
properties.get("name") , if name was supplied, or
properties.get("attribute") , if it wasn't.
For an attribute, there is also the optional default parameter, which is
separated from the attribute name by a comma. This value will be used,
quoted, if the property was not set.
example
This is best illustrated by means of example. Consider the following
theme section called "myFirstTag". This must have been set
separately in the theme JSP file, using the
com.ivata.mask.web.tag.theme.SectionTag <theme:section>tag .
<table ATTRIBUTE(cellpadding)
ATTRIBUTE(width:cellspacing) border=(border,0)>
<tr>
<td>PROPERTY(text)</td>
</tr>
</table>
Now look at the following Java code:
Properties properties = new Properties();
properties.set("width", 10);
properties.set("text", "This is an output
test text.");
String sMyFirstTag = theme.parse("myFirstTag", properties);
At this point, sMyFirstTag will contain:
<table cellspacing='10' border='0'>
<tr>
<td>This is an output test
text.</td>
</tr>
</table>
Parameters: nameParam - the name of the section text to parse forPROPERTY or ATTRIBUTE strings Parameters: propertiesParam - the properties to use when evaluatingPROPERTY or ATTRIBUTE strings a parsed string where all instances of PROPERTY orATTRIBUTE are replaced as appropriate, or an emptystring if this section has not been defined. See Also: Theme.getSection(String name) See Also: Theme.parse(String text,Properties properties) |