Package org.stringtemplate.v4
Class STGroupDir
- java.lang.Object
-
- org.stringtemplate.v4.STGroup
-
- org.stringtemplate.v4.STGroupDir
-
- Direct Known Subclasses:
STRawGroupDir
public class STGroupDir extends STGroup
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
Fields Modifier and Type Field Description String
groupDirName
URL
root
-
Fields 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
Constructors Constructor Description STGroupDir(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getFileName()
String
getName()
URL
getRootDirURL()
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(String name)
Load a template from directory or group file.CompiledST
loadTemplateFile(String prefix, String unqualifiedFileName)
Load .st as relative file name relative to root byprefix
.URL
normalizeURL(URL url)
verify there is no extra slash on the end of URL-
Methods 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
-
-
-
-
Constructor Detail
-
STGroupDir
public STGroupDir(String dirName)
-
STGroupDir
public STGroupDir(URL root)
-
STGroupDir
public STGroupDir(String dirName, char delimiterStartChar, char delimiterStopChar)
-
STGroupDir
public STGroupDir(String dirName, String encoding, char delimiterStartChar, char delimiterStopChar)
-
-
Method Detail
-
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
protected CompiledST load(String name)
Load a template from directory or group file. Group file is given precedence over directory with same name.name
is always fully-qualified.
-
loadTemplateFile
public CompiledST loadTemplateFile(String prefix, String unqualifiedFileName)
Load .st as relative file name relative to root byprefix
.
-
getFileName
public String getFileName()
- Overrides:
getFileName
in classSTGroup
-
getRootDirURL
public URL 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
-
-