org.milyn.javabean.decoders
Class LocaleAwareDateDecoder

java.lang.Object
  extended by org.milyn.javabean.decoders.LocaleAwareDateDecoder
Direct Known Subclasses:
CalendarDecoder, DateDecoder

public class LocaleAwareDateDecoder
extends Object

LocaleAwareDateDecoder is a decoder 'helper' that can be subclassed by Date decoders to enable them to use locale specific date formats.

 Usage:
 <resource-config selector="decoder:DecoderName">
      <resource>org.milyn.javabean.decoders.DateDecoder</resource>
      <param name="format">EEE MMM dd HH:mm:ss z yyyy</param>
 </resource-config>
 Optional parameters:
      <param name="locale-language">sv</param>
      <param name="locale-country">SE</param>
      <param name="verify-locale">false</param>
 

Author:
daniel.bevenius@gmail.com

Field Summary
protected  SimpleDateFormat decoder
           
static String DEFAULT_DATE_FORMAT
          Default date format string
protected  String format
           
static String FORMAT
          Date format configuration key.
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
LocaleAwareDateDecoder()
           
 
Method Summary
protected  Locale getLocale(String languageCode, String countryCode)
          Returns a Locale matching the passed in languageCode, and countryCode
protected  boolean isLocalInstalled(Locale locale)
           
 void setConfiguration(SmooksResourceConfiguration resourceConfig)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FORMAT

public static final String FORMAT
Date format configuration key.

See Also:
Constant Field Values

DEFAULT_DATE_FORMAT

public static final String DEFAULT_DATE_FORMAT
Default date format string

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

format

protected String format

decoder

protected SimpleDateFormat decoder
Constructor Detail

LocaleAwareDateDecoder

public LocaleAwareDateDecoder()
Method Detail

setConfiguration

public void setConfiguration(SmooksResourceConfiguration resourceConfig)
                      throws SmooksConfigurationException
Throws:
SmooksConfigurationException

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 © 2008. All Rights Reserved.