org.milyn.javabean.decoders
Class LocaleAwareDecoder

java.lang.Object
  extended by org.milyn.javabean.decoders.LocaleAwareDecoder
All Implemented Interfaces:
Serializable, Configurable, DataDecoder
Direct Known Subclasses:
LocaleAwareDateDecoder, NumberDecoder

public abstract class LocaleAwareDecoder
extends Object
implements DataDecoder, Configurable

LocaleAwareDecoder is a decoder 'helper' that can be subclassed by any DataDecoder implementation that relies on Locale information to perform Data Decoding.

Author:
daniel.bevenius@gmail.com
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.milyn.javabean.DataDecoder
DataDecoder.Factory
 
Field Summary
static String LOCALE
          Locale.
static String LOCALE_COUNTRY_CODE
          ISO Country Code.
static String LOCALE_LANGUAGE_CODE
          ISO Language Code.
static String VERIFY_LOCALE
          True or false(default).
 
Constructor Summary
LocaleAwareDecoder()
           
 
Method Summary
 Properties getConfiguration()
          Get the component configuration.
 Locale getLocale()
          Get the configured Locale.
protected  Locale getLocale(String languageCode, String countryCode)
          Returns a Locale matching the passed in languageCode, and countryCode
protected  boolean isLocalInstalled(Locale locale)
           
 void setConfiguration(Properties resourceConfig)
          Set the component configuration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.milyn.javabean.DataDecoder
decode
 

Field Detail

LOCALE

public static final String LOCALE
Locale. Hyphen separated ISO Language Code and Country Code e.g. "en-IE".

See Also:
Constant Field Values

LOCALE_LANGUAGE_CODE

public static final String LOCALE_LANGUAGE_CODE
ISO Language Code. Lower case two-letter code defined by ISO-639

See Also:
Constant Field Values

LOCALE_COUNTRY_CODE

public static final String LOCALE_COUNTRY_CODE
ISO Country Code. Upper case two-letter code defined by ISO-3166

See Also:
Constant Field Values

VERIFY_LOCALE

public static final String VERIFY_LOCALE
True or false(default). Whether or not a check should be performed to verify that the specified locale is installed. This operation can take some time and should be turned off in a production evironment

See Also:
Constant Field Values
Constructor Detail

LocaleAwareDecoder

public LocaleAwareDecoder()
Method Detail

setConfiguration

public void setConfiguration(Properties resourceConfig)
                      throws SmooksConfigurationException
Description copied from interface: Configurable
Set the component configuration.

Specified by:
setConfiguration in interface Configurable
Parameters:
resourceConfig - The component configuration properties.
Throws:
SmooksConfigurationException - Bad component configuration.

getConfiguration

public Properties getConfiguration()
Description copied from interface: Configurable
Get the component configuration.

Specified by:
getConfiguration in interface Configurable
Returns:
The component configuration properties.

getLocale

public Locale getLocale()
Get the configured Locale.

Does not return the default locale if locale is not configured. The implementation can interpret non-configuration in whatever way makes sense to that implementation, including defaulting it to the default locale.

Returns:
The configured Locale, or null if the locale is not configured.

getLocale

protected Locale getLocale(String languageCode,
                           String countryCode)
Returns a Locale matching the passed in languageCode, and countryCode

Parameters:
languageCode - lowercase two-letter ISO-639 code.
countryCode - uppercase two-letter ISO-3166 code.
Returns:
Locale matching the passed in languageCode and optionally the countryCode. If languageCode is null the default Locale will be returned.
Throws:
SmooksConfigurationException - if the Locale is not installed on the system

isLocalInstalled

protected boolean isLocalInstalled(Locale locale)


Copyright © 2018. All rights reserved.