Top Description Fields Constructors Methods
org.stringtemplate.v4

public Class STGroupDir

extends STGroup
Class Inheritance
Known Direct Subclasses
org.stringtemplate.v4.STRawGroupDir
Imports
org.antlr.runtime.ANTLRInputStream, .Token, org.stringtemplate.v4.compiler.CompiledST, .STException, org.stringtemplate.v4.misc.ErrorType, .Misc, java.io.File, .IOException, .InputStream, java.net.MalformedURLException, .URI, .URISyntaxException, .URL

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

Modifier and TypeField and Description
public String
public URL
Inherited from org.stringtemplate.v4.STGroup:
adaptorsDEFAULT_ERR_MGRDEFAULT_KEYdefaultGroupdelimiterStartChardelimiterStopCharDICT_KEYdictionariesencodingerrMgrGROUP_FILE_EXTENSIONimportsimportsToClearOnUnloaditerateAcrossValuesNOT_FOUND_STrenderersTEMPLATE_FILE_EXTENSIONtemplatestrackCreationEventsverbose

Constructor Summary

AccessConstructor and Description
public
STGroupDir(String dirName)

public
public
STGroupDir(String dirName, char delimiterStartChar, char delimiterStopChar)

public
STGroupDir(String dirName, String encoding)

public
STGroupDir(String dirName, String encoding, char delimiterStartChar, char delimiterStopChar)

public
STGroupDir(URL root, String encoding, char delimiterStartChar, char delimiterStopChar)

Method Summary

Modifier and TypeMethod and Description
public String
public String
public URL
getRootDirURL()

Overrides org.stringtemplate.v4.STGroup.getRootDirURL.

Return root dir if this is group dir; return dir containing group file if this is group file.
public void
importTemplates(Token fileNameToken)

Overrides org.stringtemplate.v4.STGroup.importTemplates.

Import template files, directories, and group files.
protected CompiledST
load(String name)

Overrides org.stringtemplate.v4.STGroup.load.

Load a template from directory or group file.
public CompiledST
loadTemplateFile(String prefix, String unqualifiedFileName)

Load .st as relative file name relative to root by prefix.

public URL
normalizeURL(URL url)

verify there is no extra slash on the end of URL

Inherited from org.stringtemplate.v4.STGroup:
compilecreateSingletoncreateStringTemplatecreateStringTemplateInternallycreateStringTemplateInternallydefineDictionarydefineRegiondefineTemplatedefineTemplatedefineTemplatedefineTemplateAliasdefineTemplateOrRegiongetAttributeRenderergetEmbeddedInstanceOfgetImportedGroupsgetInstanceOfgetListenergetMangledRegionNamegetModelAdaptorgetTemplateNamesgetUnMangledTemplateNamegetURLimportTemplatesimportTemplatesisDefinedisDictionaryisReservedCharacterloadloadAbsoluteTemplateFileloadGroupFileloadTemplateFilelookupImportedTemplatelookupTemplaterawDefineTemplaterawGetDictionaryrawGetTemplateregisterModelAdaptorregisterRendererregisterRenderersetListenershowtoStringundefineTemplateunload

Field Detail

groupDirNameback to summary
public String groupDirName
rootback to summary
public URL root

Constructor Detail

STGroupDirback to summary
public STGroupDir(String dirName)
STGroupDirback to summary
public STGroupDir(URL root)
STGroupDirback to summary
public STGroupDir(String dirName, char delimiterStartChar, char delimiterStopChar)
STGroupDirback to summary
public STGroupDir(String dirName, String encoding)
STGroupDirback to summary
public STGroupDir(String dirName, String encoding, char delimiterStartChar, char delimiterStopChar)
STGroupDirback to summary
public STGroupDir(URL root, String encoding, char delimiterStartChar, char delimiterStopChar)

Method Detail

getFileNameback to summary
public String getFileName()

Overrides org.stringtemplate.v4.STGroup.getFileName.

Annotations
@Override
getNameback to summary
public String getName()

Overrides org.stringtemplate.v4.STGroup.getName.

Annotations
@Override
getRootDirURLback to summary
public URL getRootDirURL()

Overrides org.stringtemplate.v4.STGroup.getRootDirURL.

Doc from org.stringtemplate.v4.STGroup.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.

Annotations
@Override
importTemplatesback to summary
public void importTemplates(Token fileNameToken)

Overrides org.stringtemplate.v4.STGroup.importTemplates.

Doc from org.stringtemplate.v4.STGroup.importTemplates.

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 t() then we search for t() 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 importTemplates(STGroup) to import templates 'programmatically'.

Annotations
@Override
loadback to summary
protected CompiledST load(String name)

Overrides org.stringtemplate.v4.STGroup.load.

Load a template from directory or group file. Group file is given precedence over directory with same name. name is always fully-qualified.

Annotations
@Override
loadTemplateFileback to summary
public CompiledST loadTemplateFile(String prefix, String unqualifiedFileName)

Load .st as relative file name relative to root by prefix.

normalizeURLback to summary
public URL normalizeURL(URL url)

verify there is no extra slash on the end of URL