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.eclipse.adt.internal.resources; 18 19 import com.android.ide.eclipse.adt.editors.layout.gscripts.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 42 /** 43 * @param name The XML Name of the attribute 44 * @param formats The formats of the attribute. Cannot be null. 45 * Should have at least one format. 46 */ AttributeInfo(String name, Format[] formats)47 public AttributeInfo(String name, Format[] formats) { 48 mName = name; 49 mFormats = formats; 50 } 51 52 /** 53 * @param name The XML Name of the attribute 54 * @param formats The formats of the attribute. Cannot be null. 55 * Should have at least one format. 56 * @param javadoc Short javadoc (i.e. the first sentence). 57 */ AttributeInfo(String name, Format[] formats, String javadoc)58 public AttributeInfo(String name, Format[] formats, String javadoc) { 59 mName = name; 60 mFormats = formats; 61 mJavaDoc = javadoc; 62 } 63 AttributeInfo(AttributeInfo info)64 public AttributeInfo(AttributeInfo info) { 65 mName = info.mName; 66 mFormats = info.mFormats; 67 mEnumValues = info.mEnumValues; 68 mFlagValues = info.mFlagValues; 69 mJavaDoc = info.mJavaDoc; 70 mDeprecatedDoc = info.mDeprecatedDoc; 71 } 72 73 /** Returns the XML Name of the attribute */ getName()74 public String getName() { 75 return mName; 76 } 77 /** Returns the formats of the attribute. Cannot be null. 78 * Should have at least one format. */ getFormats()79 public Format[] getFormats() { 80 return mFormats; 81 } 82 /** Returns the values for enums. null for other types. */ getEnumValues()83 public String[] getEnumValues() { 84 return mEnumValues; 85 } 86 /** Returns the values for flags. null for other types. */ getFlagValues()87 public String[] getFlagValues() { 88 return mFlagValues; 89 } 90 /** Returns a short javadoc, .i.e. the first sentence. */ getJavaDoc()91 public String getJavaDoc() { 92 return mJavaDoc; 93 } 94 /** Returns the documentation for deprecated attributes. Null if not deprecated. */ getDeprecatedDoc()95 public String getDeprecatedDoc() { 96 return mDeprecatedDoc; 97 } 98 99 /** Sets the values for enums. null for other types. */ setEnumValues(String[] values)100 public AttributeInfo setEnumValues(String[] values) { 101 mEnumValues = values; 102 return this; 103 } 104 105 /** Sets the values for flags. null for other types. */ setFlagValues(String[] values)106 public AttributeInfo setFlagValues(String[] values) { 107 mFlagValues = values; 108 return this; 109 } 110 111 /** Sets a short javadoc, .i.e. the first sentence. */ setJavaDoc(String javaDoc)112 public void setJavaDoc(String javaDoc) { 113 mJavaDoc = javaDoc; 114 } 115 116 /** Sets the documentation for deprecated attributes. Null if not deprecated. */ setDeprecatedDoc(String deprecatedDoc)117 public void setDeprecatedDoc(String deprecatedDoc) { 118 mDeprecatedDoc = deprecatedDoc; 119 } 120 } 121