FileDocCategorySizeDatePackage
VCardEntryConstructor.javaAPI DocAndroid 5.1 API4053Thu Mar 12 22:22:54 GMT 2015com.android.vcard

VCardEntryConstructor

public class VCardEntryConstructor extends Object implements VCardInterpreter

The {@link VCardInterpreter} implementation which enables {@link VCardEntryHandler} objects to easily handle each vCard entry.

This class understand details inside vCard and translates it to {@link VCardEntry}. Then the class throw it to {@link VCardEntryHandler} registered via {@link #addEntryHandler(VCardEntryHandler)}, so that all those registered objects are able to handle the {@link VCardEntry} object.

If you want to know the detail inside vCard, it would be better to implement {@link VCardInterpreter} directly, instead of relying on this class and {@link VCardEntry} created by the object.

Fields Summary
private static String
LOG_TAG
private final List
mEntryStack
Represents current stack of VCardEntry. Used to support nested vCard (vCard 2.1).
private VCardEntry
mCurrentEntry
private final int
mVCardType
private final android.accounts.Account
mAccount
private final List
mEntryHandlers
Constructors Summary
public VCardEntryConstructor()


      
        this(VCardConfig.VCARD_TYPE_V21_GENERIC, null, null);
    
public VCardEntryConstructor(int vcardType)

        this(vcardType, null, null);
    
public VCardEntryConstructor(int vcardType, android.accounts.Account account)

        this(vcardType, account, null);
    
public VCardEntryConstructor(int vcardType, android.accounts.Account account, String targetCharset)

deprecated
targetCharset is not used anymore. Use {@link #VCardEntryConstructor(int, Account)}

        mVCardType = vcardType;
        mAccount = account;
    
Methods Summary
public voidaddEntryHandler(VCardEntryHandler entryHandler)

        mEntryHandlers.add(entryHandler);
    
public voidclear()

        mCurrentEntry = null;
        mEntryStack.clear();
    
public voidonEntryEnded()

        mCurrentEntry.consolidateFields();
        for (VCardEntryHandler entryHandler : mEntryHandlers) {
            entryHandler.onEntryCreated(mCurrentEntry);
        }

        final int size = mEntryStack.size();
        if (size > 1) {
            VCardEntry parent = mEntryStack.get(size - 2);
            parent.addChild(mCurrentEntry);
            mCurrentEntry = parent;
        } else {
            mCurrentEntry = null;
        }
        mEntryStack.remove(size - 1);
    
public voidonEntryStarted()

        mCurrentEntry = new VCardEntry(mVCardType, mAccount);
        mEntryStack.add(mCurrentEntry);
    
public voidonPropertyCreated(VCardProperty property)

        mCurrentEntry.addProperty(property);
    
public voidonVCardEnded()

        for (VCardEntryHandler entryHandler : mEntryHandlers) {
            entryHandler.onEnd();
        }
    
public voidonVCardStarted()

        for (VCardEntryHandler entryHandler : mEntryHandlers) {
            entryHandler.onStart();
        }