Package org.stringtemplate.v4
Class STGroupDir
java.lang.Object
org.stringtemplate.v4.STGroup
org.stringtemplate.v4.STGroupDir
- Direct Known Subclasses:
STRawGroupDir
A directory or directory tree full of templates and/or group files.
We load files on-demand. Dir search path: current working dir then
CLASSPATH (as a resource). Do not look for templates outside of this dir
subtree (except via imports).
-
Field Summary
FieldsFields inherited from class org.stringtemplate.v4.STGroup
adaptors, DEFAULT_ERR_MGR, DEFAULT_KEY, defaultGroup, delimiterStartChar, delimiterStopChar, DICT_KEY, dictionaries, encoding, errMgr, GROUP_FILE_EXTENSION, imports, importsToClearOnUnload, iterateAcrossValues, NOT_FOUND_ST, renderers, TEMPLATE_FILE_EXTENSION, templates, trackCreationEvents, verbose
-
Constructor Summary
ConstructorsConstructorDescriptionSTGroupDir
(String dirName) STGroupDir
(String dirName, char delimiterStartChar, char delimiterStopChar) STGroupDir
(String dirName, String encoding) STGroupDir
(String dirName, String encoding, char delimiterStartChar, char delimiterStopChar) STGroupDir
(URL root) STGroupDir
(URL root, String encoding, char delimiterStartChar, char delimiterStopChar) -
Method Summary
Modifier and TypeMethodDescriptiongetName()
Return root dir if this is group dir; return dir containing group file if this is group file.void
importTemplates
(org.antlr.runtime.Token fileNameToken) Import template files, directories, and group files.protected CompiledST
Load a template from directory or group file.loadTemplateFile
(String prefix, String unqualifiedFileName) Load .st as relative file name relative to root byprefix
.normalizeURL
(URL url) verify there is no extra slash on the end of URLMethods inherited from class org.stringtemplate.v4.STGroup
compile, createSingleton, createStringTemplate, createStringTemplateInternally, createStringTemplateInternally, defineDictionary, defineRegion, defineTemplate, defineTemplate, defineTemplate, defineTemplateAlias, defineTemplateOrRegion, getAttributeRenderer, getEmbeddedInstanceOf, getImportedGroups, getInstanceOf, getListener, getMangledRegionName, getModelAdaptor, getTemplateNames, getUnMangledTemplateName, getURL, importTemplates, importTemplates, isDefined, isDictionary, isReservedCharacter, load, loadAbsoluteTemplateFile, loadGroupFile, loadTemplateFile, lookupImportedTemplate, lookupTemplate, rawDefineTemplate, rawGetDictionary, rawGetTemplate, registerModelAdaptor, registerRenderer, registerRenderer, setListener, show, toString, undefineTemplate, unload
-
Field Details
-
groupDirName
-
root
-
-
Constructor Details
-
STGroupDir
-
STGroupDir
-
STGroupDir
-
STGroupDir
-
STGroupDir
-
STGroupDir
-
-
Method Details
-
importTemplates
public void importTemplates(org.antlr.runtime.Token fileNameToken) Description copied from class:STGroup
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 templatet()
then we search fort()
in the subgroup first.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
STGroup.importTemplates(STGroup)
to import templates 'programmatically'.- Overrides:
importTemplates
in classSTGroup
-
load
Load a template from directory or group file. Group file is given precedence over directory with same name.name
is always fully-qualified. -
loadTemplateFile
Load .st as relative file name relative to root byprefix
. -
getName
-
getFileName
- Overrides:
getFileName
in classSTGroup
-
getRootDirURL
Description copied from class:STGroup
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.- Overrides:
getRootDirURL
in classSTGroup
-
normalizeURL
verify there is no extra slash on the end of URL
-