Class LocaleConfig
java.lang.Object
org.apache.velocity.tools.generic.SafeConfig
org.apache.velocity.tools.generic.LocaleConfig
- Direct Known Subclasses:
ConversionTool,DisplayTool,FormatConfig,ResourceTool
Implements common logic and constants for tools which allow their
default
Locale to be configured.- Since:
- VelocityTools 2.0
- Author:
- Nathan Bubna
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final LocaleThe defaultLocaleto be used when none is specified.Fields inherited from class org.apache.velocity.tools.generic.SafeConfig
LOCK_CONFIG_KEY, log, LOGGER_NAME_KEY, SAFE_MODE_KEY, USE_CLASS_LOGGER_KEY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidconfigure(ValueParser values) Does the actual configuration.This returns the configured defaultLocalefor this tool.protected voidSets the default locale for this instance.Methods inherited from class org.apache.velocity.tools.generic.SafeConfig
configure, getLog, initLogger, isConfigLocked, isSafeMode, setLockConfig, setSafeMode
-
Field Details
-
DEFAULT_LOCALE
The defaultLocaleto be used when none is specified.
-
-
Constructor Details
-
LocaleConfig
public LocaleConfig()
-
-
Method Details
-
configure
Does the actual configuration. This is protected, so subclasses may share the same ValueParser and call configure at any time, while preventing templates from doing so when configure(Map) is locked.- Overrides:
configurein classSafeConfig- Parameters:
values- configuration values
-
getLocale
This returns the configured defaultLocalefor this tool.- Returns:
- the default
Locale
-
setLocale
Sets the default locale for this instance.- Parameters:
locale- default locale to use
-
toLocale
- Parameters:
value- the object to be converted- Returns:
- a
Localefor the specified value ornullif the value is null or the conversion failed - Since:
- VelocityTools 3.0
-