FileDocCategorySizeDatePackage
VCardSupport.javaAPI DocphoneME MR2 API (J2ME)7766Wed May 02 18:00:28 BST 2007com.sun.kvem.midp.pim.formats

VCardSupport

public class VCardSupport extends Object
Helper methods for vCard implementations.

Fields Summary
Constructors Summary
Methods Summary
public static intgetAttributeCode(java.lang.String label, int defaultValue)
Lookup the attribute identifier.

param
label the name of the attribute
param
defaultValue default value to return if the attribute identifier is not found
return
identifier for requested attribute

        if (label.equals("CAR"))
            return Contact.ATTR_AUTO;
        else if (label.equals("FAX"))
            return Contact.ATTR_FAX;
        else if (label.equals("HOME"))
            return Contact.ATTR_HOME;
        else if (label.equals("CELL"))
            return Contact.ATTR_MOBILE;
        else if (label.equals("X-J2MEWTK-OTHER"))
            return Contact.ATTR_OTHER;
        else if (label.equals("PAGER"))
            return Contact.ATTR_PAGER;
        else if (label.equals("PREF"))
            return Contact.ATTR_PREFERRED;
        else if (label.equals("MSG"))
            return Contact.ATTR_SMS;
        else if (label.equals("WORK"))
            return Contact.ATTR_WORK;
        else if (label.equals("X-J2MEWTK-ASST"))
            return Contact.ATTR_ASST;
        else
            return Extensions.getContactAttributeCode(label, defaultValue);
    
public static java.lang.StringgetAttributeLabel(int attr)
Lookup the attribute name from identifier.

param
attr the field identifier
return
the name of the attribute

        switch (attr) {
            case Contact.ATTR_ASST: return "X-J2MEWTK-ASST";
            case Contact.ATTR_AUTO: return "CAR";
            case Contact.ATTR_FAX: return "FAX";
            case Contact.ATTR_HOME: return "HOME";
            case Contact.ATTR_MOBILE: return "CELL";
            case Contact.ATTR_OTHER: return "X-J2MEWTK-OTHER";
            case Contact.ATTR_PAGER: return "PAGER";
            case Contact.ATTR_PREFERRED: return "PREF";
            case Contact.ATTR_SMS: return "MSG";
            case Contact.ATTR_WORK: return "WORK";
            default: return Extensions.getContactAttributeLabel(attr);
        }
    
public static intgetClassCode(java.lang.String s)
Gets the value of the Contact.CLASS field for the given value of the vCard CLASS property. This method encapsulates the following mapping: Contact.CLASS_PUBLIC <- "PUBLIC" Contact.CLASS_PRIVATE <- "PRIVATE" Contact.CLASS_CONFIDENTIAL <- "CONFIDENTIAL"

param
s the value of the CLASS property
return
the corresponding field of Contact, or -1 if s is not recognized

        switch (s.length()) {
            case 6:
                if (s.equals("PUBLIC")) {
                    return Contact.CLASS_PUBLIC;
                }
                break;
            case 7:
                if (s.equals("PRIVATE")) {
                    return Contact.CLASS_PRIVATE;
                }
                break;
            case 12:
                if (s.equals("CONFIDENTIAL")) {
                    return Contact.CLASS_CONFIDENTIAL;
                }
                break;
        }
        return -1;
    
public static java.lang.StringgetClassType(int fieldValue)
Gets the value of the vCard CLASS field for the given value of the Contact.CLASS field. This method encapsulates the following mapping: Contact.CLASS_PUBLIC -> "PUBLIC" Contact.CLASS_PRIVATE -> "PRIVATE" Contact.CLASS_CONFIDENTIAL -> "CONFIDENTIAL"

param
fieldValue the value of the Contact.CLASS field
return
a string describing the class for the field value, or null if fieldValue is out of range

        switch (fieldValue) {
            case Contact.CLASS_CONFIDENTIAL: return "CONFIDENTIAL";
            case Contact.CLASS_PRIVATE: return "PRIVATE";
            case Contact.CLASS_PUBLIC: return "PUBLIC";
        }
        return null;
    
public static intgetFieldCode(java.lang.String fieldName)
Lookup the field identifier byte name.

param
fieldName label for field
return
identifier for requested field

        if (fieldName.equals("FN"))
            return Contact.FORMATTED_NAME;
        else if (fieldName.equals("LABEL"))
            return Contact.FORMATTED_ADDR;
        else if (fieldName.equals("ADR"))
            return Contact.ADDR;
        else if (fieldName.equals("BDAY"))
            return Contact.BIRTHDAY;
        else if (fieldName.equals("N"))
            return Contact.NAME;
        else if (fieldName.equals("PHOTO"))
            return Contact.PHOTO;
        else if (fieldName.equals("TEL"))
            return Contact.TEL;
        else if (fieldName.equals("TITLE"))
            return Contact.TITLE;
        else if (fieldName.equals("REV"))
            return Contact.REVISION;
        else if (fieldName.equals("URL"))
            return Contact.URL;
        else if (fieldName.equals("UID"))
            return Contact.UID;
        else if (fieldName.equals("KEY"))
            return Contact.PUBLIC_KEY;
        else if (fieldName.equals("NICKNAME"))
            return Contact.NICKNAME;
        else if (fieldName.equals("NOTE"))
            return Contact.NOTE;
        else if (fieldName.equals("EMAIL"))
            return Contact.EMAIL;
        else if (fieldName.equals("ORG"))
            return Contact.ORG;
        else return -1;
    
public static java.lang.StringgetFieldLabel(int field)
Gets the field label.

param
field identifier for field
return
label of requested field

        switch (field) {
            case Contact.FORMATTED_NAME: return "FN";
            case Contact.ADDR: return "ADR";
            case Contact.BIRTHDAY: return "BDAY";
            case Contact.NAME: return "N";
            case Contact.PHOTO: return "PHOTO;ENCODING=BASE64";
            case Contact.PHOTO_URL: return "PHOTO;VALUE=URL";
            case Contact.TEL: return "TEL";
            case Contact.TITLE: return "TITLE";
            case Contact.REVISION: return "REV";
            case Contact.URL: return "URL";
            case Contact.UID: return "UID";
            case Contact.PUBLIC_KEY: return "KEY;ENCODING=BASE64";
            case Contact.FORMATTED_ADDR: return "LABEL";
            case Contact.NICKNAME: return "NICKNAME";
            case Contact.NOTE: return "NOTE";
            case Contact.PUBLIC_KEY_STRING: return "KEY";
            case Contact.EMAIL: return "EMAIL";
            case Contact.ORG: return "ORG";
            default:
                return null;
        }