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

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

public abstract class BaseConverter
extends java.lang.Object

Represent a converter base class. Provides some common methods.


Field Summary
protected  java.lang.String charset
           
static java.lang.String CHARSET_UTF7
           
static java.lang.String CHARSET_UTF8
           
static java.lang.String ENCODING_B64
           
static java.lang.String ENCODING_QP
           
protected  boolean forceClientLocalTime
           
static java.lang.String PLAIN_CHARSET
           
protected  java.util.Vector<java.lang.String> supportedFields
          Specifies the list of supported fields
protected  java.util.TimeZone timezone
           
 
Constructor Summary
BaseConverter(java.util.TimeZone timezone, java.lang.String charset)
          Deprecated.  
BaseConverter(java.util.TimeZone timezone, java.lang.String charset, boolean forceDeviceLocalTime)
           
 
Method Summary
 java.lang.StringBuffer composeICalTextComponent(Property property, java.lang.String field)
          Deprecated. Unused since version 6.5, replaced by methods in #com.funambol.common.pim.converter.CalendarContentConverter
protected  java.lang.StringBuffer composeRemainingFields()
          Compose the remaining fields from the supportedFields Vector.
 java.lang.StringBuffer composeVCardComponent(java.lang.String propertyValue, java.util.ArrayList properties, java.lang.String field)
          This method compose the single component of vCard and in particular: 1) encode value with the proper encoding 2) handle the params 3) create a representation of the specificated vCard field
 java.lang.StringBuffer composeVCardComponent(java.lang.String propertyValue, java.util.ArrayList properties, java.lang.String field, boolean excludeCharset)
          This method compose the single component of vCard and in particular: 1) encode value with the proper encoding 2) handle the params 3) create a representation of the specificated vCard field
 java.lang.String encode(java.lang.String value, java.lang.String encoding, java.lang.String charset)
          Replace values with proper encoding
 java.lang.String escapeSeparator(java.lang.String value)
          A SEMI-COLON in a property value MUST be escaped with a '\' character.
static java.lang.String handleConversionAcrossTimeZones(java.lang.String sDate, java.util.TimeZone timezoneIn, java.util.TimeZone timezoneOut)
          Converts the given sDate it in the local time of another time zone.
static java.lang.String handleConversionToAllDayDate(java.lang.String sDate)
          Converts the given sDate in all-day format using the given timezone
static java.lang.String handleConversionToAllDayDate(java.lang.String sDate, java.util.TimeZone timezoneIn, java.util.TimeZone timezoneOut)
          Converts the given sDate in all-day format
In the conversion the following rules are applied: if the given timezoneIn is not null, it is applied on the stringDate conversion if the given timezoneOut is not null, it is applied on the output date
static java.lang.String handleConversionToLocalDate(java.lang.String sDate, java.util.TimeZone timezone)
          Converts the given sDate it in local time using the given timezone
static java.lang.String handleConversionToUTCDate(java.lang.String sDate, java.util.TimeZone timezone)
          Converts the given sDate in UTC using the given timezone
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ENCODING_QP

public static final java.lang.String ENCODING_QP
See Also:
Constant Field Values

CHARSET_UTF8

public static final java.lang.String CHARSET_UTF8
See Also:
Constant Field Values

CHARSET_UTF7

public static final java.lang.String CHARSET_UTF7
See Also:
Constant Field Values

ENCODING_B64

public static final java.lang.String ENCODING_B64
See Also:
Constant Field Values

PLAIN_CHARSET

public static final java.lang.String PLAIN_CHARSET
See Also:
Constant Field Values

timezone

protected java.util.TimeZone timezone

charset

protected java.lang.String charset

forceClientLocalTime

protected boolean forceClientLocalTime

supportedFields

protected java.util.Vector<java.lang.String> supportedFields
Specifies the list of supported fields

Constructor Detail

BaseConverter

@Deprecated
public BaseConverter(java.util.TimeZone timezone,
                                java.lang.String charset)
Deprecated. 

This constructor is deprecated because to handle the date is need to know timezone but also if the dates must be converted in local time.

Parameters:
timezone - the timezone to use in the conversion
charset - the charset to use in the conversion

BaseConverter

public BaseConverter(java.util.TimeZone timezone,
                     java.lang.String charset,
                     boolean forceDeviceLocalTime)
Parameters:
timezone - the timezone to use in the conversion
charset - the charset to use in the conversion
forceDeviceLocalTime - true if the date must be converted in the device's local time, false otherwise.
Method Detail

handleConversionToUTCDate

public static java.lang.String handleConversionToUTCDate(java.lang.String sDate,
                                                         java.util.TimeZone timezone)
                                                  throws ConverterException
Converts the given sDate in UTC using the given timezone

Parameters:
sDate - String
timezone - TimeZone
Returns:
String
Throws:
ConverterException

handleConversionToLocalDate

public static java.lang.String handleConversionToLocalDate(java.lang.String sDate,
                                                           java.util.TimeZone timezone)
                                                    throws ConverterException
Converts the given sDate it in local time using the given timezone

Parameters:
sDate - String
timezone - TimeZone
Returns:
String
Throws:
ConverterException

handleConversionAcrossTimeZones

public static java.lang.String handleConversionAcrossTimeZones(java.lang.String sDate,
                                                               java.util.TimeZone timezoneIn,
                                                               java.util.TimeZone timezoneOut)
                                                        throws ConverterException
Converts the given sDate it in the local time of another time zone.

Parameters:
sDate - String
timezoneIn - TimeZone
timezoneOut - TimeZone
Returns:
String
Throws:
ConverterException

handleConversionToAllDayDate

public static java.lang.String handleConversionToAllDayDate(java.lang.String sDate)
                                                     throws ConverterException
Converts the given sDate in all-day format using the given timezone

Parameters:
sDate - as a String, in local time format
Returns:
String
Throws:
ConverterException

handleConversionToAllDayDate

public static java.lang.String handleConversionToAllDayDate(java.lang.String sDate,
                                                            java.util.TimeZone timezoneIn,
                                                            java.util.TimeZone timezoneOut)
                                                     throws ConverterException
Converts the given sDate in all-day format
In the conversion the following rules are applied:

Parameters:
sDate - the date to convert
timezoneIn - the timezone to apply to the given date
timezoneOut - the timezone to apply on the output date
Returns:
String the date into proper format
Throws:
ConverterException - if an error occurs

encode

public java.lang.String encode(java.lang.String value,
                               java.lang.String encoding,
                               java.lang.String charset)
                        throws ConverterException
Replace values with proper encoding

Parameters:
value - the value to apply the replacement
encoding - the encoding to use (default is QUOTED-PRINTABLE)
charset - the charset to use (default is UTF-8)
Returns:
String the value replaced
Throws:
ConverterException

composeVCardComponent

public java.lang.StringBuffer composeVCardComponent(java.lang.String propertyValue,
                                                    java.util.ArrayList properties,
                                                    java.lang.String field)
                                             throws ConverterException
This method compose the single component of vCard and in particular: 1) encode value with the proper encoding 2) handle the params 3) create a representation of the specificated vCard field

Parameters:
propertyValue - the value of vCard field
properties - a vector of params
field - the filed name
Returns:
String the representation of the specificated vCard field
Throws:
com.funambol.common.pim.converter.ConverterException - if an error occurs
ConverterException

composeVCardComponent

public java.lang.StringBuffer composeVCardComponent(java.lang.String propertyValue,
                                                    java.util.ArrayList properties,
                                                    java.lang.String field,
                                                    boolean excludeCharset)
                                             throws ConverterException
This method compose the single component of vCard and in particular: 1) encode value with the proper encoding 2) handle the params 3) create a representation of the specificated vCard field

Parameters:
propertyValue - the value of vCard field
properties - a vector of params
field - the filed name
excludeCharset - must the charset be not set ?
Returns:
String the representation of the given vCard field
Throws:
com.funambol.common.pim.converter.ConverterException - if an error occurs
ConverterException

composeICalTextComponent

public java.lang.StringBuffer composeICalTextComponent(Property property,
                                                       java.lang.String field)
                                                throws ConverterException
Deprecated. Unused since version 6.5, replaced by methods in #com.funambol.common.pim.converter.CalendarContentConverter

This method compose the single component of iCalendar and in particular: 1) encode value with the proper encoding 2) handle the params 3) create a representation of the specificated iCalendar field

Parameters:
value - the value of iCalendar field
properties - a vector of params
field - the field name
Returns:
the representation of the specificated iCalendar field as a StringBuffer object
Throws:
ConverterException

composeRemainingFields

protected java.lang.StringBuffer composeRemainingFields()
Compose the remaining fields from the supportedFields Vector.

Returns:

escapeSeparator

public java.lang.String escapeSeparator(java.lang.String value)
A SEMI-COLON in a property value MUST be escaped with a '\' character. A BACKSLASH in a property value MUST be escaped with a '\' character.

Parameters:
value - the value in which replaced the ; and the \


Copyright © 2001-2009 Funambol.