Ben Dodson | 920dbbb | 2010-08-04 15:21:06 -0700 | [diff] [blame] | 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); |
Jeff Hamilton | 9c58484 | 2012-06-25 13:24:14 -0500 | [diff] [blame^] | 57 | // data.setValue(base + ".link", linkRef.href); |
Ben Dodson | 920dbbb | 2010-08-04 15:21:06 -0700 | [diff] [blame] | 58 | } |
Jeff Hamilton | 9c58484 | 2012-06-25 13:24:14 -0500 | [diff] [blame^] | 59 | |
| 60 | // JHAM |
| 61 | System.out.println("##### base = " + base + ", toroot = " + ClearPage.toroot + ", kind = " + kind()); |
| 62 | if (ClearPage.toroot != null) { |
| 63 | data.setValue("toroot", ClearPage.toroot); |
| 64 | } |
| 65 | if (linkRef.federatedSite != null) { |
| 66 | data.setValue("federated", linkRef.federatedSite); |
| 67 | } |
| 68 | // /JHAM |
Ben Dodson | 920dbbb | 2010-08-04 15:21:06 -0700 | [diff] [blame] | 69 | } |
| 70 | |
| 71 | public boolean checkLevel() { |
| 72 | return linkReference().checkLevel(); |
| 73 | } |
| 74 | |
| 75 | public static void makeHDF(Data data, String base, SeeTagInfo[] tags) { |
| 76 | int j = 0; |
| 77 | for (SeeTagInfo tag : tags) { |
| 78 | if (tag.mBase.checkLevel() && tag.checkLevel()) { |
| 79 | tag.makeHDF(data, base + "." + j); |
| 80 | j++; |
| 81 | } |
| 82 | } |
| 83 | } |
| 84 | } |