| Modifier and Type | Field and Description |
|---|---|
| protected Map | attributeRenderers
A Map<class,object> that allows people to register a renderer for a particular kind of object to be displayed for any template in this group. |
| protected boolean | |
| public static StringTemplateErrorListener | |
| protected static Class | defaultTemplateLexerClass
You can set the lexer once if you know all of your groups use the same separator. |
| pack-priv String | fileCharEncoding
How are the files encoded (ascii, UTF8, ...)? |
| private static StringTemplateGroupLoader | groupLoader
If a group file indicates it derives from a supergroup, how do we find it? |
| protected List | interfaces
Keep track of all interfaces implemented by this group. |
| protected long | |
| protected StringTemplateErrorListener | listener
Where to report errors. |
| protected Map | maps
Maps map names to HashMap objects. |
| protected String | name
What is the group name |
| protected static Map | nameToGroupMap
Track all groups by name; maps name to StringTemplateGroup |
| protected static Map | nameToInterfaceMap
Track all interfaces by name; maps name to StringTemplateGroupInterface |
| protected Set | noDebugStartStopStrings
The set of templates to ignore when dumping start/stop debug strings |
| protected static final StringTemplate | NOT_FOUND_ST
Used to indicate that the template doesn't exist. |
| protected int | refreshIntervalInSeconds
How long before tossing out all templates in seconds. |
| protected String | rootDir
Under what directory should I look for templates? |
| protected StringTemplateGroup | superGroup
Are we derived from another group? |
| protected Class | templateLexerClass
How to pull apart a template into chunks? |
| protected Map | templates
Maps template name to StringTemplate object |
| protected boolean | templatesDefinedInGroupFile
When templates are files on the disk, the refresh interval is used to know when to reload. |
| protected Class | userSpecifiedWriter
Normally AutoIndentWriter is used to filter output, but user can specify a new one. |
| Access | Constructor and Description |
|---|---|
| public | StringTemplateGroup(String name, String rootDir)
Create a group manager for some templates, all of which are at or below the indicated directory. |
| public | |
| public | StringTemplateGroup(String name)
Create a group manager for some templates, all of which are loaded as resources via the classloader. |
| public | |
| public | |
| public | |
| public | |
| public | |
| public | StringTemplateGroup(Reader r, Class<T> lexer, StringTemplateErrorListener errors, StringTemplateGroup superGroup)
Create a group from the input stream, but use a nondefault lexer to break the templates up into chunks. |
| Modifier and Type | Method and Description |
|---|---|
| protected void | |
| public StringTemplate | |
| public StringTemplate | defineImplicitRegionTemplate(StringTemplate enclosingTemplate, String name)
Track all references to regions <@foo()>. |
| public void | |
| public StringTemplate | defineRegionTemplate(String enclosingTemplateName, String regionName, String template, int type)
Track all references to regions <@foo>... |
| public StringTemplate | defineRegionTemplate(StringTemplate enclosingTemplate, String regionName, String template, int type)
Track all references to regions <@foo>... |
| public synchronized StringTemplate | defineTemplate(String name, String template)
Define an examplar template; precompiled and stored with no attributes. |
| public synchronized StringTemplate | |
| public void | |
| public void | emitDebugStartStopStrings(boolean emit)
Indicate whether ST should emit <templatename>...</templatename> |
| public void | |
| public void | |
| public void | |
| public void | |
| public AttributeRenderer | getAttributeRenderer(Class<T> attributeClassType)
What renderer is registered for this attributeClassType for this group? |
| public StringTemplate | |
| public StringTemplateErrorListener | |
| public String | |
| public String | getFileNameFromTemplateName(String templateName)
(public so that people can override behavior; not a general purpose method) |
| public String | |
| protected InputStreamReader | |
| protected StringTemplate | getInstanceOf(StringTemplate enclosingInstance, String name)
A support routine that gets an instance of name knowing which ST encloses it for error messages. |
| public StringTemplate | |
| public StringTemplate | getInstanceOf(String name, Map<K, V> attributes)
The primary means of getting an instance of a template from this group when you have a predefined set of attributes you want to use. |
| public String | getMangledRegionName(String enclosingTemplateName, String name)
The "foo" of t() ::= "<@foo()>" is mangled to "region#t#foo" |
| public Map | |
| public String | |
| public int | |
| public String | |
| public StringTemplateWriter | getStringTemplateWriter(Writer w)
return an instance of a StringTemplateWriter that spits output to w. |
| public StringTemplateGroup | |
| public synchronized StringTemplate | |
| public Class | |
| public String | getTemplateNameFromFileName(String fileName)
Convert a filename relativePath/name.st to relativePath/name. |
| public synchronized Set | |
| public String | |
| public void | |
| public void | implementInterface(String interfaceName)
Indicate that this group implements this interface; load if necessary if not in the nameToInterfaceMap. |
| public boolean | |
| public synchronized boolean | |
| public static StringTemplateGroup | |
| public static StringTemplateGroup | |
| public static StringTemplateGroup | |
| public static StringTemplateGroupInterface | |
| protected StringTemplate | |
| protected StringTemplate | |
| protected StringTemplate | loadTemplateFromBeneathRootDirOrCLASSPATH(String fileName)
Load a template whose name is derived from the template filename. |
| public synchronized StringTemplate | lookupTemplate(StringTemplate enclosingInstance, String name)
Get the template called 'name' from the group. |
| public StringTemplate | |
| protected void | |
| public static void | |
| public static void | |
| public void | registerRenderer(Class<T> attributeClassType, Object renderer)
Register a renderer for all objects of a particular type for all templates in this group. |
| public void | setAttributeRenderers(Map<K, V> renderers)
Specify a complete map of what object classes should map to which renderer objects for every template in this group (that doesn't override it per template). |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | setStringTemplateWriter(Class<T> c)
Specify a StringTemplateWriter implementing class to use for filtering output |
| public void | |
| public void | |
| public String | |
| public String | |
| protected void |
| attributeRenderers | back to summary |
|---|---|
| protected Map<K, V> attributeRenderers A Map | |
| debugTemplateOutput | back to summary |
|---|---|
| protected boolean debugTemplateOutput | |
| DEFAULT_ERROR_LISTENER | back to summary |
|---|---|
| public static StringTemplateErrorListener DEFAULT_ERROR_LISTENER | |
| defaultTemplateLexerClass | back to summary |
|---|---|
| protected static Class<T> defaultTemplateLexerClass You can set the lexer once if you know all of your groups use the same separator. If the instance has templateLexerClass set then it is used as an override. | |
| fileCharEncoding | back to summary |
|---|---|
| pack-priv String fileCharEncoding How are the files encoded (ascii, UTF8, ...)? You might want to read UTF8 for example on an ascii machine. | |
| groupLoader | back to summary |
|---|---|
| private static StringTemplateGroupLoader groupLoader If a group file indicates it derives from a supergroup, how do we find it? Shall we make it so the initial StringTemplateGroup file can be loaded via this loader? Right now we pass a Reader to ctor to distinguish from the other variety. | |
| interfaces | back to summary |
|---|---|
| protected List<E> interfaces Keep track of all interfaces implemented by this group. | |
| lastCheckedDisk | back to summary |
|---|---|
| protected long lastCheckedDisk | |
| listener | back to summary |
|---|---|
| protected StringTemplateErrorListener listener Where to report errors. All string templates in this group use this error handler by default. | |
| maps | back to summary |
|---|---|
| protected Map<K, V> maps Maps map names to HashMap objects. This is the list of maps defined by the user like typeInitMap ::= ["int":"0"] | |
| name | back to summary |
|---|---|
| protected String name What is the group name | |
| nameToGroupMap | back to summary |
|---|---|
| protected static Map<K, V> nameToGroupMap Track all groups by name; maps name to StringTemplateGroup | |
| nameToInterfaceMap | back to summary |
|---|---|
| protected static Map<K, V> nameToInterfaceMap Track all interfaces by name; maps name to StringTemplateGroupInterface | |
| noDebugStartStopStrings | back to summary |
|---|---|
| protected Set<E> noDebugStartStopStrings The set of templates to ignore when dumping start/stop debug strings | |
| NOT_FOUND_ST | back to summary |
|---|---|
| protected static final StringTemplate NOT_FOUND_ST Used to indicate that the template doesn't exist. We don't have to check disk for it; we know it's not there. | |
| refreshIntervalInSeconds | back to summary |
|---|---|
| protected int refreshIntervalInSeconds How long before tossing out all templates in seconds. | |
| rootDir | back to summary |
|---|---|
| protected String rootDir Under what directory should I look for templates? If null, to look into the CLASSPATH for templates as resources. | |
| superGroup | back to summary |
|---|---|
| protected StringTemplateGroup superGroup Are we derived from another group? Templates not found in this group will be searched for in the superGroup recursively. | |
| templateLexerClass | back to summary |
|---|---|
| protected Class<T> templateLexerClass How to pull apart a template into chunks? | |
| templates | back to summary |
|---|---|
| protected Map<K, V> templates Maps template name to StringTemplate object | |
| templatesDefinedInGroupFile | back to summary |
|---|---|
| protected boolean templatesDefinedInGroupFile When templates are files on the disk, the refresh interval is used to know when to reload. When a Reader is passed to the ctor, it is a stream full of template definitions. The former is used for web development, but the latter is most likely used for source code generation for translators; a refresh is unlikely. Anyway, I decided to track the source of templates in case such info is useful in other situations than just turning off refresh interval. I just found another: don't ever look on the disk for individual templates if this group is a group file...immediately look into any super group. If not in the super group, report no such template. | |
| userSpecifiedWriter | back to summary |
|---|---|
| protected Class<T> userSpecifiedWriter Normally AutoIndentWriter is used to filter output, but user can specify a new one. | |
| StringTemplateGroup | back to summary |
|---|---|
| public StringTemplateGroup(String name, String rootDir) Create a group manager for some templates, all of which are at or below the indicated directory. | |
| StringTemplateGroup | back to summary |
|---|---|
| public StringTemplateGroup(String name, String rootDir, Class<T> lexer) | |
| StringTemplateGroup | back to summary |
|---|---|
| public StringTemplateGroup(String name) Create a group manager for some templates, all of which are loaded as resources via the classloader. | |
| StringTemplateGroup | back to summary |
|---|---|
| public StringTemplateGroup(String name, Class<T> lexer) | |
| StringTemplateGroup | back to summary |
|---|---|
| public StringTemplateGroup(Reader r) Create a group from the template group defined by a input stream. The name is pulled from the file. The format is group name; t1(args) ::= "..." t2() ::= << >> ... | |
| StringTemplateGroup | back to summary |
|---|---|
| public StringTemplateGroup(Reader r, StringTemplateErrorListener errors) | |
| StringTemplateGroup | back to summary |
|---|---|
| public StringTemplateGroup(Reader r, Class<T> lexer) | |
| StringTemplateGroup | back to summary |
|---|---|
| public StringTemplateGroup(Reader r, Class<T> lexer, StringTemplateErrorListener errors) | |
| StringTemplateGroup | back to summary |
|---|---|
| public StringTemplateGroup(Reader r, Class<T> lexer, StringTemplateErrorListener errors, StringTemplateGroup superGroup) Create a group from the input stream, but use a nondefault lexer to break the templates up into chunks. This is usefor changing the delimiter from the default $...$ to <...>, for example. | |
| checkRefreshInterval | back to summary |
|---|---|
| protected void checkRefreshInterval() | |
| createStringTemplate | back to summary |
|---|---|
| public StringTemplate createStringTemplate() StringTemplate object factory; each group can have its own. | |
| defineImplicitRegionTemplate | back to summary |
|---|---|
| public StringTemplate defineImplicitRegionTemplate(StringTemplate enclosingTemplate, String name) Track all references to regions <@foo()>. We automatically define as @enclosingtemplate.foo() ::= "" You cannot set these manually in the same group; you have to subgroup to override. | |
| defineMap | back to summary |
|---|---|
| public void defineMap(String name, Map<K, V> mapping) Define a map for this group; not thread safe...do not keep adding these while you reference them. | |
| defineRegionTemplate | back to summary |
|---|---|
| public StringTemplate defineRegionTemplate(String enclosingTemplateName, String regionName, String template, int type) Track all references to regions <@foo>...<@end> or <@foo()>. | |
| defineRegionTemplate | back to summary |
|---|---|
| public StringTemplate defineRegionTemplate(StringTemplate enclosingTemplate, String regionName, String template, int type) Track all references to regions <@foo>...<@end> or <@foo()>. | |
| defineTemplate | back to summary |
|---|---|
| public synchronized StringTemplate defineTemplate(String name, String template) Define an examplar template; precompiled and stored with no attributes. Remove any previous definition. | |
| defineTemplateAlias | back to summary |
|---|---|
| public synchronized StringTemplate defineTemplateAlias(String name, String target) Make name and alias for target. Replace any previous def of name | |
| doNotEmitDebugStringsForTemplate | back to summary |
|---|---|
| public void doNotEmitDebugStringsForTemplate(String templateName) | |
| emitDebugStartStopStrings | back to summary |
|---|---|
| public void emitDebugStartStopStrings(boolean emit) Indicate whether ST should emit | |
| emitTemplateStartDebugString | back to summary |
|---|---|
| public void emitTemplateStartDebugString(StringTemplate st, StringTemplateWriter out) throws IOException | |
| emitTemplateStopDebugString | back to summary |
|---|---|
| public void emitTemplateStopDebugString(StringTemplate st, StringTemplateWriter out) throws IOException | |
| error | back to summary |
|---|---|
| public void error(String msg) | |
| error | back to summary |
|---|---|
| public void error(String msg, Exception e) | |
| getAttributeRenderer | back to summary |
|---|---|
| public AttributeRenderer getAttributeRenderer(Class<T> attributeClassType) What renderer is registered for this attributeClassType for this group? If not found, as superGroup if it has one. | |
| getEmbeddedInstanceOf | back to summary |
|---|---|
| public StringTemplate getEmbeddedInstanceOf(StringTemplate enclosingInstance, String name) throws IllegalArgumentException | |
| getErrorListener | back to summary |
|---|---|
| public StringTemplateErrorListener getErrorListener() | |
| getFileCharEncoding | back to summary |
|---|---|
| public String getFileCharEncoding() | |
| getFileNameFromTemplateName | back to summary |
|---|---|
| public String getFileNameFromTemplateName(String templateName) (public so that people can override behavior; not a general purpose method) | |
| getGroupHierarchyStackString | back to summary |
|---|---|
| public String getGroupHierarchyStackString() Walk up group hierarchy and show top down to this group | |
| getInputStreamReader | back to summary |
|---|---|
| protected InputStreamReader getInputStreamReader(InputStream in) | |
| getInstanceOf | back to summary |
|---|---|
| protected StringTemplate getInstanceOf(StringTemplate enclosingInstance, String name) throws IllegalArgumentException A support routine that gets an instance of name knowing which ST encloses it for error messages. | |
| getInstanceOf | back to summary |
|---|---|
| public StringTemplate getInstanceOf(String name) The primary means of getting an instance of a template from this group. | |
| getInstanceOf | back to summary |
|---|---|
| public StringTemplate getInstanceOf(String name, Map<K, V> attributes) The primary means of getting an instance of a template from this group when you have a predefined set of attributes you want to use. | |
| getMangledRegionName | back to summary |
|---|---|
| public String getMangledRegionName(String enclosingTemplateName, String name) The "foo" of t() ::= "<@foo()>" is mangled to "region#t#foo" | |
| getMap | back to summary |
|---|---|
| public Map | |
| getName | back to summary |
|---|---|
| public String getName() | |
| getRefreshInterval | back to summary |
|---|---|
| public int getRefreshInterval() | |
| getRootDir | back to summary |
|---|---|
| public String getRootDir() | |
| getStringTemplateWriter | back to summary |
|---|---|
| public StringTemplateWriter getStringTemplateWriter(Writer w) return an instance of a StringTemplateWriter that spits output to w. If a writer is specified, use it instead of the default. | |
| getSuperGroup | back to summary |
|---|---|
| public StringTemplateGroup getSuperGroup() | |
| getTemplateDefinition | back to summary |
|---|---|
| public synchronized StringTemplate getTemplateDefinition(String name) Get the ST for 'name' in this group only | |
| getTemplateLexerClass | back to summary |
|---|---|
| public Class What lexer class to use to break up templates. If not lexer set for this group, use static default. | |
| getTemplateNameFromFileName | back to summary |
|---|---|
| public String getTemplateNameFromFileName(String fileName) Convert a filename relativePath/name.st to relativePath/name. (public so that people can override behavior; not a general purpose method) | |
| getTemplateNames | back to summary |
|---|---|
| public synchronized Set | |
| getUnMangledTemplateName | back to summary |
|---|---|
| public String getUnMangledTemplateName(String mangledName) Return "t" from "region__t__foo" | |
| implementInterface | back to summary |
|---|---|
| public void implementInterface(StringTemplateGroupInterface I) Just track the new interface; check later. Allows dups, but no biggie. | |
| implementInterface | back to summary |
|---|---|
| public void implementInterface(String interfaceName) Indicate that this group implements this interface; load if necessary if not in the nameToInterfaceMap. | |
| isDefined | back to summary |
|---|---|
| public boolean isDefined(String name) Is there *any* definition for template 'name' in this template or above it in the group hierarchy? | |
| isDefinedInThisGroup | back to summary |
|---|---|
| public synchronized boolean isDefinedInThisGroup(String name) | |
| loadGroup | back to summary |
|---|---|
| public static StringTemplateGroup loadGroup(String name) | |
| loadGroup | back to summary |
|---|---|
| public static StringTemplateGroup loadGroup(String name, StringTemplateGroup superGroup) | |
| loadGroup | back to summary |
|---|---|
| public static StringTemplateGroup loadGroup(String name, Class<T> lexer, StringTemplateGroup superGroup) | |
| loadInterface | back to summary |
|---|---|
| public static StringTemplateGroupInterface loadInterface(String name) | |
| loadTemplate | back to summary |
|---|---|
| protected StringTemplate loadTemplate(String name, BufferedReader r) throws IOException | |
| loadTemplate | back to summary |
|---|---|
| protected StringTemplate loadTemplate(String name, String fileName) | |
| loadTemplateFromBeneathRootDirOrCLASSPATH | back to summary |
|---|---|
| protected StringTemplate loadTemplateFromBeneathRootDirOrCLASSPATH(String fileName) Load a template whose name is derived from the template filename. If there is no root directory, try to load the template from the classpath. If there is a rootDir, try to load the file from there. | |
| lookupTemplate | back to summary |
|---|---|
| public synchronized StringTemplate lookupTemplate(StringTemplate enclosingInstance, String name) throws IllegalArgumentException Get the template called 'name' from the group. If not found, attempt to load. If not found on disk, then try the superGroup if any. If not even there, then record that it's NOT_FOUND so we don't waste time looking again later. If we've gone past refresh interval, flush and look again. If I find a template in a super group, copy an instance down here | |
| lookupTemplate | back to summary |
|---|---|
| public StringTemplate lookupTemplate(String name) | |
| parseGroup | back to summary |
|---|---|
| protected void parseGroup(Reader r) | |
| registerDefaultLexer | back to summary |
|---|---|
| public static void registerDefaultLexer(Class<T> lexerClass) | |
| registerGroupLoader | back to summary |
|---|---|
| public static void registerGroupLoader(StringTemplateGroupLoader loader) | |
| registerRenderer | back to summary |
|---|---|
| public void registerRenderer(Class<T> attributeClassType, Object renderer) Register a renderer for all objects of a particular type for all templates in this group. | |
| setAttributeRenderers | back to summary |
|---|---|
| public void setAttributeRenderers(Map<K, V> renderers) Specify a complete map of what object classes should map to which renderer objects for every template in this group (that doesn't override it per template). | |
| setErrorListener | back to summary |
|---|---|
| public void setErrorListener(StringTemplateErrorListener listener) | |
| setFileCharEncoding | back to summary |
|---|---|
| public void setFileCharEncoding(String fileCharEncoding) | |
| setName | back to summary |
|---|---|
| public void setName(String name) | |
| setRefreshInterval | back to summary |
|---|---|
| public void setRefreshInterval(int refreshInterval) How often to refresh all templates from disk. This is a crude mechanism at the moment--just tosses everything out at this frequency. Set interval to 0 to refresh constantly (no caching). Set interval to a huge number like MAX_INT to have no refreshing at all (DEFAULT); it will cache stuff. | |
| setRootDir | back to summary |
|---|---|
| public void setRootDir(String rootDir) | |
| setStringTemplateWriter | back to summary |
|---|---|
| public void setStringTemplateWriter(Class<T> c) Specify a StringTemplateWriter implementing class to use for filtering output | |
| setSuperGroup | back to summary |
|---|---|
| public void setSuperGroup(StringTemplateGroup superGroup) | |
| setSuperGroup | back to summary |
|---|---|
| public void setSuperGroup(String superGroupName) Called by group parser when ": supergroupname" is found. This method forces the supergroup's lexer to be same as lexer for this (sub) group. | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
| |
| toString | back to summary |
|---|---|
| public String toString(boolean showTemplatePatterns) | |
| verifyInterfaceImplementations | back to summary |
|---|---|
| protected void verifyInterfaceImplementations() verify that this group satisfies its interfaces | |