|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.stringtemplate.v4.ST
public class ST
An instance of the StringTemplate. It consists primarily of a reference to its implementation (shared among all instances) and a hash table of attributes. Because of dynamic scoping, we also need a reference to any enclosing instance. For example, in a deeply nested template for an HTML page body, we could still reference the title attribute defined in the outermost page template. To use templates, you create one (usually via STGroup) and then inject attributes using add(). To render its attacks, use render().
| Nested Class Summary | |
|---|---|
static class |
ST.AttributeList<T>
Just an alias for ArrayList, but this way I can track whether a list is something ST created or it's an incoming list. |
static class |
ST.DebugState
Events during template hierarchy construction (not evaluation) |
static class |
ST.RegionType
<@r()>, <@r>...<@end>, and @t.r() ::= "..." defined manually by coder |
| Field Summary | |
|---|---|
static STNoSuchAttributeException |
cachedNoSuchAttrException
Cache exception since this could happen a lot if people use "missing" to mean boolean false. |
ST.DebugState |
debugState
If Interpreter.trackCreationEvents, track creation, add-attr events for each object. |
static Object |
EMPTY_ATTR
|
STGroup |
groupThatCreatedThisInstance
Created as instance of which group? We need this to init interpreter via render. |
CompiledST |
impl
The implementation for this template among all instances of same tmpelate . |
protected Object[] |
locals
Safe to simultaneously write via add, which is synchronized. |
static String |
UNKNOWN_NAME
|
static String |
VERSION
|
| Constructor Summary | |
|---|---|
protected |
ST()
Used by group creation routine, not by users |
|
ST(ST proto)
Clone a prototype template. |
|
ST(STGroup group,
String template)
|
|
ST(String template)
Used to make templates inline in code for simple things like SQL or log records. |
|
ST(String template,
char delimiterStartChar,
char delimiterStopChar)
Create ST using non-default delimiters; each one of these will live in it's own group since you're overriding a default; don't want to alter STGroup.defaultGroup. |
| Method Summary | |
|---|---|
ST |
add(String name,
Object value)
Inject an attribute (name/value pair). |
ST |
addAggr(String aggrSpec,
Object... values)
Split "aggrName.{propName1,propName2}" into list [propName1,propName2] and the aggrName. |
protected static ST.AttributeList<Object> |
convertToAttributeList(Object curvalue)
|
static String |
format(int lineWidth,
String template,
Object... attributes)
|
static String |
format(String template,
Object... attributes)
|
Object |
getAttribute(String name)
Find an attr in this template only. |
Map<String,Object> |
getAttributes()
|
List<InterpEvent> |
getEvents()
|
List<InterpEvent> |
getEvents(int lineWidth)
|
List<InterpEvent> |
getEvents(Locale locale)
|
List<InterpEvent> |
getEvents(Locale locale,
int lineWidth)
|
String |
getName()
|
STViz |
inspect()
|
STViz |
inspect(ErrorManager errMgr,
Locale locale,
int lineWidth)
|
STViz |
inspect(int lineWidth)
|
STViz |
inspect(Locale locale)
|
boolean |
isAnonSubtemplate()
|
protected void |
rawSetAttribute(String name,
Object value)
Set this.locals attr value when you only know the name, not the index. |
void |
remove(String name)
Remove an attribute value entirely (can't remove attribute definitions). |
String |
render()
|
String |
render(int lineWidth)
|
String |
render(Locale locale)
|
String |
render(Locale locale,
int lineWidth)
|
String |
toString()
|
int |
write(File outputFile,
STErrorListener listener)
|
int |
write(File outputFile,
STErrorListener listener,
String encoding)
|
int |
write(File outputFile,
STErrorListener listener,
String encoding,
int lineWidth)
|
int |
write(File outputFile,
STErrorListener listener,
String encoding,
Locale locale,
int lineWidth)
|
int |
write(STWriter out)
|
int |
write(STWriter out,
Locale locale)
|
int |
write(STWriter out,
Locale locale,
STErrorListener listener)
|
int |
write(STWriter out,
STErrorListener listener)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final String VERSION
public static final String UNKNOWN_NAME
public static final Object EMPTY_ATTR
public static STNoSuchAttributeException cachedNoSuchAttrException
public CompiledST impl
protected Object[] locals
public STGroup groupThatCreatedThisInstance
public ST.DebugState debugState
| Constructor Detail |
|---|
protected ST()
public ST(String template)
public ST(String template,
char delimiterStartChar,
char delimiterStopChar)
public ST(STGroup group,
String template)
public ST(ST proto)
| Method Detail |
|---|
public ST add(String name,
Object value)
public ST addAggr(String aggrSpec,
Object... values)
public void remove(String name)
protected void rawSetAttribute(String name,
Object value)
public Object getAttribute(String name)
public Map<String,Object> getAttributes()
protected static ST.AttributeList<Object> convertToAttributeList(Object curvalue)
public String getName()
public boolean isAnonSubtemplate()
public int write(STWriter out)
throws IOException
IOException
public int write(STWriter out,
Locale locale)
public int write(STWriter out,
STErrorListener listener)
public int write(STWriter out,
Locale locale,
STErrorListener listener)
public int write(File outputFile,
STErrorListener listener)
throws IOException
IOException
public int write(File outputFile,
STErrorListener listener,
String encoding)
throws IOException
IOException
public int write(File outputFile,
STErrorListener listener,
String encoding,
int lineWidth)
throws IOException
IOException
public int write(File outputFile,
STErrorListener listener,
String encoding,
Locale locale,
int lineWidth)
throws IOException
IOExceptionpublic String render()
public String render(int lineWidth)
public String render(Locale locale)
public String render(Locale locale,
int lineWidth)
public STViz inspect()
public STViz inspect(int lineWidth)
public STViz inspect(Locale locale)
public STViz inspect(ErrorManager errMgr,
Locale locale,
int lineWidth)
public List<InterpEvent> getEvents()
public List<InterpEvent> getEvents(int lineWidth)
public List<InterpEvent> getEvents(Locale locale)
public List<InterpEvent> getEvents(Locale locale,
int lineWidth)
public String toString()
toString in class Object
public static String format(String template,
Object... attributes)
public static String format(int lineWidth,
String template,
Object... attributes)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||