/**
  *  Returns a new component for a passed File_iCal_{Event, Alarm, FreeBusy, TimeZone, ToDo}
  *
  *  @access  public
  *  @static
  *  @param  object  $e  The event for which you wish to return a component object
  *  @return File_iCal_Component_Event   The new component object
  */
 public static function getComponent($e)
 {
     //ideally we call the component constructor with an array of contentlines
     $props = array();
     $component_name = "";
     //print_r($e);
     switch (get_class($e)) {
         case "File_iCal_Alarm":
             $component_name = "VALARM";
             break;
         case "File_iCal_Event":
             $component_name = "VEVENT";
             break;
         case "File_iCal_FreeBusy":
             $component_name = "VFREEBUSY";
             break;
         case "File_iCal_TimeZone":
             $component_name = "VTIMEZONE";
             break;
         case "File_iCal_ToDo":
             $component_name = "VTODO";
             break;
         case "File_iCal_Journal":
             $component_name = "VJOURNAL";
             break;
         default:
             trigger_error("Passed object not valid type (is a " . get_class($e) . ")", E_USER_WARNING);
     }
     require_once 'File/iCal/Property.php';
     $props[] = File_iCal_Property::getProperty("BEGIN", array(), $component_name);
     //attachment is defined in the basecomponent class, so method_exists is always true
     if (is_subclass_of($e, "File_iCal_BaseComponent_EJT") || is_a($e, "File_iCal_Alarm")) {
     }
     //needs to be finished
     if (is_subclass_of($e, "File_iCal_BaseComponent_EFJT") || is_a($e, "File_iCal_TimeZone")) {
         foreach ($e->getComments() as $c) {
         }
     }
     //this method is defined in the BaseComponent class, so it always exists
     //method should only be public for AEJT
     if (is_subclass_of($e, "File_iCal_BaseComponent_EJT") || is_a($e, "File_iCal_Alarm")) {
         if ($description = $e->getDescription()) {
             $props[] = File_iCal_Property::getProperty("DESCRIPTION", array(), $description);
         }
     }
     if (is_subclass_of($e, "File_iCal_BaseComponent_EJT") || is_a($e, "File_iCal_Alarm")) {
         if ($summary = $e->getSummary()) {
             $props[] = File_iCal_Property::getProperty("SUMMARY", array(), $summary);
         }
     }
     if (is_a($e, "File_iCal_Event") || is_a($e, "File_iCal_FreeBusy")) {
         if (($de = $e->getDateEnd()) > 0) {
             $props[] = File_iCal_Property::getProperty("DTEND", array(), $de);
         }
     }
     if (is_subclass_of($e, "File_iCal_BaseComponent_EFJT")) {
         if (($ds = $e->getDateStart()) > 0) {
             $props[] = File_iCal_Property::getProperty("DTSTART", array(), $ds);
         }
     }
     if (is_subclass_of($e, "File_iCal_BaseComponent_ET") || is_a($e, "File_iCal_Alarm") || is_a($e, "File_iCal_FreeBusy")) {
         if (($dur = $e->getDuration()) > 0) {
             $props[] = File_iCal_Property::getProperty("DURATION", array(), $dur);
         }
     }
     //should be changed
     if (method_exists($e, "getAttendees")) {
     }
     if (is_subclass_of($e, "File_iCal_BaseComponent_EJT") || is_a($e, "File_iCal_TimeZone")) {
     }
     if (method_exists($e, "getContacts")) {
     }
     if (method_exists($e, "getOrganizer")) {
         if ($o = $e->getOrganizer()) {
             $props[] = File_iCal_Property::getProperty("ORGANIZER", array(), $o);
         }
     }
     if (method_exists($e, "getURL")) {
         if ($url = $e->getURL()) {
             $props[] = File_iCal_Property::getProperty("URL", array(), $url);
         }
     }
     if (method_exists($e, "getUID")) {
         if ($uid = $e->getUID()) {
             $props[] = File_iCal_Property::getProperty("UID", array(), $uid);
         }
     }
     if (method_exists($e, "getDateStamp")) {
         if ($ds = $e->getDateStamp()) {
             $props[] = File_iCal_Property::getProperty("DTSTAMP", array(), $uid);
         }
     }
     if (method_exists($e, "getRequestStatus")) {
     }
     if (method_exists($e, "getCategories")) {
     }
     if (method_exists($e, "getClassification")) {
     }
     if (method_exists($e, "getStatus")) {
     }
     if (method_exists($e, "getRecurrenceId")) {
     }
     if (method_exists($e, "getRelatedTo")) {
     }
     if (method_exists($e, "getCreated")) {
     }
     if (method_exists($e, "getSequence")) {
         if ($sequence = $e->getSequence()) {
             $props[] = File_iCal_Property::getProperty("SEQUENCE", array(), $sequence);
         }
     }
     if (method_exists($e, "getLatitude")) {
     }
     if (method_exists($e, "getLongitude")) {
     }
     if (method_exists($e, "getLocation")) {
         if ($location = $e->getLocation()) {
             $props[] = File_iCal_Property::getLocation("LOCATION", array(), $location);
         }
     }
     if (method_exists($e, "getPriority")) {
     }
     if (method_exists($e, "getResources")) {
     }
     if (method_exists($e, "getTransparency")) {
     }
     $props[] = File_iCal_Property::getProperty("END", array(), $component_name);
     //convert these properties to contentlines
     require_once 'File/iCal/ContentLine.php';
     foreach ($props as $k => $p) {
         $props[$k] = new File_iCal_ContentLine($p);
     }
     //echo '<PRE>';print_R(array($e, $component_name,$props));
     switch ($component_name) {
         case "VEVENT":
             return new File_iCal_Component_Event($props);
             break;
         case "VTODO":
             return new File_iCal_Component_Todo($props);
             break;
         case "VTIMEZONE":
             return new File_iCal_Component_Timezone($props);
             break;
         case "VALARM":
             return new File_iCal_Component_Alarm($props);
             break;
         case "VFREEBUSY":
             return new File_iCal_Component_FreeBusy($props);
             break;
         case "VJOURNAL":
             return new File_iCal_Component_Journal($props);
             break;
         default:
             trigger_error("Cannot yet retrieve component");
     }
 }