Package org.smooks.engine.converter
Class LocaleAwareTypeConverter<S,T>
- java.lang.Object
-
- org.smooks.engine.converter.LocaleAwareTypeConverter<S,T>
-
- All Implemented Interfaces:
org.smooks.api.converter.TypeConverter<S,T>,org.smooks.api.resource.config.Configurable
- Direct Known Subclasses:
DateLocaleAwareTypeConverter,NumberTypeConverter
public abstract class LocaleAwareTypeConverter<S,T> extends Object implements org.smooks.api.converter.TypeConverter<S,T>, org.smooks.api.resource.config.Configurable
LocaleAwareDecoder is a decoder 'helper' that can be subclassed by any DataDecoder implementation that relies onLocaleinformation to perform Data Decoding.- Author:
- daniel.bevenius@gmail.com
-
-
Field Summary
Fields Modifier and Type Field Description static StringLOCALELocale.static StringLOCALE_COUNTRY_CODEISO Country Code.static StringLOCALE_LANGUAGE_CODEISO Language Code.static StringVERIFY_LOCALETrue or false(default).
-
Constructor Summary
Constructors Constructor Description LocaleAwareTypeConverter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PropertiesgetConfiguration()LocalegetLocale()Get the configuredLocale.protected LocalegetLocale(String languageCode, String countryCode)Returns a Locale matching the passed in languageCode, and countryCodeprotected booleanisLocalInstalled(Locale locale)voidsetConfiguration(Properties properties)
-
-
-
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
-
-
Method Detail
-
setConfiguration
public void setConfiguration(Properties properties) throws org.smooks.api.SmooksConfigException
- Specified by:
setConfigurationin interfaceorg.smooks.api.resource.config.Configurable- Throws:
org.smooks.api.SmooksConfigException
-
getConfiguration
public Properties getConfiguration()
- Specified by:
getConfigurationin interfaceorg.smooks.api.resource.config.Configurable
-
getLocale
public Locale getLocale()
Get the configuredLocale. 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, ornullif 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:
org.smooks.api.SmooksConfigException- if the Locale is not installed on the system
-
isLocalInstalled
protected boolean isLocalInstalled(Locale locale)
-
-