FileDocCategorySizeDatePackage
VCardParserImpl_V40.javaAPI DocAndroid 5.1 API2603Thu Mar 12 22:22:54 GMT 2015com.android.vcard

VCardParserImpl_V40

public class VCardParserImpl_V40 extends VCardParserImpl_V30

Basic implementation parsing vCard 4.0.

vCard 4.0 is not published yet. Also this implementation is premature.

hide

Fields Summary
Constructors Summary
public VCardParserImpl_V40()

        super();
    
public VCardParserImpl_V40(int vcardType)

        super(vcardType);
    
Methods Summary
protected java.util.SetgetKnownPropertyNameSet()

        return VCardParser_V40.sKnownPropertyNameSet;
    
protected intgetVersion()

        return VCardConfig.VERSION_40;
    
protected java.lang.StringgetVersionString()

        return VCardConstants.VERSION_V40;
    
protected java.lang.StringmaybeUnescapeText(java.lang.String text)
We escape "\N" into new line for safety.

        return unescapeText(text);
    
public static java.lang.StringunescapeCharacter(char ch)

        if (ch == 'n" || ch == 'N") {
            return "\n";
        } else {
            return String.valueOf(ch);
        }
    
public static java.lang.StringunescapeText(java.lang.String text)

        // TODO: more strictly, vCard 4.0 requires different type of unescaping rule
        //       toward each property.
        final StringBuilder builder = new StringBuilder();
        final int length = text.length();
        for (int i = 0; i < length; i++) {
            char ch = text.charAt(i);
            if (ch == '\\" && i < length - 1) {
                final char next_ch = text.charAt(++i);
                if (next_ch == 'n" || next_ch == 'N") {
                    builder.append("\n");
                } else {
                    builder.append(next_ch);
                }
            } else {
                builder.append(ch);
            }
        }
        return builder.toString();