OSDN Git Service

am 7ebafd5a: Merge change 9009 into donut
[android-x86/build.git] / tools / droiddoc / src / SeeTagInfo.java
1 /*
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
17 import java.util.regex.Pattern;
18 import java.util.regex.Matcher;
19 import org.clearsilver.HDF;
20 import org.clearsilver.CS;
21 import java.util.ArrayList;
22
23 public class SeeTagInfo extends TagInfo
24 {
25     private ContainerInfo mBase;
26     LinkReference mLink;
27
28     SeeTagInfo(String name, String kind, String text, ContainerInfo base,
29             SourcePositionInfo position)
30     {
31         super(name, kind, text, position);
32         mBase = base;
33     }
34
35     protected LinkReference linkReference() {
36         if (mLink == null) {
37             mLink = LinkReference.parse(text(), mBase, position(),
38                            (!"@see".equals(name())) && (mBase != null ? mBase.checkLevel() : true));
39         }
40         return mLink;
41     }
42
43     public String label()
44     {
45         return linkReference().label;
46     }
47
48     public void makeHDF(HDF data, String base)
49     {
50         LinkReference linkRef = linkReference();
51         if (linkRef.kind != null) {
52             // if they have a better suggestion about "kind" use that.
53             // do this before super.makeHDF() so it picks it up
54             setKind(linkRef.kind);
55         }
56
57         super.makeHDF(data, base);
58
59         data.setValue(base + ".label", linkRef.label);
60         if (linkRef.href != null) {
61             data.setValue(base + ".href", linkRef.href);
62         }
63     }
64
65     public boolean checkLevel() {
66         return linkReference().checkLevel();
67     }
68
69     public static void makeHDF(HDF data, String base, SeeTagInfo[] tags)
70     {
71         int j=0;
72         for (SeeTagInfo tag: tags) {
73             if (tag.mBase.checkLevel() && tag.checkLevel()) {
74                 tag.makeHDF(data, base + "." + j);
75                 j++;
76             }
77         }
78     }
79 }