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

VCard30Format

public class VCard30Format extends VCardFormat
Implementation of PIMEncoding for VCard/3.0.

Fields Summary
Constructors Summary
Methods Summary
protected java.lang.StringgetBinaryEncodingName()
Gets the binary encoding name.

return
the binary encoding name "B"

        return "B";
    
protected java.lang.StringgetCategoryProperty()
Gets the category property name.

return
the category property name "CATEGORY"

        return "CATEGORY";
    
protected java.lang.StringgetClassProperty()
Gets the class property name.

return
the class property name "CLASS"

        return "CLASS";
    
protected java.lang.StringgetVersion()
Gets the VCard version number.

return
the VCard version number "3.0"

        return "3.0";
    
protected intparseAttributes(java.lang.String[] attributes)
Get the binary value describing all flags in a vCard line.

param
attributes fields to parse
return
binary coded flags

        int code = 0;
        for (int i = 0; i < attributes.length; i++) {
            if (attributes[i].startsWith("TYPE=")) {
                String[] s = FormatSupport.split(attributes[i], ',", 5);
                for (int j = 0; j < s.length; j++) {
                    code |= VCardSupport.getAttributeCode(s[j], 0);
                }
            } else {
                code |= VCardSupport.getAttributeCode(attributes[i], 0);
            }
        }
        return code;
    
protected voidwriteAttributes(java.io.Writer w, int attributes)
Writes the attributes for a field.

param
w output stream target
param
attributes fields to be written
throws
IOException if an error occurs while writing

        boolean writtenData = false;
        for (int i = 0; i < 32; i++) {
            long mask = 1l << i;
            if ((attributes & mask) != 0) {
                String attributeLabel =
                    VCardSupport.getAttributeLabel((int) mask);
                if (attributeLabel != null) {
                    if (writtenData) {
                        w.write(",");
                    } else {
                        w.write(";TYPE=");
                        writtenData = true;
                    }
                    w.write(attributeLabel);
                }
            }
        }