org.apache.velocity.tools.generic

## Class LocaleConfig

- java.lang.Object
- - org.apache.velocity.tools.generic.SafeConfig
  - - org.apache.velocity.tools.generic.LocaleConfig

Direct Known Subclasses:
  ConversionTool, DisplayTool, FormatConfig, ResourceTool

    public class LocaleConfig
    extends SafeConfig

Implements common logic and constants for tools which allow their default `Locale` to be configured.

Since:
  VelocityTools 2.0
Author:
  Nathan Bubna

### Field Summary

Fields
`static Locale` `DEFAULT_LOCALE` The default `Locale` to 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
Constructor and Description
`LocaleConfig()`

### Method Summary

All Methods Instance Methods Concrete Methods
`protected void` `configure(ValueParser values)` Does the actual configuration.
`Locale` `getLocale()` This returns the configured default `Locale` for this tool.
`protected void` `setLocale(Locale locale)` Sets the default locale for this instance.
`Locale` `toLocale(Object value)`

### Methods inherited from class org.apache.velocity.tools.generic.SafeConfig

`configure, getLog, initLogger, isConfigLocked, isSafeMode, setLockConfig, setSafeMode`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### DEFAULT_LOCALE

    public static final Locale DEFAULT_LOCALE

The default `Locale` to be used when none is specified.

### Constructor Detail

#### LocaleConfig

    public LocaleConfig()

### Method Detail

#### configure

    protected void configure(ValueParser values)

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:
  `configure` in class `SafeConfig`
Parameters:
  `values` - configuration values

#### getLocale

    public Locale getLocale()

This returns the configured default `Locale` for this tool.

Returns:
  the default `Locale`

#### setLocale

    protected void setLocale(Locale locale)

Sets the default locale for this instance.

Parameters:
  `locale` - default locale to use

#### toLocale

    public Locale toLocale(Object value)

Parameters:
  `value` - the object to be converted
Returns:
  a `Locale` for the specified value or `null` if the value is null or the conversion failed
Since:
  VelocityTools 3.0