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 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 28 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); 63 data.setValue(base + ".federatedSite", linkRef.federatedSite); 64 } 65 66 if (ClearPage.toroot != null) { 67 data.setValue("toroot", ClearPage.toroot); 68 } 69 70 if (linkRef.federatedSite != null) { 71 data.setValue("federated", linkRef.federatedSite); 72 } 73 } 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 } 89