k5n.us
X Home X X News X X Apps/Tools X X Services X X Support X X Downloads X X Articles X X Contact X
k5n Java Calendar Tools
 AboutLicensingPlansTutorialDownloadDevelopersLinks 

Tutorial

Of course, this is all hypothetical and up for debate since the code has not yet been released :-)

The Event object holds a single ical event and includes information about any recurrence. (There will eventually by similar Todo, Journal and Freebusy objects.)

Typically, The IcalParser object is the container for the ical data. (You can override this by creating your own class that implements the DataStore interface. If not, the IcalParser class will handle all storage of iCal data.) It includes an API for querying events for specific categories and/or time ranges.



Overview of public classes:


  • us.k5n.ical
    • BogusDataException.java
    • Categories.java
    • Date.java
    • Event.java
    • Freebusy.java
    • IcalParser.java
    • ParseError.java
    • ParseException.java
    • StringUtils.java
    • Timezone.java
    • Todo.java


Parsing an iCal File:


import java.io.File;
import java.io.BufferedReader;
import java.io.IOException;
import java.util.Vector;
import us.k5n.calendar.IcalParser;
import us.k5n.calendar.Event;
import us.k5n.calendar.Todo;

...

  IcalParser parser;
  File icalFile = new File ( "/tmp/example.ics" );
  try {
    BufferedReader r = new BufferedReader ( new FileReader ( icalFile ) );
    parser.parse ( r );
  } catch ( IOException e ) {
    // ... report error
  }
  r.close ();
  Vector events = parser.getAllEvents ();
  for ( int i = 0; i < events.size(); i++ ) {
    Event e = (Event) events.elementAt ( i );
    System.out.println ( "Event: " + e.getSummary () );
  }
  TodoList todo = parser.getAllTodo (); // get to-do entries
  for ( int i = 0; i < todo.size(); i++ ) {
    Todo t = (Todo) todo.elementAt ( i );
    System.out.println ( "Todo: " + t.getSummary () );
  }
  ...


Donate

SourceForge.net Logo

Valid XHTML 1.0 Valid CSS PHP
Page Last Updated: 10-Jul-2006
Copyright ©2004-2013 Craig Knudsen, All Rights Reserved