1 /*
2  * Copyright (C) 2011 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 
17 package com.android.cts.verifier.nfc.tech;
18 
19 import android.nfc.FormatException;
20 import android.nfc.Tag;
21 
22 import java.io.IOException;
23 
24 /** Tag verifier for checking that the {@link Tag} has some expected value. */
25 public interface TagVerifier {
26 
27     /** @return true if the tag has the expected value */
verifyTag(Tag tag)28     Result verifyTag(Tag tag) throws FormatException, IOException;
29 
30     /** Class with info necessary to show the user what was written and read from a tag. */
31     public static class Result {
32 
33         private final CharSequence mExpectedContent;
34 
35         private final CharSequence mActualContent;
36 
37         private final boolean mIsMatch;
38 
Result(CharSequence expectedContent, CharSequence actualContent, boolean isMatch)39         public Result(CharSequence expectedContent, CharSequence actualContent, boolean isMatch) {
40             this.mExpectedContent = expectedContent;
41             this.mActualContent = actualContent;
42             this.mIsMatch = isMatch;
43         }
44 
45         /** @return {@link CharSequence} representation of the data written to the tag */
getExpectedContent()46         public CharSequence getExpectedContent() {
47             return mExpectedContent;
48         }
49 
50         /** @return {@link CharSequence} representation of the data read back from the tag */
getActualContent()51         public CharSequence getActualContent() {
52             return mActualContent;
53         }
54 
55         /** @return whether or not the expected content matched the actual content of the tag */
isMatch()56         public boolean isMatch() {
57             return mIsMatch;
58         }
59     }
60 }
61