.st template files and/or group files.
Individual template files contain formal template definitions. In a sense,
it's like a single group file broken into multiple files, one for each template.
ST v3 had just the pure template inside, not the template name and header.
Name inside must match filename (minus suffix).
| Modifier and Type | Field and Description |
|---|---|
| protected final Map | adaptors
A dictionary that allows people to register a model adaptor for a particular kind of object (subclass or implementation). |
| public static final ErrorManager | |
| public static final String | |
| public static STGroup | |
| public char | |
| public char | |
| public static final String | DICT_KEY
When we use key as a value in a dictionary, this is how we signify. |
| protected Map | dictionaries
Maps dictionary names to |
| public String | encoding
The encoding to use for loading files. |
| public ErrorManager | errMgr
The |
| public static final String | |
| protected final List | imports
Every group can import templates/dictionaries from other groups. |
| protected final List | |
| public boolean | iterateAcrossValues
v3 compatibility; used to iterate across |
| protected static final CompiledST | NOT_FOUND_ST
Used to indicate that the template doesn't exist. |
| protected Map | renderers
A dictionary that allows people to register a renderer for a particular kind of object for any template evaluated relative to this group. |
| private static final boolean[] | |
| public static final String | |
| protected Map | templates
Maps template name to |
| public static boolean | trackCreationEvents
For debugging with |
| public static boolean | verbose
Watch loading of groups and templates. |
| Access | Constructor and Description |
|---|---|
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public CompiledST | |
| public ST | |
| public ST | |
| public ST | createStringTemplateInternally(CompiledST impl)
Differentiate so we can avoid having creation events for regions, map operations, and other implicit "new ST" events during rendering. |
| public ST | |
| public void | |
| public CompiledST | |
| public CompiledST | |
| public CompiledST | |
| public CompiledST | defineTemplate(String fullyQualifiedTemplateName, Token nameT, List<FormalArgument> args, String template, Token templateToken)
|
| public CompiledST | |
| public void | defineTemplateOrRegion(String fullyQualifiedTemplateName, String regionSurroundingTemplateName, Token templateToken, String template, Token nameToken, List<FormalArgument> args)
|
| public <T> AttributeRenderer | |
| protected ST | |
| public String | |
| public List | |
| public ST | |
| public STErrorListener | |
| public static String | getMangledRegionName(String enclosingTemplateName, String name)
The |
| public <T> ModelAdaptor | |
| public String | |
| public URL | getRootDirURL()
Return root dir if this is group dir; return dir containing group file if this is group file. |
| public Set | |
| public static String | |
| public URL | |
| public void | |
| public void | |
| protected void | |
| public boolean | |
| public boolean | |
| public static boolean | Returns: true if the character is reserved by the StringTemplate
language; otherwise, false if the character may be used as a
delimiter.The character c)Determines if a specified character may be used as a user-specified delimiter. |
| protected CompiledST | |
| public void | |
| public CompiledST | loadAbsoluteTemplateFile(String fileName)
Load template file into this group using absolute |
| public void | loadGroupFile(String prefix, String fileName)
Load a group file with full path |
| public CompiledST | loadTemplateFile(String prefix, String unqualifiedFileName, CharStream templateStream)
Load template stream into this group. |
| protected CompiledST | |
| public CompiledST | |
| public void | |
| public Map | |
| public CompiledST | |
| public <T> void | registerModelAdaptor(Class<T> attributeType, ModelAdaptor<? super T> adaptor)
Add an adaptor for a kind of object so ST knows how to pull properties from them. |
| public <T> void | registerRenderer(Class<T> attributeType, AttributeRenderer<? super T> r)
Register a renderer for all objects of a particular "kind" for all templates evaluated relative to this group. |
| public <T> void | |
| public void | |
| public String | |
| public String | |
| public void | |
| public synchronized void | unload()
Unload all templates, dictionaries and import relationships, but leave renderers and adaptors. |
| adaptors | back to summary |
|---|---|
| protected final Map<Class<?>, ModelAdaptor<?>> adaptors A dictionary that allows people to register a model adaptor for a particular kind of object (subclass or implementation). Applies for any template evaluated relative to this group.
ST initializes with model adaptors that know how to pull
properties out of The last one you register gets priority; do least to most specific. | |
| DEFAULT_ERR_MGR | back to summary |
|---|---|
| public static final ErrorManager DEFAULT_ERR_MGR | |
| DEFAULT_KEY | back to summary |
|---|---|
| public static final String DEFAULT_KEY | |
| defaultGroup | back to summary |
|---|---|
| public static STGroup defaultGroup | |
| delimiterStartChar | back to summary |
|---|---|
| public char delimiterStartChar | |
| delimiterStopChar | back to summary |
|---|---|
| public char delimiterStopChar | |
| DICT_KEY | back to summary |
|---|---|
| public static final String DICT_KEY When we use key as a value in a dictionary, this is how we signify. | |
| dictionaries | back to summary |
|---|---|
| protected Map<String, Map<String, Object>> dictionaries Maps dictionary names to | |
| encoding | back to summary |
|---|---|
| public String encoding The encoding to use for loading files. Defaults to UTF-8. | |
| errMgr | back to summary |
|---|---|
| public ErrorManager errMgr The | |
| GROUP_FILE_EXTENSION | back to summary |
|---|---|
| public static final String GROUP_FILE_EXTENSION | |
| imports | back to summary |
|---|---|
| protected final List<STGroup> imports Every group can import templates/dictionaries from other groups.
The list must be synchronized (see | |
| importsToClearOnUnload | back to summary |
|---|---|
| protected final List<STGroup> importsToClearOnUnload | |
| iterateAcrossValues | back to summary |
|---|---|
| public boolean iterateAcrossValues v3 compatibility; used to iterate across | |
| NOT_FOUND_ST | back to summary |
|---|---|
| protected static final CompiledST NOT_FOUND_ST Used to indicate that the template doesn't exist. Prevents duplicate group file loads and unnecessary file checks. | |
| renderers | back to summary |
|---|---|
| protected Map<Class<?>, AttributeRenderer<?>> renderers A dictionary that allows people to register a renderer for
a particular kind of object for any template evaluated relative to this
group. For example, a date should be formatted differently depending
on the locale. You can set Order of addition is recorded and matters. If more than one renderer works for an object, the first registered has priority.
Renderer associated with type t.isAssignableFrom(o.getClass()) // would assignment t = o work?So it works if o is subclass or implements t.
This structure is synchronized. | |
| RESERVED_CHARACTERS | back to summary |
|---|---|
| private static final boolean[] RESERVED_CHARACTERS | |
| TEMPLATE_FILE_EXTENSION | back to summary |
|---|---|
| public static final String TEMPLATE_FILE_EXTENSION | |
| templates | back to summary |
|---|---|
| protected Map<String, CompiledST> templates Maps template name to | |
| trackCreationEvents | back to summary |
|---|---|
| public static boolean trackCreationEvents For debugging with | |
| verbose | back to summary |
|---|---|
| public static boolean verbose Watch loading of groups and templates. | |
| STGroup | back to summary |
|---|---|
| public STGroup() | |
| STGroup | back to summary |
|---|---|
| public STGroup(char delimiterStartChar, char delimiterStopChar) | |
| compile | back to summary |
|---|---|
| public CompiledST compile(String srcName, String name, List<FormalArgument> args, String template, Token templateToken) Compile a template. | |
| createSingleton | back to summary |
|---|---|
| public ST createSingleton(Token templateToken) Create singleton template for use with dictionary values. | |
| createStringTemplate | back to summary |
|---|---|
| public ST createStringTemplate(CompiledST impl) | |
| createStringTemplateInternally | back to summary |
|---|---|
| public ST createStringTemplateInternally(CompiledST impl) Differentiate so we can avoid having creation events for regions, map operations, and other implicit "new ST" events during rendering. | |
| createStringTemplateInternally | back to summary |
|---|---|
| public ST createStringTemplateInternally(ST proto) | |
| defineDictionary | back to summary |
|---|---|
| public void defineDictionary(String name, Map<String, Object> mapping) Define a map for this group. Not thread safe...do not keep adding these while you reference them. | |
| defineRegion | back to summary |
|---|---|
| public CompiledST defineRegion(String enclosingTemplateName, Token regionT, String template, Token templateToken) | |
| defineTemplate | back to summary |
|---|---|
| public CompiledST defineTemplate(String templateName, String template) for testing | |
| defineTemplate | back to summary |
|---|---|
| public CompiledST defineTemplate(String name, String argsS, String template) for testing | |
| defineTemplate | back to summary |
|---|---|
| public CompiledST defineTemplate(String fullyQualifiedTemplateName, Token nameT, List<FormalArgument> args, String template, Token templateToken) | |
| defineTemplateAlias | back to summary |
|---|---|
| public CompiledST defineTemplateAlias(Token aliasT, Token targetT) Make name and alias for target. Replace any previous definition of name. | |
| defineTemplateOrRegion | back to summary |
|---|---|
| public void defineTemplateOrRegion(String fullyQualifiedTemplateName, String regionSurroundingTemplateName, Token templateToken, String template, Token nameToken, List<FormalArgument> args) | |
| getAttributeRenderer | back to summary |
|---|---|
| public <T> AttributeRenderer Get renderer for class
For non-imported groups and object-to-render of class | |
| getEmbeddedInstanceOf | back to summary |
|---|---|
| protected ST getEmbeddedInstanceOf(Interpreter interp, InstanceScope scope, String name) | |
| getFileName | back to summary |
|---|---|
| public String getFileName() | |
| getImportedGroups | back to summary |
|---|---|
| public List | |
| getInstanceOf | back to summary |
|---|---|
| public ST getInstanceOf(String name) The primary means of getting an instance of a template from this
group. Names must be absolute, fully-qualified names like | |
| getListener | back to summary |
|---|---|
| public STErrorListener getListener() | |
| getMangledRegionName | back to summary |
|---|---|
| public static String getMangledRegionName(String enclosingTemplateName, String name) The | |
| getModelAdaptor | back to summary |
|---|---|
| public <T> ModelAdaptor | |
| getName | back to summary |
|---|---|
| public String getName() | |
| getRootDirURL | back to summary |
|---|---|
| public URL getRootDirURL() Return root dir if this is group dir; return dir containing group file if this is group file. This is derived from original incoming dir or filename. If it was absolute, this should come back as full absolute path. If only a URL is available, return URL of one dir up. | |
| getTemplateNames | back to summary |
|---|---|
| public Set | |
| getUnMangledTemplateName | back to summary |
|---|---|
| public static String getUnMangledTemplateName(String mangledName) Return | |
| getURL | back to summary |
|---|---|
| public URL getURL(String fileName) | |
| importTemplates | back to summary |
|---|---|
| public void importTemplates(STGroup g) Make this group import templates/dictionaries from
On unload imported templates are unloaded but stay in the | |
| importTemplates | back to summary |
|---|---|
| public void importTemplates(Token fileNameToken) Import template files, directories, and group files.
Priority is given to templates defined in the current group;
this, in effect, provides inheritance. Polymorphism is in effect so
that if an inherited template references template Templates are loaded on-demand from import dirs. Imported groups are loaded on-demand when searching for a template. The listener of this group is passed to the import group so errors found while loading imported element are sent to listener of this group. On unload imported templates are unloaded and removed from the imports list.
This method is called when processing import statements specified in
group files. Use | |
| importTemplates | back to summary |
|---|---|
| protected void importTemplates(STGroup g, boolean clearOnUnload) | |
| isDefined | back to summary |
|---|---|
| public boolean isDefined(String name) Is this template defined in this group or from this group below?
Names must be absolute, fully-qualified names like | |
| isDictionary | back to summary |
|---|---|
| public boolean isDictionary(String name) | |
| isReservedCharacter | back to summary |
|---|---|
| public static boolean isReservedCharacter(char c) Determines if a specified character may be used as a user-specified delimiter.
| |
| load | back to summary |
|---|---|
| protected CompiledST load(String name) Load st from disk if directory or load whole group file if .stg file (then
return just one template). | |
| load | back to summary |
|---|---|
| public void load() Force a load if it makes sense for the group. | |
| loadAbsoluteTemplateFile | back to summary |
|---|---|
| public CompiledST loadAbsoluteTemplateFile(String fileName) Load template file into this group using absolute | |
| loadGroupFile | back to summary |
|---|---|
| public void loadGroupFile(String prefix, String fileName) Load a group file with full path | |
| loadTemplateFile | back to summary |
|---|---|
| public CompiledST loadTemplateFile(String prefix, String unqualifiedFileName, CharStream templateStream) Load template stream into this group. | |
| lookupImportedTemplate | back to summary |
|---|---|
| protected CompiledST lookupImportedTemplate(String name) | |
| lookupTemplate | back to summary |
|---|---|
| public CompiledST lookupTemplate(String name) Look up a fully-qualified name. | |
| rawDefineTemplate | back to summary |
|---|---|
| public void rawDefineTemplate(String name, CompiledST code, Token defT) | |
| rawGetDictionary | back to summary |
|---|---|
| public Map | |
| rawGetTemplate | back to summary |
|---|---|
| public CompiledST rawGetTemplate(String name) | |
| registerModelAdaptor | back to summary |
|---|---|
| public <T> void registerModelAdaptor(Class<T> attributeType, ModelAdaptor<? super T> adaptor) Add an adaptor for a kind of object so ST knows how to pull properties
from them. Add adaptors in increasing order of specificity. ST adds
If an adaptor for type
This must invalidate cache entries, so set your adaptors up before
calling | |
| registerRenderer | back to summary |
|---|---|
| public <T> void registerRenderer(Class<T> attributeType, AttributeRenderer<? super T> r) Register a renderer for all objects of a particular "kind" for all
templates evaluated relative to this group. Use | |
| registerRenderer | back to summary |
|---|---|
| public <T> void registerRenderer(Class<T> attributeType, AttributeRenderer<? super T> r, boolean recursive) | |
| setListener | back to summary |
|---|---|
| public void setListener(STErrorListener listener) | |
| show | back to summary |
|---|---|
| public String show() | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object. | |
| undefineTemplate | back to summary |
|---|---|
| public void undefineTemplate(String name) | |
| unload | back to summary |
|---|---|
| public synchronized void unload() Unload all templates, dictionaries and import relationships, but leave
renderers and adaptors. This essentially forces the next call to
| |