| java.lang.Object freemarker.core.Configurable
All known Subclasses: freemarker.template.Configuration, freemarker.template.Template, freemarker.core.Environment,
Configurable | public class Configurable (Code) | | This is a common superclass of
freemarker.template.Configuration ,
freemarker.template.Template , and
Environment classes.
It provides settings that are common to each of them. FreeMarker
uses a three-level setting hierarchy - the return value of every setting
getter method on Configurable objects inherits its value from its parent
Configurable object, unless explicitly overridden by a call to a
corresponding setter method on the object itself. The parent of an
Environment object is a Template object, the
parent of a Template object is a Configuration
object.
version: $Id: Configurable.java,v 1.23.2.2 2007/04/02 13:46:43 szegedia Exp $ author: Attila Szegedi |
Method Summary | |
protected Object | clone() | public ArithmeticEngine | getArithmeticEngine() Retrieves the arithmetic engine used to perform arithmetic operations. | public String | getBooleanFormat() | String | getBooleanFormat(boolean value) | Object | getCustomAttribute(Object key, CustomAttribute attr) | public Object | getCustomAttribute(String name) Retrieves a named custom attribute for this configurable. | public String[] | getCustomAttributeNames() Returns an array with names of all custom attributes defined directly
on this configurable. | public String | getDateFormat() Returns the date format used to convert date models representing
date-only dates to strings. | public String | getDateTimeFormat() Returns the date format used to convert date models representing datetime
dates to strings. | protected Environment | getEnvironment() | public Locale | getLocale() Returns the assumed locale when searching for template files with no
explicit requested locale. | public String | getNumberFormat() Returns the default number format used to convert numbers to strings. | public ObjectWrapper | getObjectWrapper() Retrieves the object wrapper used to wrap objects to template models. | public String | getOutputEncoding() | final public Configurable | getParent() Returns the parent Configurable object of this object.
The parent stores the default values for this configurable. | public String | getSetting(String key) Returns the textual representation of a setting.
Parameters: key - the setting key. | public Map | getSettings() This meant to return the String-to-String Map of the
settings. | public TemplateExceptionHandler | getTemplateExceptionHandler() Retrieves the exception handler used to handle template exceptions. | public String | getTimeFormat() Returns the date format used to convert date models representing
time-only dates to strings. | public TimeZone | getTimeZone() Returns the time zone to use when formatting time values. | public String | getURLEscapingCharset() | protected TemplateException | invalidSettingValueException(String name, String value) | public boolean | isClassicCompatible() Returns whether the engine runs in the "Classic Compatibile" mode.
When this mode is active, the engine behavior is altered in following
way: (these resemble the behavior of the 1.7.x line of FreeMarker engine,
now named "FreeMarker Classic", hence the name).
- handle undefined expressions gracefully.
| public void | removeCustomAttribute(String name) Removes a named custom attribute for this configurable. | public void | setArithmeticEngine(ArithmeticEngine arithmeticEngine) Sets the arithmetic engine used to perform arithmetic operations. | public void | setBooleanFormat(String booleanFormat) | public void | setClassicCompatible(boolean classicCompatibility) Toggles the "Classic Compatibile" mode. | void | setCustomAttribute(Object key, Object value) | public void | setCustomAttribute(String name, Object value) Sets a named custom attribute for this configurable.
Parameters: name - the name of the custom attribute Parameters: value - the value of the custom attribute. | public void | setDateFormat(String dateFormat) Sets the date format used to convert date models representing date-only
dates to strings. | public void | setDateTimeFormat(String dateTimeFormat) Sets the date format used to convert date models representing datetime
dates to strings. | public void | setLocale(Locale locale) Sets the locale to assume when searching for template files with no
explicit requested locale. | public void | setNumberFormat(String numberFormat) Sets the number format used to convert numbers to strings. | public void | setObjectWrapper(ObjectWrapper objectWrapper) Sets the object wrapper used to wrap objects to template models. | public void | setOutputEncoding(String outputEncoding) Sets the output encoding. | final void | setParent(Configurable parent) Reparenting support. | public void | setSetting(String key, String value) Sets a setting by a name and string value.
List of supported names and their valid values:
"locale" : local codes with the usual format, such as "en_US" .
"classic_compatible" :
"true" , "false" , "yes" , "no" ,
"t" , "f" , "y" , "n" .
Case insensitive.
"template_exception_handler" : If the value contains dot, then it is
interpreted as class name, and the object will be created with
its parameterless constructor. | public void | setSettings(Properties props) Set the settings stored in a Properties object. | public void | setSettings(InputStream propsIn) Reads a setting list (key and element pairs) from the input stream. | public void | setStrictBeanModels(boolean strict) | public void | setTemplateExceptionHandler(TemplateExceptionHandler templateExceptionHandler) Sets the exception handler used to handle template exceptions. | public void | setTimeFormat(String timeFormat) Sets the date format used to convert date models representing time-only
values to strings. | public void | setTimeZone(TimeZone timeZone) Sets the time zone to use when formatting time values. | public void | setURLEscapingCharset(String urlEscapingCharset) Sets the URL escaping charset. | protected TemplateException | unknownSettingException(String name) |
ARITHMETIC_ENGINE_KEY | final public static String ARITHMETIC_ENGINE_KEY(Code) | | |
BOOLEAN_FORMAT_KEY | final public static String BOOLEAN_FORMAT_KEY(Code) | | |
CLASSIC_COMPATIBLE_KEY | final public static String CLASSIC_COMPATIBLE_KEY(Code) | | |
DATETIME_FORMAT_KEY | final public static String DATETIME_FORMAT_KEY(Code) | | |
DATE_FORMAT_KEY | final public static String DATE_FORMAT_KEY(Code) | | |
NUMBER_FORMAT_KEY | final public static String NUMBER_FORMAT_KEY(Code) | | |
OBJECT_WRAPPER_KEY | final public static String OBJECT_WRAPPER_KEY(Code) | | |
OUTPUT_ENCODING_KEY | final public static String OUTPUT_ENCODING_KEY(Code) | | |
STRICT_BEAN_MODELS | final public static String STRICT_BEAN_MODELS(Code) | | |
TEMPLATE_EXCEPTION_HANDLER_KEY | final public static String TEMPLATE_EXCEPTION_HANDLER_KEY(Code) | | |
TIME_FORMAT_KEY | final public static String TIME_FORMAT_KEY(Code) | | |
URL_ESCAPING_CHARSET_KEY | final public static String URL_ESCAPING_CHARSET_KEY(Code) | | |
Configurable | public Configurable()(Code) | | |
Configurable | public Configurable(Configurable parent)(Code) | | Creates a new instance. Normally you do not need to use this constructor,
as you don't use Configurable directly, but its subclasses.
|
getArithmeticEngine | public ArithmeticEngine getArithmeticEngine()(Code) | | Retrieves the arithmetic engine used to perform arithmetic operations.
|
getBooleanFormat | String getBooleanFormat(boolean value)(Code) | | |
getCustomAttribute | public Object getCustomAttribute(String name)(Code) | | Retrieves a named custom attribute for this configurable. If the
attribute is not present in the configurable, and the configurable has
a parent, then the parent is looked up as well.
Parameters: name - the name of the custom attribute the value of the custom attribute. Note that if the custom attributewas created with <#ftl attributes={...}>, then this value is alreadyunwrapped (i.e. it's a String , or a List , or aMap , ...etc., not a FreeMarker specific class). |
getCustomAttributeNames | public String[] getCustomAttributeNames()(Code) | | Returns an array with names of all custom attributes defined directly
on this configurable. (That is, it doesn't contain the names of custom attributes
defined indirectly on its parent configurables.) The returned array is never null,
but can be zero-length.
The order of elements in the returned array is not defined and can change
between invocations.
|
getDateFormat | public String getDateFormat()(Code) | | Returns the date format used to convert date models representing
date-only dates to strings.
Defaults to "date"
|
getDateTimeFormat | public String getDateTimeFormat()(Code) | | Returns the date format used to convert date models representing datetime
dates to strings.
Defaults to "datetime"
|
getLocale | public Locale getLocale()(Code) | | Returns the assumed locale when searching for template files with no
explicit requested locale. Defaults to system locale.
|
getNumberFormat | public String getNumberFormat()(Code) | | Returns the default number format used to convert numbers to strings.
Defaults to "number"
|
getObjectWrapper | public ObjectWrapper getObjectWrapper()(Code) | | Retrieves the object wrapper used to wrap objects to template models.
|
getParent | final public Configurable getParent()(Code) | | Returns the parent Configurable object of this object.
The parent stores the default values for this configurable. For example,
the parent of the
freemarker.template.Template object is the
freemarker.template.Configuration object, so setting values not
specfied on template level are specified by the confuration object.
the parent Configurable object, or null, if this isthe root Configurable object. |
getSettings | public Map getSettings()(Code) | | This meant to return the String-to-String Map of the
settings. So it actually should return a Properties object,
but it doesn't by mistake. The returned Map is read-only,
but it will reflect the further configuration changes (aliasing effect).
Configurable.setSettings(Properties) |
getTemplateExceptionHandler | public TemplateExceptionHandler getTemplateExceptionHandler()(Code) | | Retrieves the exception handler used to handle template exceptions.
|
getTimeFormat | public String getTimeFormat()(Code) | | Returns the date format used to convert date models representing
time-only dates to strings.
Defaults to "time"
|
getTimeZone | public TimeZone getTimeZone()(Code) | | Returns the time zone to use when formatting time values. Defaults to
system time zone.
|
getURLEscapingCharset | public String getURLEscapingCharset()(Code) | | |
isClassicCompatible | public boolean isClassicCompatible()(Code) | | Returns whether the engine runs in the "Classic Compatibile" mode.
When this mode is active, the engine behavior is altered in following
way: (these resemble the behavior of the 1.7.x line of FreeMarker engine,
now named "FreeMarker Classic", hence the name).
- handle undefined expressions gracefully. Namely when an expression
"expr" evaluates to null:
- as argument of the <assign varname=expr> directive,
${expr} directive, otherexpr == expr or
otherexpr != expr conditional expressions, or
hash[expr] expression, then it is treated as empty string.
- as argument of <list expr as item> or
<foreach item in expr>, the loop body is not executed
(as if it were a 0-length list)
- as argument of <if> directive, or otherwise where a
boolean expression is expected, it is treated as false
- Non-boolean models are accepted in <if> directive,
or as operands of logical operators. "Empty" models (zero-length string,
empty sequence or hash) are evaluated as false, all others are evaluated as
true.
- When boolean value is treated as a string (i.e. output in
${...} directive, or concatenated with other string), true
values are converted to string "true", false values are converted to
empty string.
- Scalar models supplied to <list> and
<foreach> are treated as a one-element list consisting
of the passed model.
- Paths parameter of <include> will be interpreted as
absolute path.
In all other aspects, the engine is a 2.1 engine even in compatibility
mode - you don't lose any of the new functionality by enabling it.
|
removeCustomAttribute | public void removeCustomAttribute(String name)(Code) | | Removes a named custom attribute for this configurable. Note that this
is different than setting the custom attribute value to null. If you
set the value to null,
Configurable.getCustomAttribute(String) will return
null, while if you remove the attribute, it will return the value of
the attribute in the parent configurable (if there is a parent
configurable, that is).
Parameters: name - the name of the custom attribute |
setArithmeticEngine | public void setArithmeticEngine(ArithmeticEngine arithmeticEngine)(Code) | | Sets the arithmetic engine used to perform arithmetic operations.
Parameters: arithmeticEngine - the arithmetic engine used to perform arithmeticoperations.By default, ArithmeticEngine.BIGDECIMAL_ENGINE is used. |
setBooleanFormat | public void setBooleanFormat(String booleanFormat)(Code) | | |
setClassicCompatible | public void setClassicCompatible(boolean classicCompatibility)(Code) | | Toggles the "Classic Compatibile" mode. For a comprehensive description
of this mode, see
Configurable.isClassicCompatible() .
|
setCustomAttribute | void setCustomAttribute(Object key, Object value)(Code) | | Internal entry point for setting unnamed custom attributes
|
setCustomAttribute | public void setCustomAttribute(String name, Object value)(Code) | | Sets a named custom attribute for this configurable.
Parameters: name - the name of the custom attribute Parameters: value - the value of the custom attribute. You can set the value tonull, however note that there is a semantic difference between anattribute set to null and an attribute that is not present, seeConfigurable.removeCustomAttribute(String). |
setDateFormat | public void setDateFormat(String dateFormat)(Code) | | Sets the date format used to convert date models representing date-only
dates to strings.
|
setDateTimeFormat | public void setDateTimeFormat(String dateTimeFormat)(Code) | | Sets the date format used to convert date models representing datetime
dates to strings.
|
setLocale | public void setLocale(Locale locale)(Code) | | Sets the locale to assume when searching for template files with no
explicit requested locale.
|
setNumberFormat | public void setNumberFormat(String numberFormat)(Code) | | Sets the number format used to convert numbers to strings.
|
setObjectWrapper | public void setObjectWrapper(ObjectWrapper objectWrapper)(Code) | | Sets the object wrapper used to wrap objects to template models.
Parameters: objectWrapper - the object wrapper used to wrap objects to templatemodels.By default, ObjectWrapper.DEFAULT_WRAPPER is used. |
setOutputEncoding | public void setOutputEncoding(String outputEncoding)(Code) | | Sets the output encoding. Allows null , which means that the
output encoding is not known.
|
setParent | final void setParent(Configurable parent)(Code) | | Reparenting support. This is used by Environment when it includes a
template - the included template becomes the parent configurable during
its evaluation.
|
setSetting | public void setSetting(String key, String value) throws TemplateException(Code) | | Sets a setting by a name and string value.
List of supported names and their valid values:
"locale" : local codes with the usual format, such as "en_US" .
"classic_compatible" :
"true" , "false" , "yes" , "no" ,
"t" , "f" , "y" , "n" .
Case insensitive.
"template_exception_handler" : If the value contains dot, then it is
interpreted as class name, and the object will be created with
its parameterless constructor. If the value does not contain dot,
then it must be one of these special values:
"rethrow" , "debug" ,
"html_debug" , "ignore" (case insensitive).
"arithmetic_engine" : If the value contains dot, then it is
interpreted as class name, and the object will be created with
its parameterless constructor. If the value does not contain dot,
then it must be one of these special values:
"bigdecimal" , "conservative" (case insensitive).
"object_wrapper" : If the value contains dot, then it is
interpreted as class name, and the object will be created with
its parameterless constructor. If the value does not contain dot,
then it must be one of these special values:
"simple" , "beans" , "jython" (case insensitive).
"number_format" : pattern as java.text.DecimalFormat defines.
"boolean_format" : the textual value for boolean true and false,
separated with comma. For example "yes,no" .
"date_format", "time_format", "datetime_format" : patterns as
java.text.SimpleDateFormat defines.
"time_zone" : time zone, with the format as
java.util.TimeZone.getTimeZone defines. For example "GMT-8:00" or
"America/Los_Angeles"
"output_encoding" : Informs FreeMarker about the charset
used for the output. As FreeMarker outputs character stream (not
byte stream), it is not aware of the output charset unless the
software that encloses it tells it explicitly with this setting.
Some templates may use FreeMarker features that require this.
"url_escaping_charset" : If this setting is set, then it
overrides the value of the "output_encoding" setting when
FreeMarker does URL encoding.
Parameters: key - the name of the setting. Parameters: value - the string that describes the new value of the setting. throws: UnknownSettingException - if the key is wrong. throws: TemplateException - if the new value of the setting can't be setfor any other reasons. |
setSettings | public void setSettings(Properties props) throws TemplateException(Code) | | Set the settings stored in a Properties object.
throws: TemplateException - if the Properties object containsinvalid keys, or invalid setting values, or any other error occurswhile changing the settings. |
setSettings | public void setSettings(InputStream propsIn) throws TemplateException, IOException(Code) | | Reads a setting list (key and element pairs) from the input stream.
The stream has to follow the usual .properties format.
throws: TemplateException - if the stream containsinvalid keys, or invalid setting values, or any other error occurswhile changing the settings. throws: IOException - if an error occurred when reading from the input stream. |
setStrictBeanModels | public void setStrictBeanModels(boolean strict)(Code) | | |
setTimeFormat | public void setTimeFormat(String timeFormat)(Code) | | Sets the date format used to convert date models representing time-only
values to strings.
|
setTimeZone | public void setTimeZone(TimeZone timeZone)(Code) | | Sets the time zone to use when formatting time values.
|
setURLEscapingCharset | public void setURLEscapingCharset(String urlEscapingCharset)(Code) | | Sets the URL escaping charset. Allows null , which means that the
output encoding will be used for URL escaping.
|
|
|