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 */ 16 package com.android.vcard; 17 18 import com.android.vcard.exception.VCardException; 19 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; 25 import java.util.Set; 26 27 /** 28 * <p> 29 * vCard parser for vCard 4.0. DO NOT USE IN PRODUCTION. 30 * </p> 31 * <p> 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") 35 * </p> 36 */ 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"))); 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_V40 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 addInterpreter(VCardInterpreter interpreter) { 70 mVCardParserImpl.addInterpreter(interpreter); 71 } 72 73 @Override 74 public void parse(InputStream is) throws IOException, VCardException { 75 mVCardParserImpl.parse(is); 76 } 77 78 @Override 79 public void parseOne(InputStream is) throws IOException, VCardException { 80 mVCardParserImpl.parseOne(is); 81 } 82 83 @Override 84 public void cancel() { 85 mVCardParserImpl.cancel(); 86 } 87 }