|
Forward Computing and Control Pty. Ltd. WebStringTemplate V1.5.0 2004/1/7 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.antlr.stringtemplate.StringTemplateGroup
au.com.forward.webstringtemplate.WebStringTemplateGroup
Manages a group of named mutually-referential WebStringTemplate objects.
See the documenation for details.
Currently the templates must all live under the same directory so that you
can reference them as foo.st or gutter/header.st.
To refresh a group of templates, just create a new WebStringTemplateGroup
and start pulling templates from there, or, set the refresh interval.
Use getInstanceOf(template-name) to get a string template to fill in. The name of a template is the file name minus ".st" ending.
Field Summary | |
static StringTemplateErrorListener |
DEFAULT_SERVLET_ERROR_LISTENER
The default error listener for all the WebStringTemplates |
static java.util.logging.Logger |
logger
The Java logger for this class |
Fields inherited from class org.antlr.stringtemplate.StringTemplateGroup |
DEFAULT_ERROR_LISTENER |
Constructor Summary | |
WebStringTemplateGroup(java.lang.String name,
java.lang.String rootDir)
Create a group manager for some templates, all of which are loaded from the rootDir or classpath if rootDir is null. |
|
WebStringTemplateGroup(java.lang.String name,
java.lang.String rootDir,
java.lang.String delimiterStart,
java.lang.String delimiterStop)
Create a group manager for some templates, all of which are loaded from the rootDir or classpath if rootDir is null. |
Method Summary | |
StringTemplate |
createStringTemplate(java.util.Map initialValues)
Create a StringTemplate of the correct class, used when sub-classing. |
java.lang.Object[][] |
getAllFilters()
Returns a copy of the defined filters. |
java.util.Map |
getData(java.lang.String fileName)
Gets the attributes from a HTML data file. |
IWSTFilter |
getDefaultFilter()
Gets the defaultFilter for this WebStringTemplateGroup |
IWSTFilter |
getFilter(java.lang.String nameExtension)
Gets the filter associated with this extension (case sensitive). |
StringTemplate |
getInstanceOf(java.lang.String name)
Gets the instanceOf a WebStringTemplate with an empty data map.
|
WebStringTemplate |
getInstanceOf(java.lang.String templateName,
java.lang.String dataFileName)
Gets the instanceOf a WebStringTemplate loaded with data from a
HTML data file. |
boolean |
isMissingDataErrorPathReturn()
Gets the missingDataErrorPathReturn setting. |
static WebStringTemplate |
setAttributes(WebStringTemplate wst,
java.util.Map attributes)
Add these attributes to the top level of the data map of the template. |
IWSTFilter |
setDefaultFilter(IWSTFilter filter)
Set the default filter to use to filter strings passed to the template from the data map. |
void |
setErrorListener(StringTemplateErrorListener listener)
Sets the default errorListener of the WebStringTemplates in this group |
IWSTFilter |
setFilter(java.lang.String nameExtension,
IWSTFilter filter)
Set the filter associated with this name extension. |
void |
setMissingDataErrorPathReturn(boolean flag)
Sets the missingDataErrorPathReturn |
Methods inherited from class org.antlr.stringtemplate.StringTemplateGroup |
defineTemplate, error, error, getDelimiterStart, getDelimiterStop, getEmbeddedInstanceOf, getEmbeddedInstanceOf, getErrorListener, getFileNameFromTemplateName, getInstanceOf, getName, getRefreshInterval, getRootDir, getSuperGroup, getTemplate, getTemplateNameFromFileName, loadTemplate, loadTemplate, setName, setRefreshInterval, setRootDir, setSuperGroup, setSuperGroup, toString |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final java.util.logging.Logger logger
public static StringTemplateErrorListener DEFAULT_SERVLET_ERROR_LISTENER
Constructor Detail |
public WebStringTemplateGroup(java.lang.String name, java.lang.String rootDir)
The default filter is WSTXmlFilter and the name extension .plain is set to WSTPlainFiter and .xml is set to WSTXmlFilter
name
- the name of grouprootDir
- root dir to load templates from or null to use classpath.
Any trailing / or file.separator is stripped.public WebStringTemplateGroup(java.lang.String name, java.lang.String rootDir, java.lang.String delimiterStart, java.lang.String delimiterStop)
name
- name of grouprootDir
- root dir to load templates from or null to use
classpath. Any trailing / or file.separator is strippeddelimiterStart
- start delimiterdelimiterStop
- end delimiterMethod Detail |
public StringTemplate createStringTemplate(java.util.Map initialValues)
createStringTemplate
in class StringTemplateGroup
initialValues
- map of attribute values
public boolean isMissingDataErrorPathReturn()
public void setMissingDataErrorPathReturn(boolean flag)
flag
- true if missing data is to return an error path, else falsepublic IWSTFilter setDefaultFilter(IWSTFilter filter)
filter
- The defaultFilter
java.lang.NullPointerException
- if filter null.public IWSTFilter getDefaultFilter()
public IWSTFilter setFilter(java.lang.String nameExtension, IWSTFilter filter)
nameExtension
- The attribute extension to associate this
filter with. Any leading '.' is stripped.filter
- The filter to associate with this
extension, null to remove association.
java.lang.NullPointerException
- if filter null and nameExtension is "".
I.e. cannot remove the default filter.
java.lang.IllegalArgumentException
- if extension name is "comment" (ignoring
case).public IWSTFilter getFilter(java.lang.String nameExtension)
nameExtension
- Description of the Parameter
public java.lang.Object[][] getAllFilters()
public void setErrorListener(StringTemplateErrorListener listener)
setErrorListener
in class StringTemplateGroup
listener
- The errorListener value
java.lang.NullPointerException
- if listener is null.public java.util.Map getData(java.lang.String fileName)
If an error occures during loading, StringTemplateErrorListener.error(java.lang.String, java.lang.Throwable)
is called and the map set to null. Note:
the StringTemplateErrorListener.error(java.lang.String, java.lang.Throwable)
may throw an exception and
not return.
All attribute values are loaded as Strings. Each attribute is wrapped in a WSTPlainFilter to ensure it is delivered to the template exactly as loaded.
To generate HTML data, create a template and set its attribute data map and
then set the attribute wst.outputDataDefinition
to "true" in the template data map and call
template.toString() and save the resulting string in a file.
fileName
- the name of the HTML data file to load
(including extension.)
java.lang.NullPointerException
- if fileName is null.public StringTemplate getInstanceOf(java.lang.String name)
WebStringTemplate
with an empty data map.
getInstanceOf(name,(String)null)
; instead as this
returns a WebStringTemplate so a cast is not needed.
getInstanceOf
in class StringTemplateGroup
name
- the file name of the template (without the .st)
WebStringTemplate
objectpublic WebStringTemplate getInstanceOf(java.lang.String templateName, java.lang.String dataFileName)
WebStringTemplate
loaded with data from a
HTML data file.
templateName
- Name of template to load (without the trailing '.st')dataFileName
- the name of the data file to intialize this template
with (including extension) or null if no dataFile to be loaded.
WebStringTemplate
with attributes set to
those in the datafilepublic static WebStringTemplate setAttributes(WebStringTemplate wst, java.util.Map attributes)
wst
- the WebStringTemplateattributes
- the map containing the attributes to add
|
Forward Computing and Control Pty. Ltd. WebStringTemplate V1.5.0 2004/1/7 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |