libjava/ChangeLog:
[official-gcc.git] / libjava / classpath / tools / gnu / classpath / tools / taglets / GenericTaglet.java
blob7e18cdcac6d9f938f502283b990a52efc5dd321f
1 /* gnu.classpath.tools.taglets.GenericTaglet
2 Copyright (C) 2001 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 02111-1307 USA. */
21 package gnu.classpath.tools.taglets;
23 import java.util.Map;
25 import com.sun.tools.doclets.Taglet;
27 import com.sun.javadoc.Tag;
29 /**
30 * A taglet which can be configured at runtime.
32 * @author Julian Scheid (julian@sektor37.de)
34 public class GenericTaglet implements Taglet {
36 private String name = "since";
37 private String header = "Since:";
39 private boolean scopeOverview;
40 private boolean scopePackage;
41 private boolean scopeType;
42 private boolean scopeConstructor;
43 private boolean scopeMethod;
44 private boolean scopeField;
46 private boolean enabled = true;
48 public GenericTaglet(String name,
49 String header,
50 boolean scopeOverview,
51 boolean scopePackage,
52 boolean scopeType,
53 boolean scopeConstructor,
54 boolean scopeMethod,
55 boolean scopeField)
57 this.name = name;
58 this.header = header;
59 this.scopeOverview = scopeOverview;
60 this.scopePackage = scopePackage;
61 this.scopeType = scopeType;
62 this.scopeConstructor = scopeConstructor;
63 this.scopeMethod = scopeMethod;
64 this.scopeField = scopeField;
67 public String getName() {
68 return name;
71 public boolean inField() {
72 return scopeField;
75 public boolean inConstructor() {
76 return scopeConstructor;
79 public boolean inMethod() {
80 return scopeMethod;
83 public boolean inOverview() {
84 return scopeOverview;
87 public boolean inPackage() {
88 return scopePackage;
91 public boolean inType() {
92 return scopeType;
95 public boolean isInlineTag() {
96 return false;
99 public void register(Map tagletMap) {
100 tagletMap.put(getName(), this);
103 public String toString(Tag tag) {
104 if (enabled) {
105 return toString(new Tag[] { tag });
107 else {
108 return null;
112 public String toString(Tag[] tags) {
113 if (!enabled || tags.length == 0) {
114 return null;
116 else {
118 StringBuffer result = new StringBuffer();
119 result.append("<div class=\"classdoc-tag-section-header\">");
120 result.append(header);
121 result.append("</div>");
122 result.append("<dl class=\"classdoc-list\">");
123 for (int i = 0; i < tags.length; i++) {
124 result.append("<dt>");
125 result.append(tags[i].text());
126 result.append("</dt>");
128 result.append("</dl>");
129 return result.toString();
134 * Enables/disables this taglet.
136 public void setTagletEnabled(boolean enabled)
138 this.enabled = enabled;