iCal4j vCard - How to get 2.1 parameters?

Help
pengin
2013-05-10
2013-06-05
  • pengin
    pengin
    2013-05-10

    Hello all,

    I am using the ical4j-vcard library to parse some vCard data, but I am running into issues with vCard 2.1.

    I can parse 3.0 Property parameters such as the following by doing:
    EMAIL;type=INTERNET;type=HOME;type=pref:
    TEL;TYPE=WORK,VOICE:

    for (Iterator j = property.getParameters().iterator(); j.hasNext();) {
        Parameter parameter = (Parameter) j.next();
        System.out.println("PARAM: " + parameter);
        if (parameter.getId() == Parameter.Id.TYPE) {
            System.out.println(Arrays.toString(((Type) parameter).getTypes()));
        }
    }
    

    But for 2.1 format it doesn't work:
    EMAIL;INTERNET;HOME;
    ADR;WORK:

    Am I supposed to register "extended" properties?  I can' seem to figure out  how to do that:

                            ParameterFactoryRegistry registry = new ParameterFactoryRegistry();
    
                            ParameterFactory pf = registry.getFactory("HOME");
                            registry.register("HOME", pf);
    
     
  • Ben Fortuna
    Ben Fortuna
    2013-05-11

    Hi,

    Unfortunately I think the format for vCard 2.1 is quite different in syntax to that of vCard 3 or greater, which makes it quite difficult to support with a single parser. So currently we don't really support vCard versions earlier than 3.0.

    You could possibly modify the regular expressions used for parsing (found in the VCardBuilder class) to create a vCard 2.1-specific builder class, but this is something we haven't yet focused on.

    regards,
    ben