Menu

can't get ExceptionDates

Anonymous
2014-05-31
2014-08-05
  • Anonymous

    Anonymous - 2014-05-31

    Hello,

    I'm currently getting to know the library and am stuck at a problem:
    my iCalendar has some ExceptionDates when viewing the file itself, but when creating the object trhough the library, i can't get any of these ExceptionDates (vEvent.getExceptionDates() allways returns a empty list).

    Am I doing this wrong, or is it a bug?

    Thanks in advance!
    Johannes

     
  • Michael Angstadt

    Johannes,

    Can you show me the iCal file you are trying to parse?

    Thanks,
    Mike

     
  • Anonymous

    Anonymous - 2014-05-31

    Hey Mike,

    thanks for the fast reply! I attached the file ;)

     
  • Michael Angstadt

    The EXDATE property values all end with a comma character, which isn't supposed to happen. This is preventing biweekly from parsing them.

    As a work-around, you could retrieve the properties as raw properties, and then parse them manually:

    :::java
    ICalendar ical = ...
    ExceptionDatesScribe scribe = new ExceptionDatesScribe();
    List<RawProperty> rawProps = ical.getExperimentalProperties(scribe.getPropertyName());
    List<ExceptionDates> exdates = new ArrayList<ExceptionDates>();
    for (RawProperty rawProp : rawProps) {
      String value = rawProp.getValue();
      value = value.substring(0, value.length() - 1); //chop off ","
    
      ICalDataType dataType = rawProp.getDataType();
      if (dataType == null){
        dataType = scribe.getDefaultDataType();
      }
      Result<ExceptionDates> result = scribe.parseText(value, dataType, rawProp.getParameters());
      exdates.add(result.getProperty());
    }
    
     

    Last edit: Michael Angstadt 2014-05-31
  • Anonymous

    Anonymous - 2014-05-31

    Thanks a lot Mike!

    i thought that might be the problem, too :P

     
  • Anonymous

    Anonymous - 2014-05-31

    the class ExceptionDatesScribe is not available in the current version.. will this class be added in a future release?

     
  • Michael Angstadt

    What version are you running?

     
  • Michael Angstadt

    Oh, right. I forgot I changed the name of that class. Its old name is "ExceptionDatesMarshaller". FYI: I just released a new version today (version 0.3.3) if you want to use that. :)

     

    Last edit: Michael Angstadt 2014-05-31
  • Anonymous

    Anonymous - 2014-06-01

    thanks! I just included the latest version, but the rawProps list is allways empty... :S

     
  • Michael Angstadt

    Oops, my mistake. In your case, the EXDATE properties exist within VEVENT components. So you have to iterate over all the properties in each VEVENT:

    :::java
    //parses the broken EXDATE properties and adds them back to the ICalendar object properly
    ICalendar ical = Biweekly.parse(new File("testCal[1].ics")).first();
    ExceptionDatesScribe scribe = new ExceptionDatesScribe();
    
    for (VEvent event : ical.getEvents()) {
      List<RawProperty> rawProps = event.getExperimentalProperties(scribe.getPropertyName());
      for (RawProperty rawProp : rawProps) {
        String value = rawProp.getValue();
        value = value.substring(0, value.length() - 1); //chop off ","
    
        ICalDataType dataType = rawProp.getDataType();
        if (dataType == null) {
          dataType = scribe.getDefaultDataType();
        }
        Result<ExceptionDates> result = scribe.parseText(value, dataType, rawProp.getParameters());
        event.addExceptionDates(result.getProperty());
      }
    
      event.removeExperimentalProperty(scribe.getPropertyName());
    }
    
     
  • Anonymous

    Anonymous - 2014-06-05

    awesome, it's working now =) thanks alot, mike!

     
  • Michael Angstadt

    You're welcome!

     
  • Anonymous

    Anonymous - 2014-07-31

    I'm back once again for another question, mike!

    Could it be that - due to this error in the file - the Location-Attribute won't get parsed?

    I tried to retrieve it, but it allways returns an empty String...

    Thanks in davance!
    Johannes

     

Anonymous
Anonymous

Add attachments
Cancel