blob: 9f38655c74064580351598ff375678c09262e8c6 [file] [log] [blame]
Ben Dodson920dbbb2010-08-04 15:21:06 -07001/*
2 * Copyright (C) 2010 Google Inc.
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
17package com.google.doclava;
18
19import com.google.clearsilver.jsilver.data.Data;
20
21public class SeeTagInfo extends TagInfo {
C. Sean Youngda4b2e22015-05-18 14:12:30 -050022 public static final SeeTagInfo[] EMPTY_ARRAY = new SeeTagInfo[0];
23
24 public static SeeTagInfo[] getArray(int size) {
25 return size == 0 ? EMPTY_ARRAY : new SeeTagInfo[size];
26 }
27
Ben Dodson920dbbb2010-08-04 15:21:06 -070028 private ContainerInfo mBase;
29 LinkReference mLink;
30
31 SeeTagInfo(String name, String kind, String text, ContainerInfo base, SourcePositionInfo position) {
32 super(name, kind, text, position);
33 mBase = base;
34 }
35
36 protected LinkReference linkReference() {
37 if (mLink == null) {
38 mLink =
39 LinkReference.parse(text(), mBase, position(), (!"@see".equals(name()))
40 && (mBase != null ? mBase.checkLevel() : true));
41 }
42 return mLink;
43 }
44
45 public String label() {
46 return linkReference().label;
47 }
48
49 @Override
50 public void makeHDF(Data data, String base) {
51 LinkReference linkRef = linkReference();
52 if (linkRef.kind != null) {
53 // if they have a better suggestion about "kind" use that.
54 // do this before super.makeHDF() so it picks it up
55 setKind(linkRef.kind);
56 }
57
58 super.makeHDF(data, base);
59
60 data.setValue(base + ".label", linkRef.label);
61 if (linkRef.href != null) {
62 data.setValue(base + ".href", linkRef.href);
Scott Main4ee085a2014-03-19 20:41:48 -070063 data.setValue(base + ".federatedSite", linkRef.federatedSite);
Ben Dodson920dbbb2010-08-04 15:21:06 -070064 }
Jeff Hamilton9c584842012-06-25 13:24:14 -050065
Jeff Hamilton9c584842012-06-25 13:24:14 -050066 if (ClearPage.toroot != null) {
67 data.setValue("toroot", ClearPage.toroot);
68 }
Jeff Hamilton72ce82e2012-08-28 15:08:11 -050069
Jeff Hamilton9c584842012-06-25 13:24:14 -050070 if (linkRef.federatedSite != null) {
71 data.setValue("federated", linkRef.federatedSite);
72 }
Ben Dodson920dbbb2010-08-04 15:21:06 -070073 }
74
75 public boolean checkLevel() {
76 return linkReference().checkLevel();
77 }
78
79 public static void makeHDF(Data data, String base, SeeTagInfo[] tags) {
80 int j = 0;
81 for (SeeTagInfo tag : tags) {
82 if (tag.mBase.checkLevel() && tag.checkLevel()) {
83 tag.makeHDF(data, base + "." + j);
84 j++;
85 }
86 }
87 }
88}