IAttributeInfo.java revision 3db9393ba06bbf70fa7b4a6db1ef60396979a1d4
1/*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Eclipse Public License, Version 1.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.eclipse.org/org/documents/epl-v10.php
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
17package com.android.ide.common.api;
18
19import com.google.common.annotations.Beta;
20
21/**
22 * Information about an attribute as gathered from the attrs.xml file where
23 * the attribute was declared. This must include a format (string, reference, float, etc.),
24 * possible flag or enum values, whether it's deprecated and its javadoc.
25 * <p>
26 * <b>NOTE: This is not a public or final API; if you rely on this be prepared
27 * to adjust your code for the next tools release.</b>
28 * </p>
29 */
30@Beta
31public interface IAttributeInfo {
32
33    /** An attribute format, e.g. string, reference, float, etc. */
34    public enum Format {
35        STRING,
36        BOOLEAN,
37        INTEGER,
38        FLOAT,
39        REFERENCE,
40        COLOR,
41        DIMENSION,
42        FRACTION,
43        ENUM,
44        FLAG;
45
46        /**
47         * Returns true if and only if this format is in the given array of
48         * formats
49         *
50         * @param formats An array of formats, or null.
51         * @return True if and only if the given array (if any) contains this
52         *         format.
53         */
54        public boolean in(Format[] formats) {
55            if (formats == null) {
56                return false;
57            }
58            for (Format f : formats) {
59                if (f == this) {
60                    return true;
61                }
62            }
63
64            return false;
65        }
66    }
67
68    /** Returns the XML Name of the attribute */
69    public String getName();
70
71    /** Returns the formats of the attribute. Cannot be null.
72     *  Should have at least one format. */
73    public Format[] getFormats();
74
75    /** Returns the values for enums. null for other types. */
76    public String[] getEnumValues();
77
78    /** Returns the values for flags. null for other types. */
79    public String[] getFlagValues();
80
81    /** Returns a short javadoc, .i.e. the first sentence. */
82    public String getJavaDoc();
83
84    /** Returns the documentation for deprecated attributes. Null if not deprecated. */
85    public String getDeprecatedDoc();
86
87    /** Returns the fully qualified class name of the view defining this attribute */
88    public String getDefinedBy();
89}
90