1 /* 2 * Copyright (C) 2008 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 17 package com.android.ide.common.resources.platform; 18 19 import com.android.ide.common.api.IAttributeInfo; 20 21 22 /** 23 * Information about an attribute as gathered from the attrs.xml file where 24 * the attribute was declared. This must include a format (string, reference, float, etc.), 25 * possible flag or enum values, whether it's deprecated and its javadoc. 26 */ 27 public class AttributeInfo implements IAttributeInfo { 28 /** XML Name of the attribute */ 29 private String mName; 30 31 /** Formats of the attribute. Cannot be null. Should have at least one format. */ 32 private Format[] mFormats; 33 /** Values for enum. null for other types. */ 34 private String[] mEnumValues; 35 /** Values for flag. null for other types. */ 36 private String[] mFlagValues; 37 /** Short javadoc (i.e. the first sentence). */ 38 private String mJavaDoc; 39 /** Documentation for deprecated attributes. Null if not deprecated. */ 40 private String mDeprecatedDoc; 41 /** The source class defining this attribute */ 42 private String mDefinedBy; 43 44 /** 45 * @param name The XML Name of the attribute 46 * @param formats The formats of the attribute. Cannot be null. 47 * Should have at least one format. 48 */ 49 public AttributeInfo(String name, Format[] formats) { 50 mName = name; 51 mFormats = formats; 52 } 53 54 /** 55 * @param name The XML Name of the attribute 56 * @param formats The formats of the attribute. Cannot be null. 57 * Should have at least one format. 58 * @param javadoc Short javadoc (i.e. the first sentence). 59 */ 60 public AttributeInfo(String name, Format[] formats, String javadoc) { 61 mName = name; 62 mFormats = formats; 63 mJavaDoc = javadoc; 64 } 65 66 public AttributeInfo(AttributeInfo info) { 67 mName = info.mName; 68 mFormats = info.mFormats; 69 mEnumValues = info.mEnumValues; 70 mFlagValues = info.mFlagValues; 71 mJavaDoc = info.mJavaDoc; 72 mDeprecatedDoc = info.mDeprecatedDoc; 73 } 74 75 /** Returns the XML Name of the attribute */ 76 public String getName() { 77 return mName; 78 } 79 /** Returns the formats of the attribute. Cannot be null. 80 * Should have at least one format. */ 81 public Format[] getFormats() { 82 return mFormats; 83 } 84 /** Returns the values for enums. null for other types. */ 85 public String[] getEnumValues() { 86 return mEnumValues; 87 } 88 /** Returns the values for flags. null for other types. */ 89 public String[] getFlagValues() { 90 return mFlagValues; 91 } 92 /** Returns a short javadoc, .i.e. the first sentence. */ 93 public String getJavaDoc() { 94 return mJavaDoc; 95 } 96 /** Returns the documentation for deprecated attributes. Null if not deprecated. */ 97 public String getDeprecatedDoc() { 98 return mDeprecatedDoc; 99 } 100 101 /** Sets the values for enums. null for other types. */ 102 public AttributeInfo setEnumValues(String[] values) { 103 mEnumValues = values; 104 return this; 105 } 106 107 /** Sets the values for flags. null for other types. */ 108 public AttributeInfo setFlagValues(String[] values) { 109 mFlagValues = values; 110 return this; 111 } 112 113 /** Sets a short javadoc, .i.e. the first sentence. */ 114 public void setJavaDoc(String javaDoc) { 115 mJavaDoc = javaDoc; 116 } 117 118 /** Sets the documentation for deprecated attributes. Null if not deprecated. */ 119 public void setDeprecatedDoc(String deprecatedDoc) { 120 mDeprecatedDoc = deprecatedDoc; 121 } 122 123 /** 124 * Sets the name of the class (fully qualified class name) which defined 125 * this attribute 126 * 127 * @param definedBy the name of the class (fully qualified class name) which 128 * defined this attribute 129 */ 130 public void setDefinedBy(String definedBy) { 131 mDefinedBy = definedBy; 132 } 133 134 /** 135 * Returns the name of the class (fully qualified class name) which defined 136 * this attribute 137 * 138 * @return the name of the class (fully qualified class name) which defined 139 * this attribute 140 */ 141 public String getDefinedBy() { 142 return mDefinedBy; 143 } 144 } 145