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 TagInfo { |
C. Sean Young | da4b2e2 | 2015-05-18 14:12:30 -0500 | [diff] [blame] | 22 | public static final TagInfo[] EMPTY_ARRAY = new TagInfo[0]; |
| 23 | |
| 24 | public static TagInfo[] getArray(int size) { |
| 25 | return size == 0 ? EMPTY_ARRAY : new TagInfo[size]; |
| 26 | } |
| 27 | |
Ben Dodson | 920dbbb | 2010-08-04 15:21:06 -0700 | [diff] [blame] | 28 | private String mName; |
| 29 | private String mText; |
| 30 | private String mKind; |
| 31 | private SourcePositionInfo mPosition; |
| 32 | |
| 33 | TagInfo(String n, String k, String t, SourcePositionInfo sp) { |
| 34 | mName = n; |
| 35 | mText = t; |
| 36 | mKind = k; |
| 37 | mPosition = sp; |
| 38 | } |
| 39 | |
| 40 | String name() { |
| 41 | return mName; |
| 42 | } |
| 43 | |
| 44 | String text() { |
| 45 | return mText; |
| 46 | } |
| 47 | |
| 48 | String kind() { |
| 49 | return mKind; |
| 50 | } |
| 51 | |
| 52 | SourcePositionInfo position() { |
| 53 | return mPosition; |
| 54 | } |
| 55 | |
| 56 | void setKind(String kind) { |
| 57 | mKind = kind; |
| 58 | } |
| 59 | |
| 60 | public void makeHDF(Data data, String base) { |
| 61 | data.setValue(base + ".name", name()); |
Scott Main | 4ec568b | 2012-11-30 18:33:21 -0800 | [diff] [blame] | 62 | |
| 63 | if (name().equals("@value")) { |
| 64 | mText = mText.replace('#', '.'); |
| 65 | } |
Ben Dodson | 920dbbb | 2010-08-04 15:21:06 -0700 | [diff] [blame] | 66 | data.setValue(base + ".text", text()); |
| 67 | data.setValue(base + ".kind", kind()); |
| 68 | } |
| 69 | |
| 70 | public static void makeHDF(Data data, String base, TagInfo[] tags) { |
| 71 | makeHDF(data, base, tags, null, 0, 0); |
| 72 | } |
| 73 | |
| 74 | public static void makeHDF(Data data, String base, InheritedTags tags) { |
| 75 | makeHDF(data, base, tags.tags(), tags.inherited(), 0, 0); |
| 76 | } |
| 77 | |
| 78 | private static int makeHDF(Data data, String base, TagInfo[] tags, InheritedTags inherited, |
| 79 | int j, int depth) { |
| 80 | int i; |
| 81 | int len = tags.length; |
| 82 | if (len == 0 && inherited != null) { |
| 83 | j = makeHDF(data, base, inherited.tags(), inherited.inherited(), j, depth + 1); |
| 84 | } else { |
| 85 | for (i = 0; i < len; i++, j++) { |
| 86 | TagInfo t = tags[i]; |
| 87 | if (inherited != null && t.name().equals("@inheritDoc")) { |
| 88 | j = makeHDF(data, base, inherited.tags(), inherited.inherited(), j, depth + 1); |
| 89 | } else { |
| 90 | if (t.name().equals("@inheritDoc")) { |
| 91 | Errors.error(Errors.BAD_INHERITDOC, t.mPosition, |
| 92 | "@inheritDoc on class/method that is not inherited"); |
| 93 | } |
| 94 | t.makeHDF(data, base + "." + j); |
| 95 | } |
| 96 | } |
| 97 | } |
| 98 | return j; |
| 99 | } |
| 100 | } |