2 * Copyright (C) 2008 The Android Open Source Project
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
8 * http://www.eclipse.org/org/documents/epl-v10.php
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.
17 package com.android.ide.eclipse.adt.internal.resources;
21 * Information needed to represent a View or ViewGroup (aka Layout) item
22 * in the layout hierarchy, as extracted from the main android.jar and the
23 * associated attrs.xml.
25 public class ViewClassInfo {
26 /** Is this a layout class (i.e. ViewGroup) or just a view? */
27 private boolean mIsLayout;
28 /** FQCN e.g. android.view.View, never null. */
29 private String mFullClassName;
30 /** Short class name, e.g. View, never null. */
31 private String mShortClassName;
32 /** Super class. Can be null. */
33 private ViewClassInfo mSuperClass;
34 /** Short javadoc. Can be null. */
35 private String mJavaDoc;
36 /** Attributes for this view or view group. Can be empty but never null. */
37 private AttributeInfo[] mAttributes;
39 public static class LayoutParamsInfo {
40 /** Short class name, e.g. LayoutData, never null. */
41 private String mShortClassName;
42 /** ViewLayout class info owning this layout data */
43 private ViewClassInfo mViewLayoutClass;
44 /** Super class. Can be null. */
45 private LayoutParamsInfo mSuperClass;
46 /** Layout Data Attributes for layout classes. Can be empty but not null. */
47 private AttributeInfo[] mAttributes;
49 public LayoutParamsInfo(ViewClassInfo enclosingViewClassInfo,
50 String shortClassName, LayoutParamsInfo superClassInfo) {
51 mShortClassName = shortClassName;
52 mViewLayoutClass = enclosingViewClassInfo;
53 mSuperClass = superClassInfo;
54 mAttributes = new AttributeInfo[0];
57 /** Returns short class name, e.g. "LayoutData" */
58 public String getShortClassName() {
59 return mShortClassName;
61 /** Returns the ViewLayout class info enclosing this layout data. Cannot null. */
62 public ViewClassInfo getViewLayoutClass() {
63 return mViewLayoutClass;
65 /** Returns the super class info. Can be null. */
66 public LayoutParamsInfo getSuperClass() {
69 /** Returns the LayoutData attributes. Can be empty but not null. */
70 public AttributeInfo[] getAttributes() {
73 /** Sets the LayoutData attributes. Can be empty but not null. */
74 public void setAttributes(AttributeInfo[] attributes) {
75 mAttributes = attributes;
79 /** Layout data info for a layout class. Null for all non-layout classes and always
80 * non-null for a layout class. */
81 public LayoutParamsInfo mLayoutData;
85 public ViewClassInfo(boolean isLayout, String fullClassName, String shortClassName) {
87 mFullClassName = fullClassName;
88 mShortClassName = shortClassName;
89 mAttributes = new AttributeInfo[0];
92 /** Returns whether this is a layout class (i.e. ViewGroup) or just a View */
93 public boolean isLayout() {
97 /** Returns FQCN e.g. "android.view.View" */
98 public String getFullClassName() {
99 return mFullClassName;
102 /** Returns short class name, e.g. "View" */
103 public String getShortClassName() {
104 return mShortClassName;
107 /** Returns the super class. Can be null. */
108 public ViewClassInfo getSuperClass() {
112 /** Returns a short javadoc */
113 public String getJavaDoc() {
117 /** Returns the attributes for this view or view group. Maybe empty but not null. */
118 public AttributeInfo[] getAttributes() {
122 /** Returns the LayoutData info for layout classes. Null for non-layout view classes. */
123 public LayoutParamsInfo getLayoutData() {
128 * Sets a link on the info of the super class of this View or ViewGroup.
130 * The super class info must be of the same kind (i.e. group to group or view to view)
131 * except for the top ViewGroup which links to the View info.
133 * The super class cannot be null except for the top View info.
135 public void setSuperClass(ViewClassInfo superClass) {
136 mSuperClass = superClass;
139 /** Sets the javadoc for this View or ViewGroup. */
140 public void setJavaDoc(String javaDoc) {
144 /** Sets the list of attributes for this View or ViewGroup. */
145 public void setAttributes(AttributeInfo[] attributes) {
146 mAttributes = attributes;
150 * Sets the {@link LayoutParamsInfo} for layout classes.
151 * Does nothing for non-layout view classes.
153 public void setLayoutParams(LayoutParamsInfo layoutData) {
155 mLayoutData = layoutData;