|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.stringtemplate.v4.STGroup
public class STGroup
A directory or directory tree of .st template files and/or group files. Individual template files contain formal template definitions. In a sense, it's like a single group file broken into multiple files, one for each template. ST v3 had just the pure template inside, not the template name and header. Name inside must match filename (minus suffix).
| Field Summary | |
|---|---|
protected Map<Class,ModelAdaptor> |
adaptors
A dictionary that allows people to register a model adaptor for a particular kind of object (subclass or implementation). |
static ErrorManager |
DEFAULT_ERR_MGR
|
static String |
DEFAULT_KEY
|
static STGroup |
defaultGroup
|
char |
delimiterStartChar
|
char |
delimiterStopChar
|
static String |
DICT_KEY
When we use key as a value in a dictionary, this is how we signify. |
protected Map<String,Map<String,Object>> |
dictionaries
Maps dict names to HashMap objects. |
String |
encoding
Load files using what encoding? |
ErrorManager |
errMgr
The errMgr for entire group; all compilations and executions. |
protected List<STGroup> |
imports
Every group can import templates/dictionaries from other groups. |
protected List<STGroup> |
importsToClearOnUnload
|
boolean |
iterateAcrossValues
v3 compatibility; used to iterate across values not keys like v4. |
protected static CompiledST |
NOT_FOUND_ST
Used to indicate that the template doesn't exist. |
protected Map<Class,AttributeRenderer> |
renderers
A dictionary that allows people to register a renderer for a particular kind of object for any template evaluated relative to this group. |
protected Map<String,CompiledST> |
templates
Maps template name to StringTemplate object. |
static boolean |
trackCreationEvents
For debugging with STViz. |
protected Map<Class,ModelAdaptor> |
typeToAdaptorCache
Cache exact attribute type to adaptor object |
protected Map<Class,AttributeRenderer> |
typeToRendererCache
Cache exact attribute type to renderer object |
static boolean |
verbose
Watch loading of groups and templates |
| Constructor Summary | |
|---|---|
STGroup()
|
|
STGroup(char delimiterStartChar,
char delimiterStopChar)
|
|
| Method Summary | |
|---|---|
CompiledST |
compile(String srcName,
String name,
List<FormalArgument> args,
String template,
org.antlr.runtime.Token templateToken)
Compile a template |
ST |
createSingleton(org.antlr.runtime.Token templateToken)
Create singleton template for use with dictionary values |
ST |
createStringTemplate(CompiledST impl)
|
ST |
createStringTemplateInternally(CompiledST impl)
differentiate so we can avoid having creation events for regions, map operations, and other "new ST" events used during interp. |
ST |
createStringTemplateInternally(ST proto)
|
void |
defineDictionary(String name,
Map<String,Object> mapping)
Define a map for this group; not thread safe...do not keep adding these while you reference them. |
CompiledST |
defineRegion(String enclosingTemplateName,
org.antlr.runtime.Token regionT,
String template,
org.antlr.runtime.Token templateToken)
|
CompiledST |
defineTemplate(String templateName,
String template)
|
CompiledST |
defineTemplate(String name,
String argsS,
String template)
|
CompiledST |
defineTemplate(String fullyQualifiedTemplateName,
org.antlr.runtime.Token nameT,
List<FormalArgument> args,
String template,
org.antlr.runtime.Token templateToken)
|
CompiledST |
defineTemplateAlias(org.antlr.runtime.Token aliasT,
org.antlr.runtime.Token targetT)
Make name and alias for target. |
void |
defineTemplateOrRegion(String fullyQualifiedTemplateName,
String regionSurroundingTemplateName,
org.antlr.runtime.Token templateToken,
String template,
org.antlr.runtime.Token nameToken,
List<FormalArgument> args)
|
AttributeRenderer |
getAttributeRenderer(Class attributeType)
Get renderer for class T associated with this group. |
protected ST |
getEmbeddedInstanceOf(Interpreter interp,
ST enclosingInstance,
int ip,
String name)
|
String |
getFileName()
|
List<STGroup> |
getImportedGroups()
|
ST |
getInstanceOf(String name)
The primary means of getting an instance of a template from this group. |
STErrorListener |
getListener()
|
static String |
getMangledRegionName(String enclosingTemplateName,
String name)
The "foo" of t() ::= "<@foo()>" is mangled to "/region__/t__foo" |
ModelAdaptor |
getModelAdaptor(Class attributeType)
|
String |
getName()
|
URL |
getRootDirURL()
Return root dir if this is group dir; return dir containing group file if this is group file. |
Set<String> |
getTemplateNames()
|
static String |
getUnMangledTemplateName(String mangledName)
Return "t.foo" from "/region__/t__foo" |
URL |
getURL(String fileName)
|
void |
importTemplates(STGroup g)
Make this group import templates/dictionaries from g. |
protected void |
importTemplates(STGroup g,
boolean clearOnUnload)
|
void |
importTemplates(org.antlr.runtime.Token fileNameToken)
Import template files, directories, and group files. |
void |
invalidateModelAdaptorCache(Class attributeType)
remove at least all types in cache that are subclasses or implement attributeType |
boolean |
isDefined(String name)
Is this template defined in this group or from this group below? Names must be absolute, fully-qualified names like /a/b |
boolean |
isDictionary(String name)
|
void |
load()
Force a load if it makes sense for the group |
protected CompiledST |
load(String name)
Load st from disk if dir or load whole group file if .stg file (then return just one template). |
CompiledST |
loadAbsoluteTemplateFile(String fileName)
Load template file into this group using absolute filename |
void |
loadGroupFile(String prefix,
String fileName)
Load a group file with full path fileName; it's relative to root by prefix. |
CompiledST |
loadTemplateFile(String prefix,
String unqualifiedFileName,
org.antlr.runtime.CharStream templateStream)
Load template stream into this group. |
protected CompiledST |
lookupImportedTemplate(String name)
|
CompiledST |
lookupTemplate(String name)
Look up a fully-qualified name |
void |
rawDefineTemplate(String name,
CompiledST code,
org.antlr.runtime.Token defT)
|
Map<String,Object> |
rawGetDictionary(String name)
|
CompiledST |
rawGetTemplate(String name)
|
void |
registerModelAdaptor(Class attributeType,
ModelAdaptor adaptor)
Add an adaptor for a kind of object so ST knows how to pull properties from them. |
void |
registerRenderer(Class attributeType,
AttributeRenderer r)
Register a renderer for all objects of a particular "kind" for all templates evaluated relative to this group. |
void |
registerRenderer(Class attributeType,
AttributeRenderer r,
boolean recursive)
|
void |
setListener(STErrorListener listener)
|
String |
show()
|
String |
toString()
|
void |
undefineTemplate(String name)
|
void |
unload()
"unload" all templates, dictionaries and import relationships, but leave renderers and adaptors. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final String DICT_KEY
public static final String DEFAULT_KEY
public String encoding
protected final List<STGroup> imports
protected final List<STGroup> importsToClearOnUnload
public char delimiterStartChar
public char delimiterStopChar
protected Map<String,CompiledST> templates
protected Map<String,Map<String,Object>> dictionaries
protected Map<Class,AttributeRenderer> renderers
protected Map<Class,ModelAdaptor> adaptors
protected Map<Class,ModelAdaptor> typeToAdaptorCache
protected Map<Class,AttributeRenderer> typeToRendererCache
protected static final CompiledST NOT_FOUND_ST
public static final ErrorManager DEFAULT_ERR_MGR
public static boolean verbose
public static boolean trackCreationEvents
public boolean iterateAcrossValues
public static STGroup defaultGroup
public ErrorManager errMgr
| Constructor Detail |
|---|
public STGroup()
public STGroup(char delimiterStartChar,
char delimiterStopChar)
| Method Detail |
|---|
public ST getInstanceOf(String name)
protected ST getEmbeddedInstanceOf(Interpreter interp,
ST enclosingInstance,
int ip,
String name)
public ST createSingleton(org.antlr.runtime.Token templateToken)
public boolean isDefined(String name)
public CompiledST lookupTemplate(String name)
public void unload()
protected CompiledST load(String name)
public void load()
protected CompiledST lookupImportedTemplate(String name)
public CompiledST rawGetTemplate(String name)
public Map<String,Object> rawGetDictionary(String name)
public boolean isDictionary(String name)
public CompiledST defineTemplate(String templateName,
String template)
public CompiledST defineTemplate(String name,
String argsS,
String template)
public CompiledST defineTemplate(String fullyQualifiedTemplateName,
org.antlr.runtime.Token nameT,
List<FormalArgument> args,
String template,
org.antlr.runtime.Token templateToken)
public CompiledST defineTemplateAlias(org.antlr.runtime.Token aliasT,
org.antlr.runtime.Token targetT)
public CompiledST defineRegion(String enclosingTemplateName,
org.antlr.runtime.Token regionT,
String template,
org.antlr.runtime.Token templateToken)
public void defineTemplateOrRegion(String fullyQualifiedTemplateName,
String regionSurroundingTemplateName,
org.antlr.runtime.Token templateToken,
String template,
org.antlr.runtime.Token nameToken,
List<FormalArgument> args)
public void rawDefineTemplate(String name,
CompiledST code,
org.antlr.runtime.Token defT)
public void undefineTemplate(String name)
public CompiledST compile(String srcName,
String name,
List<FormalArgument> args,
String template,
org.antlr.runtime.Token templateToken)
public static String getMangledRegionName(String enclosingTemplateName,
String name)
public static String getUnMangledTemplateName(String mangledName)
public void defineDictionary(String name,
Map<String,Object> mapping)
public void importTemplates(STGroup g)
public void importTemplates(org.antlr.runtime.Token fileNameToken)
importTemplates(STGroup) to import templates
'programmatically'.
protected void importTemplates(STGroup g,
boolean clearOnUnload)
public List<STGroup> getImportedGroups()
public void loadGroupFile(String prefix,
String fileName)
public CompiledST loadAbsoluteTemplateFile(String fileName)
public CompiledST loadTemplateFile(String prefix,
String unqualifiedFileName,
org.antlr.runtime.CharStream templateStream)
public void registerModelAdaptor(Class attributeType,
ModelAdaptor adaptor)
public void invalidateModelAdaptorCache(Class attributeType)
public ModelAdaptor getModelAdaptor(Class attributeType)
public void registerRenderer(Class attributeType,
AttributeRenderer r)
public void registerRenderer(Class attributeType,
AttributeRenderer r,
boolean recursive)
public AttributeRenderer getAttributeRenderer(Class attributeType)
public ST createStringTemplate(CompiledST impl)
public ST createStringTemplateInternally(CompiledST impl)
public ST createStringTemplateInternally(ST proto)
public String getName()
public String getFileName()
public URL getRootDirURL()
public URL getURL(String fileName)
public String toString()
toString in class Objectpublic String show()
public STErrorListener getListener()
public void setListener(STErrorListener listener)
public Set<String> getTemplateNames()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||