public class JSilverOptions extends Object implements Cloneable
JSilver
Constructor and Description |
---|
JSilverOptions() |
Modifier and Type | Method and Description |
---|---|
JSilverOptions |
clone() |
boolean |
getAllowGlobalDataModification() |
boolean |
getCacheTemplates() |
boolean |
getCompileTemplates() |
EscapeMode |
getEscapeMode() |
boolean |
getIgnoreAttributes() |
int |
getInitialBufferSize() |
boolean |
getKeepTemplateCacheFresh() |
int |
getLoadPathCacheSize() |
boolean |
getLogEscapedVariables() |
Map<Object,String> |
getPrecompiledTemplateMap() |
boolean |
getPropagateEscapeStatus() |
StringInternStrategy |
getStringInternStrategy()
Returns
StringInternStrategy object that is used for optimization of HDF parsing. |
boolean |
getStripHtmlWhiteSpace() |
boolean |
getStripStructuralWhiteSpace() |
boolean |
getUseOutputBufferPool() |
boolean |
getUseStrongCacheReferences() |
JSilverOptions |
setAllowGlobalDataModification(boolean allowGlobalDataModification)
Use this method to disable wrapping the global HDF with an UnmodifiableData object which
prevents modification.
|
JSilverOptions |
setCacheTemplates(boolean cacheTemplates)
Whether to cache templates.
|
JSilverOptions |
setCompileTemplates(boolean compileTemplates)
Compile templates to Java byte code.
|
JSilverOptions |
setEscapeMode(EscapeMode escapeMode)
Escape any template being rendered with the given escaping mode.
|
JSilverOptions |
setIgnoreAttributes(boolean ignoreAttributes)
If set, then HDF attributes in HDF files will be ignored and not stored in the Data object
filled by the parser.
|
JSilverOptions |
setInitialBufferSize(int initialBufferSize)
Initial buffer size used when rendering directly to a string.
|
JSilverOptions |
setKeepTemplateCacheFresh(boolean keepTemplateCacheFresh) |
JSilverOptions |
setLoadPathCacheSize(int loadPathCacheSize)
Set the initial size of the load path cache container.
|
JSilverOptions |
setLogEscapedVariables(boolean logEscapedVariables)
Use this method to enable logging of all variables whose values are modified by auto escaping
or <cs escape> commands.
|
JSilverOptions |
setPrecompiledTemplateMap(Map<Object,String> precompiledTemplateMap)
Optional mapping of TemplateLoader keys to Template instances that will be queried when loading
a template.
|
JSilverOptions |
setPropagateEscapeStatus(boolean propagateEscapeStatus)
Only used for templates that are being auto escaped.
|
void |
setStringInternStrategy(StringInternStrategy stringInternStrategy)
Sets the
StringInternStrategy object that will be used to optimize HDF parsing. |
JSilverOptions |
setStripHtmlWhiteSpace(boolean value)
If
true , then unnecessary whitespace will be stripped from the output. |
JSilverOptions |
setStripStructuralWhiteSpace(boolean value)
If
true , then structural whitespace will be stripped from the output. |
JSilverOptions |
setUseOutputBufferPool(boolean value)
If
true , then use a threadlocal buffer pool for holding rendered output when outputting
to String. |
JSilverOptions |
setUseStrongCacheReferences(boolean value)
If
true , then the template cache will use strong persistent references for the values. |
public JSilverOptions setLoadPathCacheSize(int loadPathCacheSize)
public int getLoadPathCacheSize()
setLoadPathCacheSize(int)
public JSilverOptions setCacheTemplates(boolean cacheTemplates)
public boolean getCacheTemplates()
setCacheTemplates(boolean)
public JSilverOptions setCompileTemplates(boolean compileTemplates)
public boolean getCompileTemplates()
setCompileTemplates(boolean)
public JSilverOptions setIgnoreAttributes(boolean ignoreAttributes)
false
. Many applications use HDF attributes only in
template preprocessing (like translation support) and never in production servers where the
templates are rendered. By disabling attribute parsing, these applications can save on memory
for storing HDF structures read from files.public boolean getIgnoreAttributes()
setIgnoreAttributes(boolean)
public JSilverOptions setInitialBufferSize(int initialBufferSize)
public int getInitialBufferSize()
setInitialBufferSize(int)
public JSilverOptions setPrecompiledTemplateMap(Map<Object,String> precompiledTemplateMap)
precompiledTemplateMap
- map of TemplateLoader keys to corresponding class names that
should be valid BaseCompiledTemplate subclasses. Set to null
(default) to not
load precompiled templates.public Map<Object,String> getPrecompiledTemplateMap()
null
(default) if no precompiled templates should be preloaded.setPrecompiledTemplateMap(java.util.Map)
public JSilverOptions setUseStrongCacheReferences(boolean value)
true
, then the template cache will use strong persistent references for the values.
If false
(default) it will use soft references. Warning: The cache size is unbounded so
only use this option if you have sufficient memory to load all the Templates into memory.public boolean getUseStrongCacheReferences()
setUseStrongCacheReferences(boolean)
public EscapeMode getEscapeMode()
public JSilverOptions setEscapeMode(EscapeMode escapeMode)
escapeMode
- public boolean getPropagateEscapeStatus()
setPropagateEscapeStatus(boolean)
public JSilverOptions setPropagateEscapeStatus(boolean propagateEscapeStatus)
true
and auto escaping is enabled, variables created by <cs set> or <cs
call> commands are not auto escaped if they are assigned constant or escaped values. This is
disabled by default.public void setStringInternStrategy(StringInternStrategy stringInternStrategy)
StringInternStrategy
object that will be used to optimize HDF parsing.
Set value should not be null
as it can cause NullPointerException
.
stringInternStrategy
- - StringInternStrategy
objectpublic StringInternStrategy getStringInternStrategy()
StringInternStrategy
object that is used for optimization of HDF parsing.
The returned value should never be null
.
StringInternStrategy
object.public JSilverOptions setUseOutputBufferPool(boolean value)
true
, then use a threadlocal buffer pool for holding rendered output when outputting
to String. Assumes that render() is called from a thread and that thread will not reenter
render() while it is running. If false
, a new buffer is allocated for each request
where an Appendable output object was not provided.public boolean getUseOutputBufferPool()
setUseOutputBufferPool(boolean)
public JSilverOptions setStripHtmlWhiteSpace(boolean value)
true
, then unnecessary whitespace will be stripped from the output. 'Unnecessary' is
meant in terms of HTML output. See
HtmlWhiteSpaceStripper
for more info.public boolean getStripHtmlWhiteSpace()
setStripHtmlWhiteSpace(boolean)
public JSilverOptions setStripStructuralWhiteSpace(boolean value)
true
, then structural whitespace will be stripped from the output. This allows
templates to be written to more closely match normal programming languages. See
StructuralWhitespaceStripper
for more info.public boolean getStripStructuralWhiteSpace()
setStripHtmlWhiteSpace(boolean)
public JSilverOptions setAllowGlobalDataModification(boolean allowGlobalDataModification)
true
unless incompatibilities or performance issues found. Note,
that setting to true
could introduce bugs in templates that acquire local references to
the global data structure and then try to modify them, which is not the intended behavior.
Allowing global data modification during rendering is not compatible with the recently fixed
JNI Clearsilver library.
TODO: Remove once legacy mode is no longer needed.allowGlobalDataModification
- true
if you want to avoid wrapping the global HDF so
that all writes to it during rendering are prevented and throw an exception.public boolean getAllowGlobalDataModification()
setAllowGlobalDataModification(boolean)
public JSilverOptions setKeepTemplateCacheFresh(boolean keepTemplateCacheFresh)
keepTemplateCacheFresh
- true
to have the template cache call
ResourceLoader.getResourceVersionId(String)
to check if it should refresh its cache entries (this incurs a small performance penalty
each time the cache is accessed)public boolean getKeepTemplateCacheFresh()
setKeepTemplateCacheFresh(boolean)
public JSilverOptions clone()
public boolean getLogEscapedVariables()
setLogEscapedVariables(boolean)
public JSilverOptions setLogEscapedVariables(boolean logEscapedVariables)
Level.WARNING
. This is useful
for detecting variables that should be exempt from auto escaping.
It is recommended to only enable this flag during testing or debugging and not for production jobs.
Copyright © 2010–2015 Google. All rights reserved.