com.miginfocom.util.dates
Class DefaultDateStringProvider

java.lang.Object
  extended by com.miginfocom.util.dates.DefaultDateStringProvider
All Implemented Interfaces:
DateStringProvider, StringProvider, java.io.Serializable

public class DefaultDateStringProvider
extends java.lang.Object
implements DateStringProvider, java.io.Serializable

An implementation that interprets the formatting object sent in and return an appropriate string.

See Also:
Serialized Form

Constructor Summary
DefaultDateStringProvider(java.lang.Object format)
          Constructor for a dateAlign of 0.5.
DefaultDateStringProvider(java.lang.Object format, double dateAlign)
          Constructor.
 
Method Summary
 double getDateAlign()
          Returns where between the start and end millisecond of the date range the millisecond is that should be used to format the date.
 DateRangeI getDateRange()
          Property: The date range that is used for providing string.
 java.lang.Object getFormat()
          Returns the object sent into the constructor.
 java.lang.String getString(int ix)
          Returns the string for the index.
 int getStringCount()
          Returns the number of strings this provider can provide.
 void setDateRange(DateRangeI dateRange)
          Property: The date range that is used for providing string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultDateStringProvider

public DefaultDateStringProvider(java.lang.Object format)
Constructor for a dateAlign of 0.5.

Parameters:
format - If DateFormat, DateFormatList or StringProvider the middle millisecond in the date range will be sent to these objects for formatting. If the object is not recognized a simple .toString() will be returned in setDateRange(com.miginfocom.util.dates.DateRangeI) and the dateRange will be disregarded.

For the serialization and XML persistance to work this object should be XML persistable. See IOUtil.setDelegate(Class, java.beans.PersistenceDelegate).


DefaultDateStringProvider

public DefaultDateStringProvider(java.lang.Object format,
                                 double dateAlign)
Constructor.

Parameters:
format - If DateFormat, DateFormatList or StringProvider the middle millisecond in the date range will be sent to these objects for formatting. If the object is not recognized a simple .toString() will be returned in setDateRange(com.miginfocom.util.dates.DateRangeI) and the dateRange will be disregarded.

For the serialization and XML persistance to work this object should be XML persistable. See IOUtil.setDelegate(Class, java.beans.PersistenceDelegate).

dateAlign - Where between the start and end millisecond of the date range the millisecond is that should be used to format the date. For instance 0.5 means the middle and 0.0 at the start.
Method Detail

getDateRange

public DateRangeI getDateRange()
Description copied from interface: DateStringProvider
Property: The date range that is used for providing string.

Specified by:
getDateRange in interface DateStringProvider
Returns:
The current date range. May be null.

setDateRange

public void setDateRange(DateRangeI dateRange)
Description copied from interface: DateStringProvider
Property: The date range that is used for providing string.

Specified by:
setDateRange in interface DateStringProvider
Parameters:
dateRange - A date range. Should handle null and return something appropriate for the current time.

getString

public java.lang.String getString(int ix)
Description copied from interface: StringProvider
Returns the string for the index. Throws exception if ix is >= the size

Specified by:
getString in interface StringProvider
Parameters:
ix - The index.
Returns:
The string for the index. Never null.

getStringCount

public int getStringCount()
Description copied from interface: StringProvider
Returns the number of strings this provider can provide.

Specified by:
getStringCount in interface StringProvider
Returns:
The number of strings this provider can provide.

getFormat

public java.lang.Object getFormat()
Returns the object sent into the constructor.

Returns:
The object sent into the constructor. Never null.

getDateAlign

public double getDateAlign()
Returns where between the start and end millisecond of the date range the millisecond is that should be used to format the date. For instance 0.5 means the middle and 0.0 at the start.

Returns:
Where between the start and end millisecond of the date range the millisecond is that should be used to format the date.


Copyright © 2009 MiG InfoCom AB. All Rights Reserved.