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

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

public class VCalendarConverter
extends BaseConverter

This object is a converter from a Calendar object model to a VCalendar string

Version:
$Id: VCalendarConverter.java,v 1.13 2008-09-03 09:51:04 mauro Exp $
See Also:
Converter

Field Summary
 
Fields inherited from class com.funambol.common.pim.model.converter.BaseConverter
charset, CHARSET_UTF7, CHARSET_UTF8, ENCODING_B64, ENCODING_QP, forceClientLocalTime, PLAIN_CHARSET, supportedFields, timezone
 
Constructor Summary
VCalendarConverter(java.util.TimeZone timezone, java.lang.String charset)
          Deprecated. 
VCalendarConverter(java.util.TimeZone timezone, java.lang.String charset, boolean forceClientLocalTime)
           
 
Method Summary
static java.lang.String addCRBeforeEachLF(java.lang.String raw)
           
protected  void addXParams(java.lang.StringBuffer paramList, Property prop)
          Added X-Param to the input list of the property parameters The buffer iterates throguh the parameters and adds the start parameter char ';' and then the parameter.
 VCalendar calendar2vcalendar(Calendar cal, boolean xv)
          Performs the Calendar-to-VCalendar conversion.
protected  Property composeDateTimeField(java.lang.String label, PropertyWithTimeZone property, boolean allDay, boolean xvCalendar)
           
protected  Property composeDateTimeField(java.lang.String label, PropertyWithTimeZone property, boolean allDay, boolean xvCalendar, boolean isRecurrence)
           
protected  Property composeField(java.lang.String label, Property property, boolean xvCalendar)
           
 java.lang.String convert(java.lang.Object obj)
           
protected  PropertyWithTimeZone decodeDateTimeField(Property property, java.util.TimeZone fieldTimezone)
           
protected  Property decodeField(Property property)
           
protected  java.lang.Short decodeShortField(Property property)
           
protected  java.util.Map<java.lang.String,java.lang.String> getParameters(Property property)
          Creates an HashMap with the X-Param set extracted from a com.funambol.common.pim.model.Property object.
protected  java.util.List<Parameter> getXParams(Property property)
          Creates an ArrayList with the X-Param set extracted from a com.funambol.common.pim.common.Property object.
static java.lang.String iCalEscape(java.lang.String raw)
           
static boolean isComplexProperty(java.lang.String name)
          This method is used to recognize those properties that could have a complex (ie, made of different semicolon-separated and comma-separated parts) content.
static boolean isQPProperty(java.lang.String name)
          This method is used to recognize those properties that have been decided to be encoded with Quoted-Printable.
 Calendar vcalendar2calendar(VCalendar vcal)
          Performs the VCalendar-to-Calendar conversion, finding out automatically which type of calendar (Event or Todo) it is.
static java.lang.String vCalEscape(java.lang.String raw)
           
static java.lang.String vCalEscapeButKeepNewlines(java.lang.String raw)
           
static java.lang.String vCalUnescape(java.lang.String raw)
           
 
Methods inherited from class com.funambol.common.pim.model.converter.BaseConverter
composeICalTextComponent, composeRemainingFields, composeVCardComponent, composeVCardComponent, encode, escapeSeparator, handleConversionAcrossTimeZones, handleConversionToAllDayDate, handleConversionToAllDayDate, handleConversionToLocalDate, handleConversionToUTCDate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VCalendarConverter

@Deprecated
public VCalendarConverter(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.


VCalendarConverter

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

convert

public java.lang.String convert(java.lang.Object obj)
                         throws ConverterException
Throws:
ConverterException

vcalendar2calendar

public Calendar vcalendar2calendar(VCalendar vcal)
                            throws ConverterException
Performs the VCalendar-to-Calendar conversion, finding out automatically which type of calendar (Event or Todo) it is.

Parameters:
vcal - the VCalendar object to be converted
Returns:
a Calendar containing the converted representation of this VCalendar
Throws:
com.funambol.common.pim.converter.ConverterException
ConverterException

calendar2vcalendar

public VCalendar calendar2vcalendar(Calendar cal,
                                    boolean xv)
                             throws ConverterException
Performs the Calendar-to-VCalendar conversion.

Parameters:
cal - the Calendar object to be converted
xv - true if the text/x-vcalendar format must be used while generating some properties of the VCalendar output object
Returns:
a VCalendar containing the converted representation of this Calendar
Throws:
com.funambol.common.pim.converter.ConverterException
ConverterException

getParameters

protected java.util.Map<java.lang.String,java.lang.String> getParameters(Property property)
Creates an HashMap with the X-Param set extracted from a com.funambol.common.pim.model.Property object. The encoding and charset parameters are ignored.

Parameters:
property - the Property object (containing the X-Param ArrayList)
Returns:
a list of X-Param's

getXParams

protected java.util.List<Parameter> getXParams(Property property)
Creates an ArrayList with the X-Param set extracted from a com.funambol.common.pim.common.Property object.

Parameters:
property - the Property object (containing the X-Param HashMap)
Returns:
a list of X-Param's

addXParams

protected void addXParams(java.lang.StringBuffer paramList,
                          Property prop)
Added X-Param to the input list of the property parameters The buffer iterates throguh the parameters and adds the start parameter char ';' and then the parameter. Avoids the add the starting ';' by the caller and delete the trailing ';' here.

Parameters:
paramList - the list of standard param
prop - the property object

composeField

protected Property composeField(java.lang.String label,
                                Property property,
                                boolean xvCalendar)
Parameters:
label -
property -
xvCalendar - true only if this property is part of a vCalendar (1.0) item, false if it is part of an iCalendar (2.0)
Returns:
a representation of the event field

decodeShortField

protected java.lang.Short decodeShortField(Property property)

composeDateTimeField

protected Property composeDateTimeField(java.lang.String label,
                                        PropertyWithTimeZone property,
                                        boolean allDay,
                                        boolean xvCalendar)
Parameters:
label -
property -
allDay -
xvCalendar -
Returns:

composeDateTimeField

protected Property composeDateTimeField(java.lang.String label,
                                        PropertyWithTimeZone property,
                                        boolean allDay,
                                        boolean xvCalendar,
                                        boolean isRecurrence)

decodeField

protected Property decodeField(Property property)

decodeDateTimeField

protected PropertyWithTimeZone decodeDateTimeField(Property property,
                                                   java.util.TimeZone fieldTimezone)

isComplexProperty

public static boolean isComplexProperty(java.lang.String name)
This method is used to recognize those properties that could have a complex (ie, made of different semicolon-separated and comma-separated parts) content. For such properties, the content saved into the DB is not unescaped, in order to keep the difference between "true" (ie, escaped) commas and semicolons and those used as separators (ie, unescaped).

Parameters:
name - the name of the property, as a String
Returns:
true if the property can have, according to the specification, a complex content and therefore mustn't be (un)escaped

isQPProperty

public static boolean isQPProperty(java.lang.String name)
This method is used to recognize those properties that have been decided to be encoded with Quoted-Printable. This information is to be used only in the Calendar-to-VCalendar side of the converter.

Parameters:
name - the name of the property, as a String
Returns:
true if the property must be QP-encoded

vCalEscapeButKeepNewlines

public static java.lang.String vCalEscapeButKeepNewlines(java.lang.String raw)

vCalEscape

public static java.lang.String vCalEscape(java.lang.String raw)

iCalEscape

public static java.lang.String iCalEscape(java.lang.String raw)

vCalUnescape

public static java.lang.String vCalUnescape(java.lang.String raw)

addCRBeforeEachLF

public static java.lang.String addCRBeforeEachLF(java.lang.String raw)


Copyright © 2001-2009 Funambol.