Package org.stringtemplate.v4
Class STGroupFile
- java.lang.Object
-
- org.stringtemplate.v4.STGroup
-
- org.stringtemplate.v4.STGroupFile
-
public class STGroupFile extends STGroup
The internal representation of a single group file (which must end in ".stg"). If we fail to find a group file, look for it via the CLASSPATH as a resource. Templates are only looked up in this file or an import.
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanalreadyLoadedStringfileNameJust records how user "spelled" the file name they wanted to load.URLurlWhere to find the group file.-
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 STGroupFile(String fileName)Load a file relative to current directory or from root or via CLASSPATH.STGroupFile(String fileName, char delimiterStartChar, char delimiterStopChar)STGroupFile(String fullyQualifiedFileName, String encoding)STGroupFile(String fullyQualifiedFileName, String encoding, char delimiterStartChar, char delimiterStopChar)STGroupFile(URL url)Convenience ctorSTGroupFile(URL url, String encoding, char delimiterStartChar, char delimiterStopChar)Pass in a URL with the location of a group file.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetFileName()StringgetName()URLgetRootDirURL()Return root dir if this is group dir; return dir containing group file if this is group file.booleanisDefined(String name)Is this template defined in this group or from this group below? Names must be absolute, fully-qualified names like/a/b.booleanisDictionary(String name)voidload()Force a load if it makes sense for the group.protected CompiledSTload(String name)Load st from disk if directory or load whole group file if .stg file (then return just one template).Stringshow()voidunload()Unload all templates, dictionaries and import relationships, but leave renderers and adaptors.-
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, importTemplates, isReservedCharacter, loadAbsoluteTemplateFile, loadGroupFile, loadTemplateFile, lookupImportedTemplate, lookupTemplate, rawDefineTemplate, rawGetDictionary, rawGetTemplate, registerModelAdaptor, registerRenderer, registerRenderer, setListener, toString, undefineTemplate
-
-
-
-
Field Detail
-
fileName
public String fileName
Just records how user "spelled" the file name they wanted to load. The url is the key field here for loading content. If they use ctor with URL arg, this field is null.
-
url
public URL url
Where to find the group file. NonNull.
-
alreadyLoaded
protected boolean alreadyLoaded
-
-
Constructor Detail
-
STGroupFile
public STGroupFile(String fileName)
Load a file relative to current directory or from root or via CLASSPATH.
-
STGroupFile
public STGroupFile(String fileName, char delimiterStartChar, char delimiterStopChar)
-
STGroupFile
public STGroupFile(String fullyQualifiedFileName, String encoding, char delimiterStartChar, char delimiterStopChar)
-
STGroupFile
public STGroupFile(URL url, String encoding, char delimiterStartChar, char delimiterStopChar)
Pass in a URL with the location of a group file. E.g., STGroup g = new STGroupFile(loader.getResource("org/foo/templates/g.stg"), "UTF-8", '<', '>');
-
STGroupFile
public STGroupFile(URL url)
Convenience ctor
-
-
Method Detail
-
isDictionary
public boolean isDictionary(String name)
- Overrides:
isDictionaryin classSTGroup
-
isDefined
public boolean isDefined(String name)
Description copied from class:STGroupIs this template defined in this group or from this group below? Names must be absolute, fully-qualified names like/a/b.
-
unload
public void unload()
Description copied from class:STGroupUnload all templates, dictionaries and import relationships, but leave renderers and adaptors. This essentially forces the next call toSTGroup.getInstanceOf(java.lang.String)to reload templates. Callunload()on each group in theSTGroup.importslist, and remove all elements inSTGroup.importsToClearOnUnloadfromSTGroup.imports.
-
load
protected CompiledST load(String name)
Description copied from class:STGroupLoad st from disk if directory or load whole group file if .stg file (then return just one template).nameis fully-qualified.
-
load
public void load()
Description copied from class:STGroupForce a load if it makes sense for the group.
-
getFileName
public String getFileName()
- Overrides:
getFileNamein classSTGroup
-
getRootDirURL
public URL getRootDirURL()
Description copied from class:STGroupReturn 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:
getRootDirURLin classSTGroup
-
-