summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaisuke Miyakawa <dmiyakawa@google.com>2011-04-05 14:35:09 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-04-05 14:35:09 -0700
commit79a36630866f4747b6384aac94c2553004d91ec6 (patch)
tree11d1586f561568519488f50942bf67c556f17202
parent56650608f09fc75f260c03e00456ef3d1e60c929 (diff)
parent9ec6c05a1dbb17862a44f96e91975dfc01cebf6e (diff)
downloadvcard-79a36630866f4747b6384aac94c2553004d91ec6.tar.gz
Merge "Remove VCardInterpreterCollection"
-rw-r--r--java/com/android/vcard/VCardInterpreterCollection.java71
-rw-r--r--tests/src/com/android/vcard/tests/testutils/VCardVerifier.java29
2 files changed, 9 insertions, 91 deletions
diff --git a/java/com/android/vcard/VCardInterpreterCollection.java b/java/com/android/vcard/VCardInterpreterCollection.java
deleted file mode 100644
index 9a50ab7..0000000
--- a/java/com/android/vcard/VCardInterpreterCollection.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.vcard;
-
-import java.util.Collection;
-
-/**
- * The {@link VCardInterpreter} implementation which aggregates more than one
- * {@link VCardInterpreter} objects and make a user object treat them as one
- * {@link VCardInterpreter} object.
- * @deprecated {@link VCardParser} has native support for multiple interpreter now.
- */
-public final class VCardInterpreterCollection implements VCardInterpreter {
- private final Collection<VCardInterpreter> mInterpreterCollection;
-
- public VCardInterpreterCollection(Collection<VCardInterpreter> interpreterCollection) {
- mInterpreterCollection = interpreterCollection;
- }
-
- public Collection<VCardInterpreter> getCollection() {
- return mInterpreterCollection;
- }
-
- @Override
- public void onVCardStarted() {
- for (VCardInterpreter builder : mInterpreterCollection) {
- builder.onVCardStarted();
- }
- }
-
- @Override
- public void onVCardEnded() {
- for (VCardInterpreter builder : mInterpreterCollection) {
- builder.onVCardEnded();
- }
- }
-
- @Override
- public void onEntryStarted() {
- for (VCardInterpreter builder : mInterpreterCollection) {
- builder.onEntryStarted();
- }
- }
-
- @Override
- public void onEntryEnded() {
- for (VCardInterpreter builder : mInterpreterCollection) {
- builder.onEntryEnded();
- }
- }
-
- @Override
- public void onPropertyCreated(VCardProperty property) {
- for (VCardInterpreter interpreter : mInterpreterCollection) {
- interpreter.onPropertyCreated(property);
- }
- }
-}
diff --git a/tests/src/com/android/vcard/tests/testutils/VCardVerifier.java b/tests/src/com/android/vcard/tests/testutils/VCardVerifier.java
index e529e71..b07564c 100644
--- a/tests/src/com/android/vcard/tests/testutils/VCardVerifier.java
+++ b/tests/src/com/android/vcard/tests/testutils/VCardVerifier.java
@@ -19,7 +19,6 @@ import com.android.vcard.VCardComposer;
import com.android.vcard.VCardConfig;
import com.android.vcard.VCardEntryConstructor;
import com.android.vcard.VCardInterpreter;
-import com.android.vcard.VCardInterpreterCollection;
import com.android.vcard.VCardParser;
import com.android.vcard.VCardUtils;
import com.android.vcard.exception.VCardException;
@@ -233,30 +232,20 @@ public class VCardVerifier {
* Used both from {@link #verifyForImportTest()} and from {@link #verifyForExportTest()}.
*/
private void verifyWithInputStream(InputStream is) throws IOException {
- final VCardInterpreter interpreter;
- if (mContentValuesVerifier != null) {
- final VCardEntryConstructor constructor = new VCardEntryConstructor(mVCardType);
- constructor.addEntryHandler(mContentValuesVerifier);
- if (mPropertyNodesVerifier != null) {
- interpreter = new VCardInterpreterCollection(Arrays.asList(
- mPropertyNodesVerifier, constructor));
- } else {
- interpreter = constructor;
- }
- } else {
- if (mPropertyNodesVerifier != null) {
- interpreter = mPropertyNodesVerifier;
- } else {
- interpreter = null;
- }
- }
-
try {
// Note: we must not specify charset toward vCard parsers. This code checks whether
// those parsers are able to encode given binary without any extra information for
// charset.
final VCardParser parser = VCardUtils.getAppropriateParser(mVCardType);
- parser.parse(is, interpreter);
+ if (mContentValuesVerifier != null) {
+ final VCardEntryConstructor constructor = new VCardEntryConstructor(mVCardType);
+ constructor.addEntryHandler(mContentValuesVerifier);
+ parser.addInterpreter(constructor);
+ }
+ if (mPropertyNodesVerifier != null) {
+ parser.addInterpreter(mPropertyNodesVerifier);
+ }
+ parser.parse(is);
} catch (VCardException e) {
Log.e(LOG_TAG, "VCardException", e);
AndroidTestCase.fail("Unexpected VCardException: " + e.getMessage());