VCardParser_V40.java revision 4560bdde6dd75cca49fc55b58aafb5d416b88ca3
1/*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package com.android.vcard;
17
18import com.android.vcard.exception.VCardException;
19
20import java.io.IOException;
21import java.io.InputStream;
22import java.util.Arrays;
23import java.util.Collections;
24import java.util.HashSet;
25import java.util.Set;
26
27/**
28 * <p>
29 * vCard parser for vCard 4.0.
30 * </p>
31 * <p>
32 * Currently this parser is based on vCard 4.0 specification rev 11.
33 * </p>
34 */
35public class VCardParser_V40 implements VCardParser {
36    /* package */ static final Set<String> sKnownPropertyNameSet =
37            Collections.unmodifiableSet(new HashSet<String>(Arrays.asList(
38                    "BEGIN", "END", "SOURCE", "NAME", "KIND", "XML",
39                    "FN", "N", "NICKNAME", "PHOTO", "BDAY", "DDAY",
40                    "BIRTH", "DEATH", "ANNIVERSARY", "SEX", "ADR",
41                    "LABEL", "TEL", "EMAIL", "IMPP", "LANG", "TZ",
42                    "GEO", "TITLE", "ROLE", "LOGO", "ORG", "MEMBER",
43                    "RELATED", "CATEGORIES", "NOTE", "PRODID",
44                    "REV", "SOUND", "UID", "CLIENTPIDMAP",
45                    "URL", "VERSION", "CLASS", "KEY", "FBURL", "CALENDRURI",
46                    "CALURI")));
47
48    /**
49     * <p>
50     * A unmodifiable Set storing the values for the type "ENCODING", available in vCard 4.0.
51     * </p>
52     */
53    /* package */ static final Set<String> sAcceptableEncoding =
54            Collections.unmodifiableSet(new HashSet<String>(Arrays.asList(
55                    VCardConstants.PARAM_ENCODING_8BIT,
56                    VCardConstants.PARAM_ENCODING_B)));
57
58    private final VCardParserImpl_V30 mVCardParserImpl;
59
60    public VCardParser_V40() {
61        mVCardParserImpl = new VCardParserImpl_V40();
62    }
63
64    public VCardParser_V40(int vcardType) {
65        mVCardParserImpl = new VCardParserImpl_V40(vcardType);
66    }
67
68    @Override
69    public void parse(InputStream is, VCardInterpreter interepreter)
70            throws IOException, VCardException {
71        mVCardParserImpl.parse(is, interepreter);
72    }
73
74    @Override
75    public void cancel() {
76        mVCardParserImpl.cancel();
77    }
78}