blob: 34e6aed7bf93131641bbcde9bccc1e6cd1e755d9 [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 {
22 private ContainerInfo mBase;
23 LinkReference mLink;
24
25 SeeTagInfo(String name, String kind, String text, ContainerInfo base, SourcePositionInfo position) {
26 super(name, kind, text, position);
27 mBase = base;
28 }
29
30 protected LinkReference linkReference() {
31 if (mLink == null) {
32 mLink =
33 LinkReference.parse(text(), mBase, position(), (!"@see".equals(name()))
34 && (mBase != null ? mBase.checkLevel() : true));
35 }
36 return mLink;
37 }
38
39 public String label() {
40 return linkReference().label;
41 }
42
43 @Override
44 public void makeHDF(Data data, String base) {
45 LinkReference linkRef = linkReference();
46 if (linkRef.kind != null) {
47 // if they have a better suggestion about "kind" use that.
48 // do this before super.makeHDF() so it picks it up
49 setKind(linkRef.kind);
50 }
51
52 super.makeHDF(data, base);
53
54 data.setValue(base + ".label", linkRef.label);
55 if (linkRef.href != null) {
56 data.setValue(base + ".href", linkRef.href);
Scott Main4ee085a2014-03-19 20:41:48 -070057 data.setValue(base + ".federatedSite", linkRef.federatedSite);
Ben Dodson920dbbb2010-08-04 15:21:06 -070058 }
Jeff Hamilton9c584842012-06-25 13:24:14 -050059
Jeff Hamilton9c584842012-06-25 13:24:14 -050060 if (ClearPage.toroot != null) {
61 data.setValue("toroot", ClearPage.toroot);
62 }
Jeff Hamilton72ce82e2012-08-28 15:08:11 -050063
Jeff Hamilton9c584842012-06-25 13:24:14 -050064 if (linkRef.federatedSite != null) {
65 data.setValue("federated", linkRef.federatedSite);
66 }
Ben Dodson920dbbb2010-08-04 15:21:06 -070067 }
68
69 public boolean checkLevel() {
70 return linkReference().checkLevel();
71 }
72
73 public static void makeHDF(Data data, String base, SeeTagInfo[] tags) {
74 int j = 0;
75 for (SeeTagInfo tag : tags) {
76 if (tag.mBase.checkLevel() && tag.checkLevel()) {
77 tag.makeHDF(data, base + "." + j);
78 j++;
79 }
80 }
81 }
82}