Top Description Fields Constructors Methods
org.stringtemplate.v4

public Class STGroupFile

extends STGroup
Class Inheritance
Imports
org.stringtemplate.v4.compiler.CompiledST, .STException, org.stringtemplate.v4.misc.ErrorType, .Misc, java.io.File, java.net.MalformedURLException, .URL

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

Modifier and TypeField and Description
protected boolean
public String
fileName

Just records how user "spelled" the file name they wanted to load.

public URL
url

Where to find the group file.

Inherited from org.stringtemplate.v4.STGroup:
adaptorsDEFAULT_ERR_MGRDEFAULT_KEYdefaultGroupdelimiterStartChardelimiterStopCharDICT_KEYdictionariesencodingerrMgrGROUP_FILE_EXTENSIONimportsimportsToClearOnUnloaditerateAcrossValuesNOT_FOUND_STrenderersTEMPLATE_FILE_EXTENSIONtemplatestrackCreationEventsverbose

Constructor Summary

AccessConstructor and Description
public
STGroupFile(String fileName)

Load a file relative to current directory or from root or via CLASSPATH.

public
STGroupFile(String fileName, char delimiterStartChar, char delimiterStopChar)

public
STGroupFile(String fullyQualifiedFileName, String encoding)

public
STGroupFile(String fullyQualifiedFileName, String encoding, char delimiterStartChar, char delimiterStopChar)

public
STGroupFile(URL url, String encoding, char delimiterStartChar, char delimiterStopChar)

Pass in a URL with the location of a group file.

public
STGroupFile(URL url)

Convenience ctor

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 boolean
isDefined(String name)

Overrides org.stringtemplate.v4.STGroup.isDefined.

Is this template defined in this group or from this group below?
public boolean
protected synchronized CompiledST
load(String name)

Overrides org.stringtemplate.v4.STGroup.load.

Load st from disk if directory or load whole group file if .stg file (then return just one template).
public synchronized void
load()

Overrides org.stringtemplate.v4.STGroup.load.

Force a load if it makes sense for the group.
public String
public synchronized void
unload()

Overrides org.stringtemplate.v4.STGroup.unload.

Unload all templates, dictionaries and import relationships, but leave renderers and adaptors.
Inherited from org.stringtemplate.v4.STGroup:
compilecreateSingletoncreateStringTemplatecreateStringTemplateInternallycreateStringTemplateInternallydefineDictionarydefineRegiondefineTemplatedefineTemplatedefineTemplatedefineTemplateAliasdefineTemplateOrRegiongetAttributeRenderergetEmbeddedInstanceOfgetImportedGroupsgetInstanceOfgetListenergetMangledRegionNamegetModelAdaptorgetTemplateNamesgetUnMangledTemplateNamegetURLimportTemplatesimportTemplatesimportTemplatesisReservedCharacterloadAbsoluteTemplateFileloadGroupFileloadTemplateFilelookupImportedTemplatelookupTemplaterawDefineTemplaterawGetDictionaryrawGetTemplateregisterModelAdaptorregisterRendererregisterRenderersetListenertoStringundefineTemplate

Field Detail

alreadyLoadedback to summary
protected boolean alreadyLoaded
fileNameback to summary
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.

urlback to summary
public URL url

Where to find the group file. NonNull.

Constructor Detail

STGroupFileback to summary
public STGroupFile(String fileName)

Load a file relative to current directory or from root or via CLASSPATH.

STGroupFileback to summary
public STGroupFile(String fileName, char delimiterStartChar, char delimiterStopChar)
STGroupFileback to summary
public STGroupFile(String fullyQualifiedFileName, String encoding)
STGroupFileback to summary
public STGroupFile(String fullyQualifiedFileName, String encoding, char delimiterStartChar, char delimiterStopChar)
STGroupFileback to summary
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", '<', '>');

STGroupFileback to summary
public STGroupFile(URL url)

Convenience ctor

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
isDefinedback to summary
public boolean isDefined(String name)

Overrides org.stringtemplate.v4.STGroup.isDefined.

Doc from org.stringtemplate.v4.STGroup.isDefined.

Is this template defined in this group or from this group below? Names must be absolute, fully-qualified names like /a/b.

Annotations
@Override
isDictionaryback to summary
public boolean isDictionary(String name)

Overrides org.stringtemplate.v4.STGroup.isDictionary.

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

Overrides org.stringtemplate.v4.STGroup.load.

Doc from org.stringtemplate.v4.STGroup.load.

Load st from disk if directory or load whole group file if .stg file (then return just one template). name is fully-qualified.

Annotations
@Override
loadback to summary
public synchronized void load()

Overrides org.stringtemplate.v4.STGroup.load.

Doc from org.stringtemplate.v4.STGroup.load.

Force a load if it makes sense for the group.

Annotations
@Override
showback to summary
public String show()

Overrides org.stringtemplate.v4.STGroup.show.

Annotations
@Override
unloadback to summary
public synchronized void unload()

Overrides org.stringtemplate.v4.STGroup.unload.

Doc from org.stringtemplate.v4.STGroup.unload.

Unload all templates, dictionaries and import relationships, but leave renderers and adaptors. This essentially forces the next call to getInstanceOf to reload templates. Call unload() on each group in the imports list, and remove all elements in importsToClearOnUnload from imports.

Annotations
@Override