|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectfreemarker.core.Configurable
This is a common superclass of Configuration
,
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.
Nested Class Summary | |
class |
Configurable.UnknownSettingException
|
Field Summary | |
static java.lang.String |
ARITHMETIC_ENGINE_KEY
|
static java.lang.String |
BOOLEAN_FORMAT_KEY
|
static java.lang.String |
CLASSIC_COMPATIBLE_KEY
|
static java.lang.String |
DATE_FORMAT_KEY
|
static java.lang.String |
DATETIME_FORMAT_KEY
|
static java.lang.String |
LOCALE_KEY
|
static java.lang.String |
NUMBER_FORMAT_KEY
|
static java.lang.String |
OBJECT_WRAPPER_KEY
|
static java.lang.String |
TEMPLATE_EXCEPTION_HANDLER_KEY
|
static java.lang.String |
TIME_FORMAT_KEY
|
static java.lang.String |
TIME_ZONE_KEY
|
Constructor Summary | |
Configurable()
|
|
Configurable(Configurable parent)
Creates a new instance. |
Method Summary | |
protected java.lang.Object |
clone()
|
ArithmeticEngine |
getArithmeticEngine()
Retrieves the arithmetic engine used to perform arithmetic operations. |
java.lang.String |
getBooleanFormat()
|
java.lang.Object |
getCustomAttribute(java.lang.String name)
Retrieves a named custom attribute for this configurable. |
java.lang.String[] |
getCustomAttributeNames()
Returns an array with names of all custom attributes defined directly on this configurable. |
java.lang.String |
getDateFormat()
Returns the date format used to convert date models representing date-only dates to strings. |
java.lang.String |
getDateTimeFormat()
Returns the date format used to convert date models representing datetime dates to strings. |
protected Environment |
getEnvironment()
|
java.util.Locale |
getLocale()
Returns the assumed locale when searching for template files with no explicit requested locale. |
java.lang.String |
getNumberFormat()
Returns the default number format used to convert numbers to strings. |
ObjectWrapper |
getObjectWrapper()
Retrieves the object wrapper used to wrap objects to template models. |
Configurable |
getParent()
Returns the parent Configurable object of this object. |
java.lang.String |
getSetting(java.lang.String key)
Returns the textual representation of a setting. |
java.util.Map |
getSettings()
|
TemplateExceptionHandler |
getTemplateExceptionHandler()
Retrieves the exception handler used to handle template exceptions. |
java.lang.String |
getTimeFormat()
Returns the date format used to convert date models representing time-only dates to strings. |
java.util.TimeZone |
getTimeZone()
Returns the time zone to use when formatting time values. |
protected TemplateException |
invalidSettingValueException(java.lang.String name,
java.lang.String value)
|
boolean |
isClassicCompatible()
Returns whether the engine runs in the "Classic Compatibile" mode. |
void |
removeCustomAttribute(java.lang.String name)
Removes a named custom attribute for this configurable. |
void |
setArithmeticEngine(ArithmeticEngine arithmeticEngine)
Sets the arithmetic engine used to perform arithmetic operations. |
void |
setBooleanFormat(java.lang.String booleanFormat)
|
void |
setClassicCompatible(boolean classicCompatibility)
Toggles the "Classic Compatibile" mode. |
void |
setCustomAttribute(java.lang.String name,
java.lang.Object value)
Sets a named custom attribute for this configurable. |
void |
setDateFormat(java.lang.String dateFormat)
Sets the date format used to convert date models representing date-only dates to strings. |
void |
setDateTimeFormat(java.lang.String dateTimeFormat)
Sets the date format used to convert date models representing datetime dates to strings. |
void |
setLocale(java.util.Locale locale)
Sets the locale to assume when searching for template files with no explicit requested locale. |
void |
setNumberFormat(java.lang.String numberFormat)
Sets the number format used to convert numbers to strings. |
void |
setObjectWrapper(ObjectWrapper objectWrapper)
Sets the object wrapper used to wrap objects to template models. |
void |
setSetting(java.lang.String key,
java.lang.String value)
Sets a setting by a name and string value. |
void |
setSettings(java.io.InputStream propsIn)
Reads a setting list (key and element pairs) from the input stream. |
void |
setSettings(java.util.Properties props)
Set the settings stored in a Properties object. |
void |
setTemplateExceptionHandler(TemplateExceptionHandler templateExceptionHandler)
Sets the exception handler used to handle template exceptions. |
void |
setTimeFormat(java.lang.String timeFormat)
Sets the date format used to convert date models representing time-only values to strings. |
void |
setTimeZone(java.util.TimeZone timeZone)
Sets the time zone to use when formatting time values. |
protected TemplateException |
unknownSettingException(java.lang.String name)
|
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String LOCALE_KEY
public static final java.lang.String NUMBER_FORMAT_KEY
public static final java.lang.String TIME_FORMAT_KEY
public static final java.lang.String DATE_FORMAT_KEY
public static final java.lang.String DATETIME_FORMAT_KEY
public static final java.lang.String TIME_ZONE_KEY
public static final java.lang.String CLASSIC_COMPATIBLE_KEY
public static final java.lang.String TEMPLATE_EXCEPTION_HANDLER_KEY
public static final java.lang.String ARITHMETIC_ENGINE_KEY
public static final java.lang.String OBJECT_WRAPPER_KEY
public static final java.lang.String BOOLEAN_FORMAT_KEY
Constructor Detail |
public Configurable()
public Configurable(Configurable parent)
Configurable
directly, but its subclasses.
Method Detail |
protected java.lang.Object clone() throws java.lang.CloneNotSupportedException
java.lang.CloneNotSupportedException
public final Configurable getParent()
Template
object is the
Configuration
object, so setting values not
specfied on template level are specified by the confuration object.
public void setClassicCompatible(boolean classicCompatibility)
isClassicCompatible()
.
public boolean isClassicCompatible()
public void setLocale(java.util.Locale locale)
public java.util.TimeZone getTimeZone()
public void setTimeZone(java.util.TimeZone timeZone)
public java.util.Locale getLocale()
public void setNumberFormat(java.lang.String numberFormat)
public java.lang.String getNumberFormat()
public void setBooleanFormat(java.lang.String booleanFormat)
public java.lang.String getBooleanFormat()
public void setTimeFormat(java.lang.String timeFormat)
public java.lang.String getTimeFormat()
public void setDateFormat(java.lang.String dateFormat)
public java.lang.String getDateFormat()
public void setDateTimeFormat(java.lang.String dateTimeFormat)
public java.lang.String getDateTimeFormat()
public void setTemplateExceptionHandler(TemplateExceptionHandler templateExceptionHandler)
templateExceptionHandler
- the template exception handler to use for
handling TemplateException
s. By default,
TemplateExceptionHandler.HTML_DEBUG_HANDLER
is used.public TemplateExceptionHandler getTemplateExceptionHandler()
public void setArithmeticEngine(ArithmeticEngine arithmeticEngine)
arithmeticEngine
- the arithmetic engine used to perform arithmetic
operations.By default, ArithmeticEngine.BIGDECIMAL_ENGINE
is
used.public ArithmeticEngine getArithmeticEngine()
public void setObjectWrapper(ObjectWrapper objectWrapper)
objectWrapper
- the object wrapper used to wrap objects to template
models.By default, ObjectWrapper.DEFAULT_WRAPPER
is used.public ObjectWrapper getObjectWrapper()
public void setSetting(java.lang.String key, java.lang.String value) throws TemplateException
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"
key
- the name of the setting.value
- the string that describes the new value of the setting.
Configurable.UnknownSettingException
- if the key is wrong.
TemplateException
- if the new value of the setting can't be set
for any other reasons.public java.lang.String getSetting(java.lang.String key)
key
- the setting key. Can be any of standard XXX_KEY
constants, or a custom key.public java.util.Map getSettings()
protected Environment getEnvironment()
protected TemplateException unknownSettingException(java.lang.String name)
protected TemplateException invalidSettingValueException(java.lang.String name, java.lang.String value)
public void setSettings(java.util.Properties props) throws TemplateException
Properties
object.
TemplateException
- if the Properties
object contains
invalid keys, or invalid setting values, or any other error occurs
while changing the settings.public void setSettings(java.io.InputStream propsIn) throws TemplateException, java.io.IOException
.properties
format.
TemplateException
- if the stream contains
invalid keys, or invalid setting values, or any other error occurs
while changing the settings.
java.io.IOException
- if an error occurred when reading from the input stream.public void setCustomAttribute(java.lang.String name, java.lang.Object value)
name
- the name of the custom attributevalue
- the value of the custom attribute. You can set the value to
null, however note that there is a semantic difference between an
attribute set to null and an attribute that is not present, see
removeCustomAttribute(String)
.public java.lang.String[] getCustomAttributeNames()
public void removeCustomAttribute(java.lang.String name)
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).
name
- the name of the custom attribute
public java.lang.Object getCustomAttribute(java.lang.String name)
name
- the name of the custom attribute
String
, or a List
, or a
Map
, ...etc., not a FreeMarker specific class).
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |