1 /* 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 17 package com.google.doclava; 18 19 import com.google.clearsilver.jsilver.data.Data; 20 21 public 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); 57 } 58 59 if (ClearPage.toroot != null) { 60 data.setValue("toroot", ClearPage.toroot); 61 } 62 63 if (linkRef.federatedSite != null) { 64 data.setValue("federated", linkRef.federatedSite); 65 } 66 } 67 68 public boolean checkLevel() { 69 return linkReference().checkLevel(); 70 } 71 72 public static void makeHDF(Data data, String base, SeeTagInfo[] tags) { 73 int j = 0; 74 for (SeeTagInfo tag : tags) { 75 if (tag.mBase.checkLevel() && tag.checkLevel()) { 76 tag.makeHDF(data, base + "." + j); 77 j++; 78 } 79 } 80 } 81 } 82