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 17package com.google.doclava; 18 19import com.google.clearsilver.jsilver.data.Data; 20 21public class TagInfo { 22 private String mName; 23 private String mText; 24 private String mKind; 25 private SourcePositionInfo mPosition; 26 27 TagInfo(String n, String k, String t, SourcePositionInfo sp) { 28 mName = n; 29 mText = t; 30 mKind = k; 31 mPosition = sp; 32 } 33 34 String name() { 35 return mName; 36 } 37 38 String text() { 39 return mText; 40 } 41 42 String kind() { 43 return mKind; 44 } 45 46 SourcePositionInfo position() { 47 return mPosition; 48 } 49 50 void setKind(String kind) { 51 mKind = kind; 52 } 53 54 public void makeHDF(Data data, String base) { 55 data.setValue(base + ".name", name()); 56 57 if (name().equals("@value")) { 58 mText = mText.replace('#', '.'); 59 } 60 data.setValue(base + ".text", text()); 61 data.setValue(base + ".kind", kind()); 62 } 63 64 public static void makeHDF(Data data, String base, TagInfo[] tags) { 65 makeHDF(data, base, tags, null, 0, 0); 66 } 67 68 public static void makeHDF(Data data, String base, InheritedTags tags) { 69 makeHDF(data, base, tags.tags(), tags.inherited(), 0, 0); 70 } 71 72 private static int makeHDF(Data data, String base, TagInfo[] tags, InheritedTags inherited, 73 int j, int depth) { 74 int i; 75 int len = tags.length; 76 if (len == 0 && inherited != null) { 77 j = makeHDF(data, base, inherited.tags(), inherited.inherited(), j, depth + 1); 78 } else { 79 for (i = 0; i < len; i++, j++) { 80 TagInfo t = tags[i]; 81 if (inherited != null && t.name().equals("@inheritDoc")) { 82 j = makeHDF(data, base, inherited.tags(), inherited.inherited(), j, depth + 1); 83 } else { 84 if (t.name().equals("@inheritDoc")) { 85 Errors.error(Errors.BAD_INHERITDOC, t.mPosition, 86 "@inheritDoc on class/method that is not inherited"); 87 } 88 t.makeHDF(data, base + "." + j); 89 } 90 } 91 } 92 return j; 93 } 94} 95