2 * Copyright (C) 2010 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 package com
.android
.vcard
;
18 import com
.android
.vcard
.exception
.VCardException
;
20 import java
.io
.IOException
;
21 import java
.io
.InputStream
;
22 import java
.util
.Arrays
;
23 import java
.util
.Collections
;
24 import java
.util
.HashSet
;
29 * vCard parser for vCard 4.0. DO NOT USE IN PRODUCTION.
32 * Currently this parser is based on vCard 4.0 specification rev 15 (partly).
33 * Note that some of current implementation lack basic capability required in vCard 4.0.
34 * (e.g. PHOTO has data parameter in rev 15 while this implementation requires "ENCODING=b")
37 public class VCardParser_V40
extends VCardParser
{
38 /* package */ static final Set
<String
> sKnownPropertyNameSet
=
39 Collections
.unmodifiableSet(new HashSet
<String
>(Arrays
.asList(
40 "BEGIN", "END", "VERSION",
41 "SOURCE", "KIND", "FN", "N", "NICKNAME",
42 "PHOTO", "BDAY", "ANNIVERSARY", "GENDER", "ADR", "TEL",
43 "EMAIL", "IMPP", "LANG", "TZ", "GEO", "TITLE", "ROLE",
44 "LOGO", "ORG", "MEMBER", "RELATED", "CATEGORIES",
45 "NOTE", "PRODID", "REV", "SOUND", "UID", "CLIENTPIDMAP",
46 "URL", "KEY", "FBURL", "CALENDRURI", "CALURI", "XML")));
50 * A unmodifiable Set storing the values for the type "ENCODING", available in vCard 4.0.
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
)));
58 private final VCardParserImpl_V40 mVCardParserImpl
;
60 public VCardParser_V40() {
61 mVCardParserImpl
= new VCardParserImpl_V40();
64 public VCardParser_V40(int vcardType
) {
65 mVCardParserImpl
= new VCardParserImpl_V40(vcardType
);
69 public void addInterpreter(VCardInterpreter interpreter
) {
70 mVCardParserImpl
.addInterpreter(interpreter
);
74 public void parse(InputStream is
) throws IOException
, VCardException
{
75 mVCardParserImpl
.parse(is
);
79 public void parseOne(InputStream is
) throws IOException
, VCardException
{
80 mVCardParserImpl
.parseOne(is
);
84 public void cancel() {
85 mVCardParserImpl
.cancel();