com.miginfocom.calendar.activity.iofilter
Class ICalendarImport

java.lang.Object
  extended by com.miginfocom.calendar.activity.iofilter.AbstractActivityIOPlugin
      extended by com.miginfocom.calendar.activity.iofilter.ICalendarImport
All Implemented Interfaces:
ActivityIOPlugin

public class ICalendarImport
extends AbstractActivityIOPlugin

iCalendar importer. Only for testing and com.miginfocom.demo. Not production quality and NOT supported.

Currently (2004-10-20) it can import all tested iCalendar files, and that really really fast.


Field Summary
protected  java.lang.Object[] catIDs
           
protected  java.lang.String fileName
           
protected  long lastMod
           
 
Constructor Summary
ICalendarImport()
           
ICalendarImport(java.lang.String fileName, java.lang.Object[] catIDs)
           
 
Method Summary
 CompositeRecurrence addRecurrenceInfo(java.lang.String recLine, CompositeRecurrence rec)
          Perses a recurrence and returns it
 java.lang.Object[] getCatIDs()
           
 long getDefaultPollInterval()
          Returns the filters suggested number of milliseconds that should pass between two update checks.
 java.lang.String getFileName()
           
 java.lang.Object getID()
          Returns an ID of the plugin.
 java.lang.String getName()
          Returns a name if the IO plugin
 java.util.ArrayList importICal()
           
 boolean isReadSupported()
          If the plugin can read activities
 boolean isWriteSupported()
          If the plugin can write activities
static java.util.Calendar parseDateTime(java.lang.String timePartStr)
           
static java.util.Calendar parseDateTimeFields(java.lang.String dateTime, java.util.TimeZone zone)
           
static java.util.LinkedList parseDateTimes(java.lang.String timePartStr, boolean expandToDayBoundary)
          Parses dates and date-times.
static java.lang.Integer parseDuration(java.lang.String dur)
          Parses duration in accordance with ISO 8601.
static MutableDateRange parsePeriod(java.lang.String perStr, java.util.TimeZone zone)
          Parses a period.
 Recurrence parseRecurrenceRule(java.lang.String rRuleTxt)
          Parses the content of a recur row.
 void pollUpdates()
          Called by this class when there is either a change in the subscriptions in the broker or the poll interval has passes.
 void setCatIDs(java.lang.Object[] catIDs)
           
 void setFileName(java.lang.String fileName)
           
protected  java.util.ArrayList splitCS(java.lang.String csStr)
          Returns a comma separated list as an array of objects
protected  Activity tranActivity(java.util.ArrayList evLines)
           
 
Methods inherited from class com.miginfocom.calendar.activity.iofilter.AbstractActivityIOPlugin
startAutoPoll
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fileName

protected java.lang.String fileName

catIDs

protected java.lang.Object[] catIDs

lastMod

protected long lastMod
Constructor Detail

ICalendarImport

public ICalendarImport()

ICalendarImport

public ICalendarImport(java.lang.String fileName,
                       java.lang.Object[] catIDs)
Method Detail

pollUpdates

public void pollUpdates()
Description copied from class: AbstractActivityIOPlugin
Called by this class when there is either a change in the subscriptions in the broker or the poll interval has passes.

Override this method and go check for the activities. When they are found and retrieved post them to the ActivityDepository.

Specified by:
pollUpdates in class AbstractActivityIOPlugin

getDefaultPollInterval

public long getDefaultPollInterval()
Description copied from interface: ActivityIOPlugin
Returns the filters suggested number of milliseconds that should pass between two update checks.

Returns:
The filters suggested number of milliseconds that should pass between two update checks. -1 means no auto-poll.

getID

public java.lang.Object getID()
Description copied from interface: ActivityIOPlugin
Returns an ID of the plugin. For recognition by an ActivityResolver for instance.

Returns:
An ID of the plugin. Not null.

getName

public java.lang.String getName()
Description copied from interface: ActivityIOPlugin
Returns a name if the IO plugin

Returns:
E.g. "Nick's iCalendar import/export plugin"

isReadSupported

public boolean isReadSupported()
Description copied from interface: ActivityIOPlugin
If the plugin can read activities

Returns:
If the plugin can read activities

isWriteSupported

public boolean isWriteSupported()
Description copied from interface: ActivityIOPlugin
If the plugin can write activities

Returns:
If the plugin can write activities

getCatIDs

public java.lang.Object[] getCatIDs()

setCatIDs

public void setCatIDs(java.lang.Object[] catIDs)

getFileName

public java.lang.String getFileName()

setFileName

public void setFileName(java.lang.String fileName)

importICal

public java.util.ArrayList importICal()

tranActivity

protected Activity tranActivity(java.util.ArrayList evLines)

addRecurrenceInfo

public CompositeRecurrence addRecurrenceInfo(java.lang.String recLine,
                                             CompositeRecurrence rec)
Perses a recurrence and returns it

Parameters:
recLine - The whole recurrence line
rec - The recurrence to add to or null to creat a new one.
Returns:
rec or a newly created one if rec was null.

parseRecurrenceRule

public Recurrence parseRecurrenceRule(java.lang.String rRuleTxt)
Parses the content of a recur row.

Parameters:
rRuleTxt - Everything after "RRULEx" or "EXRULEx".
Returns:
A new Recurrence, never null.

splitCS

protected java.util.ArrayList splitCS(java.lang.String csStr)
Returns a comma separated list as an array of objects

Parameters:
csStr - A comma separated list
Returns:
An array, at least of size 1 and never null

parseDateTime

public static java.util.Calendar parseDateTime(java.lang.String timePartStr)

parseDateTimes

public static java.util.LinkedList parseDateTimes(java.lang.String timePartStr,
                                                  boolean expandToDayBoundary)
Parses dates and date-times. Sets date ranges to DateRangeI.getHasTime() to false if only date is specified, even if it is expanded with the parameter expandToDayBoundary.

Parameters:
expandToDayBoundary - If true dates with no time will be expanded to the whole day IF asRanges is set.
Returns:
A list of ImmutableDateRange objects.

parsePeriod

public static MutableDateRange parsePeriod(java.lang.String perStr,
                                           java.util.TimeZone zone)
Parses a period. E.g. "19960403T020000Z/19960403T040000Z" or "19960404T010000Z/PT3H"

Returns:
Not null but can throw exceptions.

parseDateTimeFields

public static java.util.Calendar parseDateTimeFields(java.lang.String dateTime,
                                                     java.util.TimeZone zone)
Parameters:
dateTime - Should be trimmed and uppercase.
Returns:
null or the date/time

parseDuration

public static java.lang.Integer parseDuration(java.lang.String dur)
Parses duration in accordance with ISO 8601. Quite lenient.

Parameters:
dur - Duration. Need not be upper case
Returns:
null if error or the relative duration in seconds. Can be negative.


Copyright © 2009 MiG InfoCom AB. All Rights Reserved.