FileDocCategorySizeDatePackage
VNodeBuilder.javaAPI DocAndroid 5.1 API5386Thu Mar 12 22:22:54 GMT 2015com.android.vcard.tests.testutils

VNodeBuilder

public class VNodeBuilder extends Object implements com.android.vcard.VCardInterpreter

The class storing the parse result to custom datastruct: {@link VNode}, and {@link PropertyNode}. Maybe several vcard instance, so use vNodeList to store.

This is called VNode, not VCardNode, since it was used for expressing vCalendar (iCal).

Fields Summary
private static String
LOG_TAG
private List
mVNodeList
private VNode
mCurrentVNode
private String
mSourceCharset
The charset using which VParser parses the text.
private String
mTargetCharset
The charset with which byte array is encoded to String.
private boolean
mStrictLineBreakParsing
Constructors Summary
public VNodeBuilder()


      
        this(VCardConfig.DEFAULT_IMPORT_CHARSET, false);
    
public VNodeBuilder(String targetCharset, boolean strictLineBreakParsing)

        mSourceCharset = VCardConfig.DEFAULT_INTERMEDIATE_CHARSET;
        if (targetCharset != null) {
            mTargetCharset = targetCharset;
        } else {
            mTargetCharset = VCardConfig.DEFAULT_IMPORT_CHARSET;
        }
        mStrictLineBreakParsing = strictLineBreakParsing;
    
Methods Summary
public VNodegetCurrentVNode()

        return mCurrentVNode;
    
public java.lang.StringgetResult()

        throw new RuntimeException("Not supported");
    
public java.util.ListgetVNodeList()

        return mVNodeList;
    
private java.lang.StringlistToString(java.util.List list)

        int size = list.size();
        if (size > 1) {
            StringBuilder typeListB = new StringBuilder();
            for (String type : list) {
                typeListB.append(type).append(";");
            }
            int len = typeListB.length();
            if (len > 0 && typeListB.charAt(len - 1) == ';") {
                return typeListB.substring(0, len - 1);
            }
            return typeListB.toString();
        } else if (size == 1) {
            return list.get(0);
        } else {
            return "";
        }
    
public voidonEntryEnded()

        int lastIndex = mVNodeList.size() - 1;
        mVNodeList.remove(lastIndex--);
        mCurrentVNode = lastIndex >= 0 ? mVNodeList.get(lastIndex) : null;
    
public voidonEntryStarted()

        mCurrentVNode = new VNode();
        mVNodeList.add(mCurrentVNode);
    
public voidonPropertyCreated(com.android.vcard.VCardProperty property)

        // TODO: remove PropertyNode.
        PropertyNode propNode = new PropertyNode();
        propNode.propName = property.getName();
        List<String> groupList = property.getGroupList();
        if (groupList != null) {
            propNode.propGroupSet.addAll(groupList);
        }
        Map<String, Collection<String>> propertyParameterMap = property.getParameterMap();
        for (String paramType : propertyParameterMap.keySet()) {
            Collection<String> paramValueList = propertyParameterMap.get(paramType);
            if (paramType.equalsIgnoreCase("TYPE")) {
                propNode.paramMap_TYPE.addAll(paramValueList);
            } else {
                for (String paramValue : paramValueList) {
                    propNode.paramMap.put(paramType, paramValue);
                }
            }
        }

        // TODO: just redundant

        if (property.getRawValue() == null) {
            propNode.propValue_bytes = null;
            propNode.propValue_vector.clear();
            propNode.propValue_vector.add("");
            propNode.propValue = "";
            return;
        }

        final List<String> values = property.getValueList();
        if (values == null || values.size() == 0) {
            propNode.propValue_vector.clear();
            propNode.propValue_vector.add("");
            propNode.propValue = "";
        } else {
            propNode.propValue_vector.addAll(values);
            propNode.propValue = listToString(propNode.propValue_vector);
        }
        propNode.propValue_bytes = property.getByteValue();

        mCurrentVNode.propList.add(propNode);
    
public voidonVCardEnded()

    
public voidonVCardStarted()