com.funambol.common.pim
Class Utils

java.lang.Object
  extended by com.funambol.common.pim.Utils
Direct Known Subclasses:
PimUtils

public class Utils
extends java.lang.Object

This class contains utilities for the PIM module. In particular it provides methods to fold, unfold, escape, unescape, encode e decode. All these tasks are required by most PIM formats (vCard, vCal and so on).


Field Summary
static char FOLDING_INDENT_CHAR
           
 
Constructor Summary
Utils(java.lang.String defaultCharset)
           
 
Method Summary
 java.lang.String decode(java.lang.String text, java.lang.String encoding, java.lang.String propertyCharset)
          Decode the given text according to the given encoding and charset
 java.lang.String escape(java.lang.String msg, boolean escapeComma)
          Escape special chars: '\' ';' ',' '\n'
 java.lang.String escape(java.lang.String msg, boolean escapeComma, boolean escapeLF)
          Escape special chars: '\' ';' ',' '\n'
 java.lang.String fold(java.lang.String str)
          Folds a string (i.e.
 java.lang.String unescape(java.lang.String text)
          Unescape '\' ',' ';' '\n' '\N' chars
 java.lang.String unfold(java.lang.String str)
          Unfolds a string (i.e.
 java.lang.String unfoldNewline(java.lang.String str)
          Unfolds a string (i.e.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FOLDING_INDENT_CHAR

public static final char FOLDING_INDENT_CHAR
See Also:
Constant Field Values
Constructor Detail

Utils

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

fold

public java.lang.String fold(java.lang.String str)
Folds a string (i.e. folds a text field in order to not exceed 75 chars for each string line, by inserting a CLRF line break and a tabulation as a prefix for each line)


unfold

public java.lang.String unfold(java.lang.String str)
Unfolds a string (i.e. removes all the CRLF characters)


unfoldNewline

public java.lang.String unfoldNewline(java.lang.String str)
Unfolds a string (i.e. removes all the line break characters). This function is meant to ensure compatibility with vCard documents that adhere loosely to the specification


decode

public java.lang.String decode(java.lang.String text,
                               java.lang.String encoding,
                               java.lang.String propertyCharset)
Decode the given text according to the given encoding and charset

Parameters:
text - the text to decode
encoding - the encoding
propertyCharset - the charset
Returns:
the text decoded

unescape

public java.lang.String unescape(java.lang.String text)
Unescape '\' ',' ';' '\n' '\N' chars

Parameters:
text - the text to unescape
Returns:
String the unescaped text

escape

public java.lang.String escape(java.lang.String msg,
                               boolean escapeComma)
Escape special chars: '\' ';' ',' '\n'

Parameters:
msg - message to escape,
escapeComma - boolean to escape or not the comma character. In some cases for Vcard is not necessary escape commas.
Returns:
the escaped message

escape

public java.lang.String escape(java.lang.String msg,
                               boolean escapeComma,
                               boolean escapeLF)
Escape special chars: '\' ';' ',' '\n'

Parameters:
msg - message to escape,
escapeComma - boolean to escape or not the comma character. In some cases for Vcard is not necessary escape commas.
escapeLF - boolean to escape LF or not
Returns:
the escaped message


Copyright © 2001-2009 Funambol.