com.funambol.common.pim.model.converter
Class TimeZoneHelper

java.lang.Object
  extended by com.funambol.common.pim.model.converter.TimeZoneHelper
Direct Known Subclasses:
CachedTimeZoneHelper

public class TimeZoneHelper
extends java.lang.Object

This class implements the time-zone conversions.

Version:
$Id: TimeZoneHelper.java,v 1.7 2008-08-27 10:58:39 mauro Exp $

Field Summary
protected  java.lang.String id
           
 
Constructor Summary
protected TimeZoneHelper()
          Just creates an empty TimeZoneHelper.
  TimeZoneHelper(Property tz, java.util.List<Property> daylightList)
          Creates a new instance of TimeZoneHelper on the basis of the information extracted from a vCalendar (1.0) item.
  TimeZoneHelper(java.lang.String id, long from, long to)
          Creates a new instance of TimeZoneHelper on the basis of a zoneinfo (Olson database) ID.
  TimeZoneHelper(VTimezone vTimeZone, long from, long to)
          Creates a new instance of TimeZoneHelper on the basis of the information extracted from an iCalendar (vCalendar 2.0) item.
 
Method Summary
protected  java.lang.String cacheID(java.lang.String id)
           
 void clearCachedID()
           
protected  long fixFrom(java.util.TimeZone tz, int standardOffset, long from)
           
protected  int getBasicOffset()
           
 java.util.List<Property> getDaylightList()
           
protected  java.util.List<ICalendarTimeZoneTransition> getICalendarTransitions()
           
protected  java.lang.String getName()
           
static long getReferenceTime()
           
protected  java.util.List<TimeZoneTransition> getTransitions()
           
 Property getTZ()
           
 VTimezone getVTimezone()
           
 java.util.List<Property> getXVCalendarProperties()
           
protected  void processID(java.lang.String id, long from, long to)
          Extract time-zone information from a zoneinfo (Olson database) ID and saves them in the TimeZoneHelper fields.
protected  void setName(java.lang.String name)
          This setter is only for test purposes.
static void setReferenceTime(long time)
           
 java.lang.String toID()
          Gets an Olson ID corresponding to the transitions and offsets saved.
 java.lang.String toID(java.lang.String suggested)
          Gets an Olson ID corresponding to the information saved and a suggestion.
 java.lang.String toID(java.util.TimeZone suggested)
          Gets an Olson ID corresponding to the information saved and a suggestion.
protected static VTimezone toVTimezone(java.util.List<ICalendarTimeZoneTransition> iCalendarTransitions, java.lang.String id, int basicOffset)
           
protected static int year(long time)
           
protected static int year(java.lang.String time)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

id

protected java.lang.String id
Constructor Detail

TimeZoneHelper

protected TimeZoneHelper()
Just creates an empty TimeZoneHelper. It's only for usage by subclasses.


TimeZoneHelper

public TimeZoneHelper(Property tz,
                      java.util.List<Property> daylightList)
               throws java.lang.Exception
Creates a new instance of TimeZoneHelper on the basis of the information extracted from a vCalendar (1.0) item.

Parameters:
tz - the TZ property
daylightList - a List containing all DAYLIGHT properties
Throws:
java.lang.Exception

TimeZoneHelper

public TimeZoneHelper(VTimezone vTimeZone,
                      long from,
                      long to)
               throws java.lang.Exception
Creates a new instance of TimeZoneHelper on the basis of the information extracted from an iCalendar (vCalendar 2.0) item.

Parameters:
vTimeZone -
from - the start of the relevant time interval for the generation of transitions (an istant expressed as a long)
to - the end of the relevant time interval for the generation of transitions (an istant expressed as a long)
Throws:
java.lang.Exception

TimeZoneHelper

public TimeZoneHelper(java.lang.String id,
                      long from,
                      long to)
Creates a new instance of TimeZoneHelper on the basis of a zoneinfo (Olson database) ID.

Parameters:
id - the time zone ID according to the zoneinfo (Olson) database
from - the start of the relevant time interval for the generation of transitions (an istant expressed as a long)
to - the end of the relevant time interval for the generation of transitions (an istant expressed as a long)
Method Detail

getName

protected java.lang.String getName()

setName

protected void setName(java.lang.String name)
This setter is only for test purposes. Usually, the name is set by constructors.

Parameters:
name - the new name to set

getBasicOffset

protected int getBasicOffset()

getTransitions

protected java.util.List<TimeZoneTransition> getTransitions()

processID

protected void processID(java.lang.String id,
                         long from,
                         long to)
Extract time-zone information from a zoneinfo (Olson database) ID and saves them in the TimeZoneHelper fields.

Parameters:
id - the time zone ID according to the zoneinfo (Olson) database
from - the start of the relevant time interval for the generation of transitions (an istant expressed as a long)
to - the end of the relevant time interval for the generation of transitions (an istant expressed as a long)

toID

public java.lang.String toID()
Gets an Olson ID corresponding to the transitions and offsets saved. First it looks for a cached ID. If it is not found, it looks for a matching ID among the favorite ones. Otherwise it looks for it among all available IDs with the same basic offset.

Returns:
a string containing the Olson ID or null if no matching ID is found

toID

public java.lang.String toID(java.lang.String suggested)
Gets an Olson ID corresponding to the information saved and a suggestion. First it looks for a cached ID. If it is not found, it checks if the saved name simply contains an Olson ID. If it does, it will be returned as the result without further investigation. If that is not the case, the suggested ID is checked against the transitions and offsets saved. If this also fails, it looks for a matching ID among the favorite ones. Otherwise it looks for it among all available IDs with the same basic offset.

Parameters:
suggested - the suggested ID (as a string)
Returns:
a string containing the Olson ID or null if no matching ID is found

toID

public java.lang.String toID(java.util.TimeZone suggested)
Gets an Olson ID corresponding to the information saved and a suggestion. First it looks for a cached ID. If it is not found, it checks if the saved name simply contains an Olson ID. If it does, it will be returned as the result without further investigation. If that is not the case, the ID of the suggested time zone is checked against the transitions and offsets saved. If this also fails, it looks for a matching ID among the favorite ones. Otherwise it looks for it among all available IDs with the same basic offset.

Parameters:
suggested - the suggested time zone (as a TimeZone object)
Returns:
a string containing the Olson ID or null if no matching ID is found

getTZ

public Property getTZ()

getDaylightList

public java.util.List<Property> getDaylightList()

getXVCalendarProperties

public java.util.List<Property> getXVCalendarProperties()

getVTimezone

public VTimezone getVTimezone()

getICalendarTransitions

protected java.util.List<ICalendarTimeZoneTransition> getICalendarTransitions()

cacheID

protected java.lang.String cacheID(java.lang.String id)

toVTimezone

protected static VTimezone toVTimezone(java.util.List<ICalendarTimeZoneTransition> iCalendarTransitions,
                                       java.lang.String id,
                                       int basicOffset)

year

protected static int year(long time)

year

protected static int year(java.lang.String time)
                   throws java.text.ParseException
Throws:
java.text.ParseException

clearCachedID

public void clearCachedID()

getReferenceTime

public static long getReferenceTime()

setReferenceTime

public static void setReferenceTime(long time)

fixFrom

protected long fixFrom(java.util.TimeZone tz,
                       int standardOffset,
                       long from)


Copyright © 2001-2009 Funambol.