blob: a24106bb6d0c4ec4cd0985dce91df020ce2d237f [file] [log] [blame]
The Android Open Source Project88b60792009-03-03 19:28:42 -08001/*
2 * Copyright (C) 2008 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
17import java.util.ArrayList;
18import java.util.Comparator;
19
20import org.clearsilver.HDF;
21import org.clearsilver.CS;
22
23public class AttributeInfo {
24 public static final Comparator<AttributeInfo> comparator = new Comparator<AttributeInfo>() {
25 public int compare(AttributeInfo a, AttributeInfo b) {
26 return a.name().compareTo(b.name());
27 }
28 };
29
30 public FieldInfo attrField;
31 public ArrayList<MethodInfo> methods = new ArrayList<MethodInfo>();
32
33 private ClassInfo mClass;
34 private String mName;
35 private Comment mComment;
36
37 public AttributeInfo(ClassInfo cl, FieldInfo f) {
38 mClass = cl;
39 attrField = f;
40 }
41
42 public String name() {
43 if (mName == null) {
44 for (AttrTagInfo comment: attrField.comment().attrTags()) {
45 String n = comment.name();
46 if (n != null) {
47 mName = n;
48 return n;
49 }
50 }
51 }
52 return mName;
53 }
54
55 public Comment comment() {
56 if (mComment == null) {
57 for (AttrTagInfo attr: attrField.comment().attrTags()) {
58 Comment c = attr.description();
59 if (c != null) {
60 mComment = c;
61 return c;
62 }
63 }
64 }
65 if (mComment == null) {
66 return new Comment("", mClass, new SourcePositionInfo());
67 }
68 return mComment;
69 }
70
71 public String anchor() {
72 return "attr_" + name();
73 }
74 public String htmlPage() {
75 return mClass.htmlPage() + "#" + anchor();
76 }
77
78 public void makeHDF(HDF data, String base) {
79 data.setValue(base + ".name", name());
80 data.setValue(base + ".anchor", anchor());
81 data.setValue(base + ".href", htmlPage());
82 data.setValue(base + ".R.name", attrField.name());
83 data.setValue(base + ".R.href", attrField.htmlPage());
84 TagInfo.makeHDF(data, base + ".deprecated", attrField.comment().deprecatedTags());
85 TagInfo.makeHDF(data, base + ".shortDescr", comment().briefTags());
86 TagInfo.makeHDF(data, base + ".descr", comment().tags());
87
88 int i=0;
89 for (MethodInfo m: methods) {
90 String s = base + ".methods." + i;
91 data.setValue(s + ".href", m.htmlPage());
92 data.setValue(s + ".name", m.name() + m.prettySignature());
93 }
94 }
95
96 public boolean checkLevel() {
97 return attrField.checkLevel();
98 }
99}
100