org.norther.tammi.core.converter
Class DefaultDateConverter

java.lang.Object
  extended by org.norther.tammi.core.base.Adaptee
      extended by org.norther.tammi.core.converter.DefaultObjectConverter
          extended by org.norther.tammi.core.converter.DefaultDateConverter
All Implemented Interfaces:
Serializable, NotificationBroadcaster, NotificationEmitter, Manageable, MBeanDelegate, DateConverter, ObjectConverter

public class DefaultDateConverter
extends DefaultObjectConverter
implements DateConverter

A default implementation of DateConverter.

Author:
Marketta Priha
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.norther.tammi.core.base.Adaptee
ADAPTEE_NOTIF_DESCRIPTION, ADAPTEE_NOTIFICATIONS
 
Fields inherited from interface org.norther.tammi.core.converter.DateConverter
DEFAULT_STYLE, FULL_STYLE, LONG_STYLE, MEDIUM_STYLE, SHORT_STYLE
 
Fields inherited from interface org.norther.tammi.core.base.MBeanDelegate
ARRAY_TYPE, OBJECT_TYPE, PRIMITIVE_TYPE, STRING_TYPE
 
Constructor Summary
DefaultDateConverter()
          Constructs a new converter.
 
Method Summary
 Set classNameSet()
          Returns a read-only set of class names of defined patterns.
 void clearClassSpecificPatterns()
          Clears all class specific patterns.
 void clearLocalPatternChars()
          Clears all locale specific pattern chars.
 String getClassSpecificPattern(String className)
          Gets the class specific default date pattern.
 DateFormat getDateFormat(String pattern)
          Gets a date format for the specified pattern.
 DateFormat getDateFormat(String pattern, Locale locale)
          Gets a date format for the specified pattern and locale.
 DateFormat getDateFormat(String className, String pattern)
          Gets a date format for the specified class and pattern.
 DateFormat getDateFormat(String className, String pattern, Locale locale)
          Gets a date format for the specified class, pattern and locale.
 String getDefaultPattern()
          Gets the default date pattern.
 String getFormatPattern(String className, String pattern, Locale locale)
          Gets the format pattern.
 Object getInstance(String className, Object object, String pattern, Object minValue, Object maxValue)
          Gets an instance of the named class by converting the source object and optionally applying the specified pattern and limits.
 Object getInstance(String className, Object object, String pattern, Object minValue, Object maxValue, Locale locale, ResourceBundle bundle)
          Gets an instance of the named class by converting the localized source resource and optionally applying the specified pattern and limits.
protected  DateFormatSymbols getLocalFormatSymbols(Locale locale)
          Gets the locale specific format symbols.
 String getLocalizedPattern(String className, String pattern, Locale locale)
          Gets the localized format pattern.
 String getLocalPatternChars(Locale locale)
          Gets the locale specific pattern chars.
 String getTimeZoneId()
          Gets the default time zone to apply.
 boolean isConversionSupported(String className)
          Checks whether conversion of the specified class is supported.
 Set patternLocaleSet()
          Returns a read-only set of locales with defined pattern chars.
 void removeClassSpecificPattern(String className)
          Removes the class specific default date pattern.
 void removeLocalPatternChars(Locale locale)
          Removes the locale specific pattern chars.
 void setClassSpecificPattern(String className, String pattern)
          Sets the class specific default date pattern.
 void setDefaultPattern(String pattern)
          Sets the default date pattern.
 void setLocalPatternChars(Locale locale, String chars)
          Sets the locale specific pattern chars.
 void setTimeZoneId(String id)
          Sets the default time zone to apply.
 List timeZoneIds()
          Returns a list of supported time zone ids.
 Date toDate(long msecs)
          Converts milliseconds to date.
 String toString(String className, Object object, String pattern)
          Returns a string representation of an object of the named class by optionally applying the specified pattern.
 String toString(String className, Object object, String pattern, Locale locale, ResourceBundle bundle)
          Returns a localized resource of the named class by optionally applying the specified pattern.
 long toTime(Date date)
          Converts a date to milliseconds.
 
Methods inherited from class org.norther.tammi.core.converter.DefaultObjectConverter
fromLocalizedObject, getComponentInstance, getInstance, getResourceFinderName, postmanaged, setResourceFinderName, toComponentString, toLocalizedObject, toString, toStrings, toStrings, toStrings, unmanaged
 
Methods inherited from class org.norther.tammi.core.base.Adaptee
addAdaptee, addNotificationListener, getAttributeSupport, getBroker, getCanonicalName, getDomain, getFactory, getLoader, getLog, getLog, getMBean, getMBeanServer, getNotificationInfo, getObjectName, getRegistrationTime, getSequenceNumber, hasListeners, isRegistered, premanaged, removeNotificationListener, removeNotificationListener, sendNotification, sendNotification, sendNotification, sendNotification, unregister
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.norther.tammi.core.converter.ObjectConverter
getInstance, getResourceFinderName, setResourceFinderName, toString, toStrings, toStrings, toStrings
 

Constructor Detail

DefaultDateConverter

public DefaultDateConverter()
Constructs a new converter.

Method Detail

getDefaultPattern

public String getDefaultPattern()
Description copied from interface: DateConverter
Gets the default date pattern.

Specified by:
getDefaultPattern in interface DateConverter
Returns:
the default date pattern.

setDefaultPattern

public void setDefaultPattern(String pattern)
Description copied from interface: DateConverter
Sets the default date pattern.

Specified by:
setDefaultPattern in interface DateConverter
Parameters:
pattern - the default date pattern.

getClassSpecificPattern

public String getClassSpecificPattern(String className)
Description copied from interface: DateConverter
Gets the class specific default date pattern.

Specified by:
getClassSpecificPattern in interface DateConverter
Parameters:
className - the class name of the pattern.
Returns:
the class specific default date pattern.

setClassSpecificPattern

public void setClassSpecificPattern(String className,
                                    String pattern)
Description copied from interface: DateConverter
Sets the class specific default date pattern.

Specified by:
setClassSpecificPattern in interface DateConverter
Parameters:
className - the class name of the pattern.
pattern - the class specific default date pattern.

removeClassSpecificPattern

public void removeClassSpecificPattern(String className)
Description copied from interface: DateConverter
Removes the class specific default date pattern.

Specified by:
removeClassSpecificPattern in interface DateConverter
Parameters:
className - the class name of the pattern.

clearClassSpecificPatterns

public void clearClassSpecificPatterns()
Description copied from interface: DateConverter
Clears all class specific patterns.

Specified by:
clearClassSpecificPatterns in interface DateConverter

classNameSet

public Set classNameSet()
Description copied from interface: DateConverter
Returns a read-only set of class names of defined patterns.

Specified by:
classNameSet in interface DateConverter
Returns:
a set of class names.

getLocalPatternChars

public String getLocalPatternChars(Locale locale)
Description copied from interface: DateConverter
Gets the locale specific pattern chars.

Specified by:
getLocalPatternChars in interface DateConverter
Parameters:
locale - the locale.
Returns:
the pattern chars.

setLocalPatternChars

public void setLocalPatternChars(Locale locale,
                                 String chars)
Description copied from interface: DateConverter
Sets the locale specific pattern chars.

Specified by:
setLocalPatternChars in interface DateConverter
Parameters:
locale - the locale.
chars - the pattern chars.

removeLocalPatternChars

public void removeLocalPatternChars(Locale locale)
Description copied from interface: DateConverter
Removes the locale specific pattern chars.

Specified by:
removeLocalPatternChars in interface DateConverter
Parameters:
locale - the locale.

clearLocalPatternChars

public void clearLocalPatternChars()
Description copied from interface: DateConverter
Clears all locale specific pattern chars.

Specified by:
clearLocalPatternChars in interface DateConverter

patternLocaleSet

public Set patternLocaleSet()
Description copied from interface: DateConverter
Returns a read-only set of locales with defined pattern chars.

Specified by:
patternLocaleSet in interface DateConverter
Returns:
a set of locales.

getTimeZoneId

public String getTimeZoneId()
Description copied from interface: DateConverter
Gets the default time zone to apply.

Specified by:
getTimeZoneId in interface DateConverter
Returns:
the time zone id.

setTimeZoneId

public void setTimeZoneId(String id)
Description copied from interface: DateConverter
Sets the default time zone to apply.

Note that this method changes the default time zone of the running JVM to the specified value and thus may interfere with other date functionality.

Specified by:
setTimeZoneId in interface DateConverter
Parameters:
id - the time zone id.

timeZoneIds

public List timeZoneIds()
Description copied from interface: DateConverter
Returns a list of supported time zone ids.

Specified by:
timeZoneIds in interface DateConverter
Returns:
a list of time zone ids.

getDateFormat

public DateFormat getDateFormat(String pattern)
Description copied from interface: DateConverter
Gets a date format for the specified pattern.

Specified by:
getDateFormat in interface DateConverter
Parameters:
pattern - the pattern.
Returns:
the requested date format.
See Also:
DateFormat

getDateFormat

public DateFormat getDateFormat(String pattern,
                                Locale locale)
Description copied from interface: DateConverter
Gets a date format for the specified pattern and locale.

Specified by:
getDateFormat in interface DateConverter
Parameters:
pattern - the pattern.
locale - the locale.
Returns:
the requested date format.
See Also:
DateFormat

getDateFormat

public DateFormat getDateFormat(String className,
                                String pattern)
Description copied from interface: DateConverter
Gets a date format for the specified class and pattern.

Specified by:
getDateFormat in interface DateConverter
Parameters:
className - the name of the class to format.
pattern - the pattern.
Returns:
the requested date format.
See Also:
DateFormat

getDateFormat

public DateFormat getDateFormat(String className,
                                String pattern,
                                Locale locale)
Description copied from interface: DateConverter
Gets a date format for the specified class, pattern and locale.

Specified by:
getDateFormat in interface DateConverter
Parameters:
className - the name of the class to format.
pattern - the pattern.
locale - the locale.
Returns:
the requested date format.
See Also:
DateFormat

toTime

public long toTime(Date date)
Description copied from interface: DateConverter
Converts a date to milliseconds.

Specified by:
toTime in interface DateConverter
Parameters:
date - the date.
Returns:
the date in millis.

toDate

public Date toDate(long msecs)
Description copied from interface: DateConverter
Converts milliseconds to date.

Specified by:
toDate in interface DateConverter
Parameters:
msecs - the millis.
Returns:
the millis as date.

getInstance

public Object getInstance(String className,
                          Object object,
                          String pattern,
                          Object minValue,
                          Object maxValue)
                   throws ConversionException
Description copied from interface: ObjectConverter
Gets an instance of the named class by converting the source object and optionally applying the specified pattern and limits.

Specified by:
getInstance in interface ObjectConverter
Overrides:
getInstance in class DefaultObjectConverter
Parameters:
className - the name of the class.
object - the source object.
pattern - an optional conversion pattern.
minValue - an optional minimum value.
maxValue - an optional maximum value.
Returns:
the instance.
Throws:
ConversionException - if conversion fails.

getInstance

public Object getInstance(String className,
                          Object object,
                          String pattern,
                          Object minValue,
                          Object maxValue,
                          Locale locale,
                          ResourceBundle bundle)
                   throws ConversionException
Description copied from interface: ObjectConverter
Gets an instance of the named class by converting the localized source resource and optionally applying the specified pattern and limits.

Specified by:
getInstance in interface ObjectConverter
Overrides:
getInstance in class DefaultObjectConverter
Parameters:
className - the name of the class.
object - the source object.
pattern - an optional conversion pattern.
minValue - an optional minimum value.
maxValue - an optional maximum value.
locale - the locale of the source object.
bundle - the resource bundle to apply.
Returns:
the instance.
Throws:
ConversionException - if conversion fails.

toString

public String toString(String className,
                       Object object,
                       String pattern)
Description copied from interface: ObjectConverter
Returns a string representation of an object of the named class by optionally applying the specified pattern.

Specified by:
toString in interface ObjectConverter
Overrides:
toString in class DefaultObjectConverter
Parameters:
className - the name of the class.
object - the source object.
pattern - an optional conversion pattern.
Returns:
the string representation.

toString

public String toString(String className,
                       Object object,
                       String pattern,
                       Locale locale,
                       ResourceBundle bundle)
Description copied from interface: ObjectConverter
Returns a localized resource of the named class by optionally applying the specified pattern.

Specified by:
toString in interface ObjectConverter
Overrides:
toString in class DefaultObjectConverter
Parameters:
className - the name of the class.
object - the source object.
pattern - the conversion pattern.
locale - the optional locale of the result.
bundle - the resource bundle to apply.
Returns:
the string resource.

isConversionSupported

public boolean isConversionSupported(String className)
Description copied from interface: ObjectConverter
Checks whether conversion of the specified class is supported.

Specified by:
isConversionSupported in interface ObjectConverter
Overrides:
isConversionSupported in class DefaultObjectConverter
Parameters:
className - the class name.
Returns:
true for a supported conversion, false otherwise.

getFormatPattern

public String getFormatPattern(String className,
                               String pattern,
                               Locale locale)
Description copied from interface: ObjectConverter
Gets the format pattern.

Specified by:
getFormatPattern in interface ObjectConverter
Overrides:
getFormatPattern in class DefaultObjectConverter
Parameters:
className - the class name.
pattern - the conversion pattern.
locale - an optional locale to apply.
Returns:
the format pattern or the conversion pattern if the same.

getLocalizedPattern

public String getLocalizedPattern(String className,
                                  String pattern,
                                  Locale locale)
Description copied from interface: ObjectConverter
Gets the localized format pattern.

Specified by:
getLocalizedPattern in interface ObjectConverter
Overrides:
getLocalizedPattern in class DefaultObjectConverter
Parameters:
className - the class name.
pattern - the conversion pattern.
locale - an optional locale to apply.
Returns:
the localized pattern or the conversion pattern if the same.

getLocalFormatSymbols

protected DateFormatSymbols getLocalFormatSymbols(Locale locale)
Gets the locale specific format symbols.

Parameters:
locale - the locale.
Returns:
the format symbols or null.


Copyright © 2004 The Norther Organization. All rights reserved.