com.funambol.common.pim.vcard
Class VCardFormatter

java.lang.Object
  extended by com.funambol.common.pim.vcard.VCardFormatter

public class VCardFormatter
extends java.lang.Object

This class implements a vCard 2.1 formatter for JSR75 contacts. The class can be extended to customize the way or the order in which fields are emitted. This class, like the ContactParserListener, has a fixed mapping for the multivalue fields. See ContactParserListener for more details on this mapping. In general the two implementations should be kept in sync and consistent. One aspect that client are likely to need redefining is the way photo's type is detected. J2ME has no standard way to detect the type of a picture in a byte stream, so the basic implementation assumes the mime types for contact pictures is "jpeg". Clients can extend the class and redefine the getPhoto method to support custom image type detection. Warning: the current implementation is not finished yet and not all fields are mapped. This implementation is used in the BlackBerry so it handles the BB fields only. It will be extended when needed.


Field Summary
protected static java.lang.String EMAIL_HOME_TAG
           
protected static java.lang.String EMAIL_OTHER_TAG
           
protected static java.lang.String EMAIL_WORK_TAG
           
protected static java.lang.String FAX_HOME_TAG
           
protected static java.lang.String FAX_OTHER_TAG
           
protected static java.lang.String FAX_WORK_TAG
           
protected  PimUtils pimUtils
           
protected static java.lang.String TEL_HOME_TAG
           
protected static java.lang.String TEL_MOBILE_TAG
           
protected static java.lang.String TEL_OTHER_TAG
           
protected static java.lang.String TEL_PAGER_TAG
           
protected static java.lang.String TEL_WORK_TAG
           
 
Constructor Summary
VCardFormatter()
           
VCardFormatter(java.lang.String defaultCharset)
           
 
Method Summary
 void format(javax.microedition.pim.Contact contact, java.io.OutputStream os, boolean allFields)
           
protected  void formatAddress(javax.microedition.pim.Contact contact, java.io.OutputStream os, boolean allFields)
           
protected  void formatAddress(java.lang.String[] address, java.lang.String tag, java.io.OutputStream os)
           
protected  void formatBirthday(javax.microedition.pim.Contact contact, java.io.OutputStream os, boolean allFields)
           
protected  void formatCategories(javax.microedition.pim.Contact contact, java.io.OutputStream os, boolean allFields)
           
protected  void formatEmail(javax.microedition.pim.Contact contact, java.io.OutputStream os, boolean allFields)
           
protected  void formatFaxTag(java.lang.StringBuffer out, java.lang.String tag)
           
protected  void formatField(java.lang.String tag, java.lang.String value, java.io.OutputStream os)
           
protected  void formatFields(javax.microedition.pim.Contact contact, java.io.OutputStream os, boolean allFields)
           
protected  void formatName(javax.microedition.pim.Contact contact, java.io.OutputStream os, boolean allFields)
           
protected  void formatPhoto(javax.microedition.pim.Contact contact, java.io.OutputStream os, boolean allFields)
           
protected  void formatTag(java.lang.StringBuffer out, java.lang.String tag)
           
protected  void formatTel(javax.microedition.pim.Contact contact, java.io.OutputStream os, boolean allFields)
           
protected  void formatVersion(javax.microedition.pim.Contact contact, java.io.OutputStream os)
           
protected  java.lang.String getPhotoType(byte[] photo)
           
protected  int[] getSupportedFields()
          This method can be redefined to change the default behavior and ignore unwanted fields.
protected  boolean isSupportedField(javax.microedition.pim.PIMList list, int field)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TEL_HOME_TAG

protected static final java.lang.String TEL_HOME_TAG
See Also:
Constant Field Values

TEL_WORK_TAG

protected static final java.lang.String TEL_WORK_TAG
See Also:
Constant Field Values

TEL_PAGER_TAG

protected static final java.lang.String TEL_PAGER_TAG
See Also:
Constant Field Values

FAX_WORK_TAG

protected static final java.lang.String FAX_WORK_TAG
See Also:
Constant Field Values

FAX_HOME_TAG

protected static final java.lang.String FAX_HOME_TAG
See Also:
Constant Field Values

FAX_OTHER_TAG

protected static final java.lang.String FAX_OTHER_TAG
See Also:
Constant Field Values

TEL_MOBILE_TAG

protected static final java.lang.String TEL_MOBILE_TAG
See Also:
Constant Field Values

TEL_OTHER_TAG

protected static final java.lang.String TEL_OTHER_TAG
See Also:
Constant Field Values

EMAIL_OTHER_TAG

protected static final java.lang.String EMAIL_OTHER_TAG
See Also:
Constant Field Values

EMAIL_HOME_TAG

protected static final java.lang.String EMAIL_HOME_TAG
See Also:
Constant Field Values

EMAIL_WORK_TAG

protected static final java.lang.String EMAIL_WORK_TAG
See Also:
Constant Field Values

pimUtils

protected PimUtils pimUtils
Constructor Detail

VCardFormatter

public VCardFormatter()

VCardFormatter

public VCardFormatter(java.lang.String defaultCharset)
Method Detail

format

public void format(javax.microedition.pim.Contact contact,
                   java.io.OutputStream os,
                   boolean allFields)
            throws javax.microedition.pim.PIMException
Throws:
javax.microedition.pim.PIMException

formatFields

protected void formatFields(javax.microedition.pim.Contact contact,
                            java.io.OutputStream os,
                            boolean allFields)
                     throws javax.microedition.pim.PIMException
Throws:
javax.microedition.pim.PIMException

getPhotoType

protected java.lang.String getPhotoType(byte[] photo)

formatVersion

protected void formatVersion(javax.microedition.pim.Contact contact,
                             java.io.OutputStream os)
                      throws javax.microedition.pim.PIMException
Throws:
javax.microedition.pim.PIMException

formatPhoto

protected void formatPhoto(javax.microedition.pim.Contact contact,
                           java.io.OutputStream os,
                           boolean allFields)
                    throws javax.microedition.pim.PIMException
Throws:
javax.microedition.pim.PIMException

formatName

protected void formatName(javax.microedition.pim.Contact contact,
                          java.io.OutputStream os,
                          boolean allFields)
                   throws javax.microedition.pim.PIMException
Throws:
javax.microedition.pim.PIMException

formatField

protected void formatField(java.lang.String tag,
                           java.lang.String value,
                           java.io.OutputStream os)
                    throws javax.microedition.pim.PIMException
Throws:
javax.microedition.pim.PIMException

formatTag

protected void formatTag(java.lang.StringBuffer out,
                         java.lang.String tag)

formatTel

protected void formatTel(javax.microedition.pim.Contact contact,
                         java.io.OutputStream os,
                         boolean allFields)
                  throws javax.microedition.pim.PIMException
Throws:
javax.microedition.pim.PIMException

formatFaxTag

protected void formatFaxTag(java.lang.StringBuffer out,
                            java.lang.String tag)

formatAddress

protected void formatAddress(javax.microedition.pim.Contact contact,
                             java.io.OutputStream os,
                             boolean allFields)
                      throws javax.microedition.pim.PIMException
Throws:
javax.microedition.pim.PIMException

formatAddress

protected void formatAddress(java.lang.String[] address,
                             java.lang.String tag,
                             java.io.OutputStream os)
                      throws javax.microedition.pim.PIMException
Throws:
javax.microedition.pim.PIMException

formatEmail

protected void formatEmail(javax.microedition.pim.Contact contact,
                           java.io.OutputStream os,
                           boolean allFields)
                    throws javax.microedition.pim.PIMException
Throws:
javax.microedition.pim.PIMException

formatCategories

protected void formatCategories(javax.microedition.pim.Contact contact,
                                java.io.OutputStream os,
                                boolean allFields)
                         throws javax.microedition.pim.PIMException
Throws:
javax.microedition.pim.PIMException

formatBirthday

protected void formatBirthday(javax.microedition.pim.Contact contact,
                              java.io.OutputStream os,
                              boolean allFields)
                       throws javax.microedition.pim.PIMException
Throws:
javax.microedition.pim.PIMException

getSupportedFields

protected int[] getSupportedFields()
This method can be redefined to change the default behavior and ignore unwanted fields.

Returns:
a list of fields that are going to be supported or null if all fields shall be supported.

isSupportedField

protected boolean isSupportedField(javax.microedition.pim.PIMList list,
                                   int field)


Copyright © 2001-2009 Funambol.