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 
17 package com.android.apkcheck;
18 
19 /**
20  * Container representing a method with parameters.
21  */
22 public class FieldInfo {
23     private String mName;
24     private String mType;
25     private String mNameAndType;
26     private boolean mTypeNormalized;
27 
28     /**
29      * Constructs a FieldInfo.
30      *
31      * @param name Field name.
32      * @param type Fully-qualified binary or non-binary type name.
33      */
FieldInfo(String name, String type)34     public FieldInfo(String name, String type) {
35         mName = name;
36         mType = type;
37     }
38 
39     /**
40      * Returns the combined name and type.  This value is used as a hash
41      * table key.
42      */
getNameAndType()43     public String getNameAndType() {
44         if (mNameAndType == null)
45             mNameAndType = mName + ":" + TypeUtils.typeToDescriptor(mType);
46         return mNameAndType;
47     }
48 
49     /**
50      * Normalize the type used in fields.
51      */
normalizeType(ApiList apiList)52     public void normalizeType(ApiList apiList) {
53         if (!mTypeNormalized) {
54             String type = TypeUtils.ambiguousToBinaryName(mType, apiList);
55             if (!type.equals(mType)) {
56                 /* name changed, force regen on name+type */
57                 mType = type;
58                 mNameAndType = null;
59             }
60             mTypeNormalized = true;
61         }
62     }
63 }
64 
65