summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew John Hughes <gnu_andrew@member.fsf.org>2009-03-20 13:03:45 +0000
committerAndrew John Hughes <gnu_andrew@member.fsf.org>2009-03-20 13:03:45 +0000
commit0a7f6ac8bee428e35b432a1e6c224998e37f4e59 (patch)
tree5a0dad58327324fda5af7fdb9957f74feafd1e54
parente84b91d2ce1864c3c04fe7b91e994dbb7be150f3 (diff)
downloadclasspath-0a7f6ac8bee428e35b432a1e6c224998e37f4e59.tar.gz
Cleanup generic warnings in gjavah.
2009-03-20 Andrew John Hughes <ahughes@redhat.com> * tools/gnu/classpath/tools/javah/ClassWrapper.java, * tools/gnu/classpath/tools/javah/CniPrintStream.java, * tools/gnu/classpath/tools/javah/CniStubPrinter.java, * tools/gnu/classpath/tools/javah/GcjhMain.java, * tools/gnu/classpath/tools/javah/JniIncludePrinter.java, * tools/gnu/classpath/tools/javah/JniPrintStream.java, * tools/gnu/classpath/tools/javah/JniStubPrinter.java, * tools/gnu/classpath/tools/javah/Keywords.java, * tools/gnu/classpath/tools/javah/Main.java, * tools/gnu/classpath/tools/javah/MethodHelper.java, * tools/gnu/classpath/tools/javah/PathOptionGroup.java: Fix generic issues in gjavah.
-rw-r--r--ChangeLog34
-rw-r--r--tools/gnu/classpath/tools/FileSystemClassLoader.java626
-rw-r--r--tools/gnu/classpath/tools/doclets/xmldoclet/Driver.java4902
-rw-r--r--tools/gnu/classpath/tools/doclets/xmldoclet/Driver1_4.java168
-rw-r--r--tools/gnu/classpath/tools/doclets/xmldoclet/HtmlRepairer.java1382
-rw-r--r--tools/gnu/classpath/tools/doclets/xmldoclet/TargetContext.java206
-rw-r--r--tools/gnu/classpath/tools/doclets/xmldoclet/doctranslet/OutputFileInfo.java132
-rw-r--r--tools/gnu/classpath/tools/gjdoc/ErrorReporter.java242
-rw-r--r--tools/gnu/classpath/tools/gjdoc/TemporaryStore.java264
-rw-r--r--tools/gnu/classpath/tools/gjdoc/WritableType.java88
-rw-r--r--tools/gnu/classpath/tools/javah/ClassWrapper.java50
-rw-r--r--tools/gnu/classpath/tools/javah/CniPrintStream.java4
-rw-r--r--tools/gnu/classpath/tools/javah/CniStubPrinter.java2
-rw-r--r--tools/gnu/classpath/tools/javah/GcjhMain.java2
-rw-r--r--tools/gnu/classpath/tools/javah/JniIncludePrinter.java4
-rw-r--r--tools/gnu/classpath/tools/javah/JniPrintStream.java10
-rw-r--r--tools/gnu/classpath/tools/javah/JniStubPrinter.java2
-rw-r--r--tools/gnu/classpath/tools/javah/Keywords.java4
-rw-r--r--tools/gnu/classpath/tools/javah/Main.java30
-rw-r--r--tools/gnu/classpath/tools/javah/MethodHelper.java2
-rw-r--r--tools/gnu/classpath/tools/javah/PathOptionGroup.java16
-rw-r--r--tools/gnu/classpath/tools/taglets/AuthorTaglet.java586
-rw-r--r--tools/gnu/classpath/tools/taglets/CopyrightTaglet.java246
-rw-r--r--tools/gnu/classpath/tools/taglets/DeprecatedTaglet.java264
-rw-r--r--tools/gnu/classpath/tools/taglets/GenericTaglet.java314
-rw-r--r--tools/gnu/classpath/tools/taglets/SinceTaglet.java322
-rw-r--r--tools/gnu/classpath/tools/taglets/VersionTaglet.java306
27 files changed, 5121 insertions, 5087 deletions
diff --git a/ChangeLog b/ChangeLog
index f9c0048e6..305be2455 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,37 @@
+2009-03-20 Andrew John Hughes <ahughes@redhat.com>
+
+ * tools/gnu/classpath/tools/javah/ClassWrapper.java,
+ * tools/gnu/classpath/tools/javah/CniPrintStream.java,
+ * tools/gnu/classpath/tools/javah/CniStubPrinter.java,
+ * tools/gnu/classpath/tools/javah/GcjhMain.java,
+ * tools/gnu/classpath/tools/javah/JniIncludePrinter.java,
+ * tools/gnu/classpath/tools/javah/JniPrintStream.java,
+ * tools/gnu/classpath/tools/javah/JniStubPrinter.java,
+ * tools/gnu/classpath/tools/javah/Keywords.java,
+ * tools/gnu/classpath/tools/javah/Main.java,
+ * tools/gnu/classpath/tools/javah/MethodHelper.java,
+ * tools/gnu/classpath/tools/javah/PathOptionGroup.java:
+ Fix generic issues in gjavah.
+
+2009-03-17 Andrew John Hughes <ahughes@redhat.com>
+
+ * tools/gnu/classpath/tools/FileSystemClassLoader.java,
+ * tools/gnu/classpath/tools/doclets/xmldoclet/Driver.java,
+ * tools/gnu/classpath/tools/doclets/xmldoclet/Driver1_4.java,
+ * tools/gnu/classpath/tools/doclets/xmldoclet/HtmlRepairer.java,
+ * tools/gnu/classpath/tools/doclets/xmldoclet/TargetContext.java,
+ * tools/gnu/classpath/tools/doclets/xmldoclet/doctranslet/OutputFileInfo.java,
+ * tools/gnu/classpath/tools/gjdoc/ErrorReporter.java,
+ * tools/gnu/classpath/tools/gjdoc/TemporaryStore.java,
+ * tools/gnu/classpath/tools/gjdoc/WritableType.java,
+ * tools/gnu/classpath/tools/taglets/AuthorTaglet.java,
+ * tools/gnu/classpath/tools/taglets/CopyrightTaglet.java,
+ * tools/gnu/classpath/tools/taglets/DeprecatedTaglet.java,
+ * tools/gnu/classpath/tools/taglets/GenericTaglet.java,
+ * tools/gnu/classpath/tools/taglets/SinceTaglet.java,
+ * tools/gnu/classpath/tools/taglets/VersionTaglet.java:
+ Switch to UNIX line endings.
+
2009-03-17 Andrew John Hughes <ahughes@redhat.com>
* tools/com/sun/tools/javadoc/Main.java,
diff --git a/tools/gnu/classpath/tools/FileSystemClassLoader.java b/tools/gnu/classpath/tools/FileSystemClassLoader.java
index 366353a4f..3a21fe96e 100644
--- a/tools/gnu/classpath/tools/FileSystemClassLoader.java
+++ b/tools/gnu/classpath/tools/FileSystemClassLoader.java
@@ -1,313 +1,313 @@
-/* gnu.classpath.tools.FileSystemClassLoader
- Copyright (C) 2004 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
-
-package gnu.classpath.tools;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.InputStream;
-import java.io.IOException;
-import java.io.StreamTokenizer;
-import java.io.StringReader;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-
-import java.util.LinkedList;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.StringTokenizer;
-
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
-import java.util.jar.Manifest;
-import java.util.jar.Attributes;
-
-/**
- * A <code>ClassLoader</code> implementation which looks for classes
- * on the local filesystem given a standard search path.
- */
-public class FileSystemClassLoader extends ClassLoader {
-
- private File[] pathComponents;
-
- /**
- * Initialize the class loader with a normal path string. The path
- * string should contain path components separated by {@link
- * File.pathSeparator}. Each path component should either denote a
- * directory or a .jar or .zip file.
- */
- public FileSystemClassLoader(String path)
- {
- List components = new ArrayList();
- for (StringTokenizer st = new StringTokenizer(path, File.pathSeparator); st.hasMoreTokens(); ) {
- File pathComponent = new File(st.nextToken());
- components.add(pathComponent);
- if (pathComponent.exists() && !pathComponent.isDirectory()) {
- List subComponents = tryGetJarFileClassPathComponents(pathComponent);
- if (null != subComponents) {
- components.addAll(subComponents);
- }
- }
- }
- File[] componentArray = new File[components.size()];
- this.pathComponents = (File[])components.toArray(componentArray);
- }
-
- /**
- * Initialize the class loader with an array of path
- * components. Each path component should either denote a
- * directory or a .jar or .zip file.
- */
- public FileSystemClassLoader(File[] pathComponents)
- {
- this.pathComponents = pathComponents;
- for (int i = 0; i < pathComponents.length; ++i) {
- if (!pathComponents[i].exists()) {
- System.err.println("WARNING: Path component '" + pathComponents[i] + "' not found.");
- }
- }
- }
-
- public Class loadClass(String name)
- throws ClassNotFoundException {
-
- return super.loadClass(name);
- }
-
- public Class findClass(String name)
- throws ClassNotFoundException {
-
- byte[] b = loadClassData(name);
- return defineClass(name, b, 0, b.length);
- }
-
- public URL findResource(String name)
- {
- StreamInfo streamInfo = getResourceStream(name);
- if (null == streamInfo) {
- return super.findResource(name);
- }
- else {
- try {
- return streamInfo.getURL();
- }
- catch (MalformedURLException e) {
- System.err.println("WARNING: In FileSystemClassLoader: could not derive URL from file or jar entry: " + e.toString());
- return null;
- }
- }
- }
-
- private byte[] readFromStream(InputStream in, long size)
- throws IOException
- {
- byte[] result = new byte[(int)size];
- int nread = 0;
- int offset = 0;
- while (offset < size && (nread = in.read(result, offset, (int)(size - offset))) >= 0) {
- offset += nread;
- }
- in.close();
- return result;
- }
-
- private byte[] readFromStream(StreamInfo streamInfo)
- throws IOException
- {
- InputStream in = streamInfo.openStream();
- long size = streamInfo.getSize();
-
- byte[] result = new byte[(int)size];
- int nread = 0;
- int offset = 0;
- while (offset < size && (nread = in.read(result, offset, (int)(size - offset))) >= 0) {
- offset += nread;
- }
- in.close();
- return result;
- }
-
- private static interface StreamInfo
- {
- public InputStream openStream()
- throws IOException;
- public long getSize();
- public URL getURL()
- throws MalformedURLException;
- }
-
- private static class FileStreamInfo
- implements StreamInfo
- {
- File file;
-
- FileStreamInfo(File file)
- {
- this.file = file;
- }
-
- public InputStream openStream()
- throws IOException
- {
- return new FileInputStream(file);
- }
-
- public long getSize()
- {
- return file.length();
- }
-
- public URL getURL()
- throws MalformedURLException
- {
- return file.toURL();
- }
- }
-
- private static class JarStreamInfo
- implements StreamInfo
- {
- private File file;
- private JarFile jarFile;
- private JarEntry jarEntry;
-
- JarStreamInfo(File file, JarFile jarFile, JarEntry jarEntry)
- {
- this.file = file;
- this.jarFile = jarFile;
- this.jarEntry = jarEntry;
- }
-
- public InputStream openStream()
- throws IOException
- {
- return jarFile.getInputStream(jarEntry);
- }
-
- public long getSize()
- {
- return jarEntry.getSize();
- }
-
- public URL getURL()
- throws MalformedURLException
- {
- String urlString = "jar:" + file.toURL() + "!/" + jarEntry.getName();
- return new URL(urlString);
- }
- }
-
- private StreamInfo getResourceStream(String path)
- {
- for (int i = 0; i < pathComponents.length; ++i) {
- try {
- File parent = pathComponents[i];
- if (parent.isDirectory()) {
- File file = new File(parent, path);
- if (file.exists()) {
- return new FileStreamInfo(file);
- }
- }
- else {
- JarFile jarFile = new JarFile(parent, false, JarFile.OPEN_READ);
- JarEntry jarEntry = jarFile.getJarEntry(path);
- if (null != jarEntry) {
- return new JarStreamInfo(parent, jarFile, jarEntry);
- }
- }
- }
- catch (IOException ignore) {
- }
- }
- return null;
- }
-
- private byte[] loadClassData(String className)
- throws ClassNotFoundException
- {
- String classFileName = className.replace('.', File.separatorChar) + ".class";
- StreamInfo streamInfo = getResourceStream(classFileName);
-
- try {
- if (null != streamInfo) {
- return readFromStream(streamInfo);
- }
- }
- catch (IOException ignore) {
- }
-
- throw new ClassNotFoundException(className);
- }
-
- private static List tryGetJarFileClassPathComponents(File file)
- {
- try {
- JarFile jarFile = new JarFile(file, false, JarFile.OPEN_READ);
- Manifest manifest = jarFile.getManifest();
- if (null != manifest) {
- Attributes mainAttributes = manifest.getMainAttributes();
- if (null != mainAttributes) {
- String classPath = mainAttributes.getValue(Attributes.Name.CLASS_PATH);
- if (null != classPath) {
- List result = new LinkedList();
- StreamTokenizer tokenizer = new StreamTokenizer(new StringReader(classPath));
- tokenizer.resetSyntax();
- tokenizer.wordChars(0, Integer.MAX_VALUE);
- tokenizer.whitespaceChars(9, 9); // tab
- tokenizer.whitespaceChars(10, 10); // lf
- tokenizer.whitespaceChars(13, 13); // cr
- tokenizer.whitespaceChars(32, 32); // space
- tokenizer.quoteChar('"');
- int token;
- while ((token = tokenizer.nextToken()) != StreamTokenizer.TT_EOF) {
- if (StreamTokenizer.TT_WORD == token) {
- result.add(new File(file.getParentFile(), tokenizer.sval));
- }
- }
- return result;
- }
- }
- }
- }
- catch (IOException ignore) {
- }
- return null;
- }
-}
-
+/* gnu.classpath.tools.FileSystemClassLoader
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.StreamTokenizer;
+import java.io.StringReader;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import java.util.LinkedList;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.StringTokenizer;
+
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+import java.util.jar.Attributes;
+
+/**
+ * A <code>ClassLoader</code> implementation which looks for classes
+ * on the local filesystem given a standard search path.
+ */
+public class FileSystemClassLoader extends ClassLoader {
+
+ private File[] pathComponents;
+
+ /**
+ * Initialize the class loader with a normal path string. The path
+ * string should contain path components separated by {@link
+ * File.pathSeparator}. Each path component should either denote a
+ * directory or a .jar or .zip file.
+ */
+ public FileSystemClassLoader(String path)
+ {
+ List components = new ArrayList();
+ for (StringTokenizer st = new StringTokenizer(path, File.pathSeparator); st.hasMoreTokens(); ) {
+ File pathComponent = new File(st.nextToken());
+ components.add(pathComponent);
+ if (pathComponent.exists() && !pathComponent.isDirectory()) {
+ List subComponents = tryGetJarFileClassPathComponents(pathComponent);
+ if (null != subComponents) {
+ components.addAll(subComponents);
+ }
+ }
+ }
+ File[] componentArray = new File[components.size()];
+ this.pathComponents = (File[])components.toArray(componentArray);
+ }
+
+ /**
+ * Initialize the class loader with an array of path
+ * components. Each path component should either denote a
+ * directory or a .jar or .zip file.
+ */
+ public FileSystemClassLoader(File[] pathComponents)
+ {
+ this.pathComponents = pathComponents;
+ for (int i = 0; i < pathComponents.length; ++i) {
+ if (!pathComponents[i].exists()) {
+ System.err.println("WARNING: Path component '" + pathComponents[i] + "' not found.");
+ }
+ }
+ }
+
+ public Class loadClass(String name)
+ throws ClassNotFoundException {
+
+ return super.loadClass(name);
+ }
+
+ public Class findClass(String name)
+ throws ClassNotFoundException {
+
+ byte[] b = loadClassData(name);
+ return defineClass(name, b, 0, b.length);
+ }
+
+ public URL findResource(String name)
+ {
+ StreamInfo streamInfo = getResourceStream(name);
+ if (null == streamInfo) {
+ return super.findResource(name);
+ }
+ else {
+ try {
+ return streamInfo.getURL();
+ }
+ catch (MalformedURLException e) {
+ System.err.println("WARNING: In FileSystemClassLoader: could not derive URL from file or jar entry: " + e.toString());
+ return null;
+ }
+ }
+ }
+
+ private byte[] readFromStream(InputStream in, long size)
+ throws IOException
+ {
+ byte[] result = new byte[(int)size];
+ int nread = 0;
+ int offset = 0;
+ while (offset < size && (nread = in.read(result, offset, (int)(size - offset))) >= 0) {
+ offset += nread;
+ }
+ in.close();
+ return result;
+ }
+
+ private byte[] readFromStream(StreamInfo streamInfo)
+ throws IOException
+ {
+ InputStream in = streamInfo.openStream();
+ long size = streamInfo.getSize();
+
+ byte[] result = new byte[(int)size];
+ int nread = 0;
+ int offset = 0;
+ while (offset < size && (nread = in.read(result, offset, (int)(size - offset))) >= 0) {
+ offset += nread;
+ }
+ in.close();
+ return result;
+ }
+
+ private static interface StreamInfo
+ {
+ public InputStream openStream()
+ throws IOException;
+ public long getSize();
+ public URL getURL()
+ throws MalformedURLException;
+ }
+
+ private static class FileStreamInfo
+ implements StreamInfo
+ {
+ File file;
+
+ FileStreamInfo(File file)
+ {
+ this.file = file;
+ }
+
+ public InputStream openStream()
+ throws IOException
+ {
+ return new FileInputStream(file);
+ }
+
+ public long getSize()
+ {
+ return file.length();
+ }
+
+ public URL getURL()
+ throws MalformedURLException
+ {
+ return file.toURL();
+ }
+ }
+
+ private static class JarStreamInfo
+ implements StreamInfo
+ {
+ private File file;
+ private JarFile jarFile;
+ private JarEntry jarEntry;
+
+ JarStreamInfo(File file, JarFile jarFile, JarEntry jarEntry)
+ {
+ this.file = file;
+ this.jarFile = jarFile;
+ this.jarEntry = jarEntry;
+ }
+
+ public InputStream openStream()
+ throws IOException
+ {
+ return jarFile.getInputStream(jarEntry);
+ }
+
+ public long getSize()
+ {
+ return jarEntry.getSize();
+ }
+
+ public URL getURL()
+ throws MalformedURLException
+ {
+ String urlString = "jar:" + file.toURL() + "!/" + jarEntry.getName();
+ return new URL(urlString);
+ }
+ }
+
+ private StreamInfo getResourceStream(String path)
+ {
+ for (int i = 0; i < pathComponents.length; ++i) {
+ try {
+ File parent = pathComponents[i];
+ if (parent.isDirectory()) {
+ File file = new File(parent, path);
+ if (file.exists()) {
+ return new FileStreamInfo(file);
+ }
+ }
+ else {
+ JarFile jarFile = new JarFile(parent, false, JarFile.OPEN_READ);
+ JarEntry jarEntry = jarFile.getJarEntry(path);
+ if (null != jarEntry) {
+ return new JarStreamInfo(parent, jarFile, jarEntry);
+ }
+ }
+ }
+ catch (IOException ignore) {
+ }
+ }
+ return null;
+ }
+
+ private byte[] loadClassData(String className)
+ throws ClassNotFoundException
+ {
+ String classFileName = className.replace('.', File.separatorChar) + ".class";
+ StreamInfo streamInfo = getResourceStream(classFileName);
+
+ try {
+ if (null != streamInfo) {
+ return readFromStream(streamInfo);
+ }
+ }
+ catch (IOException ignore) {
+ }
+
+ throw new ClassNotFoundException(className);
+ }
+
+ private static List tryGetJarFileClassPathComponents(File file)
+ {
+ try {
+ JarFile jarFile = new JarFile(file, false, JarFile.OPEN_READ);
+ Manifest manifest = jarFile.getManifest();
+ if (null != manifest) {
+ Attributes mainAttributes = manifest.getMainAttributes();
+ if (null != mainAttributes) {
+ String classPath = mainAttributes.getValue(Attributes.Name.CLASS_PATH);
+ if (null != classPath) {
+ List result = new LinkedList();
+ StreamTokenizer tokenizer = new StreamTokenizer(new StringReader(classPath));
+ tokenizer.resetSyntax();
+ tokenizer.wordChars(0, Integer.MAX_VALUE);
+ tokenizer.whitespaceChars(9, 9); // tab
+ tokenizer.whitespaceChars(10, 10); // lf
+ tokenizer.whitespaceChars(13, 13); // cr
+ tokenizer.whitespaceChars(32, 32); // space
+ tokenizer.quoteChar('"');
+ int token;
+ while ((token = tokenizer.nextToken()) != StreamTokenizer.TT_EOF) {
+ if (StreamTokenizer.TT_WORD == token) {
+ result.add(new File(file.getParentFile(), tokenizer.sval));
+ }
+ }
+ return result;
+ }
+ }
+ }
+ }
+ catch (IOException ignore) {
+ }
+ return null;
+ }
+}
+
diff --git a/tools/gnu/classpath/tools/doclets/xmldoclet/Driver.java b/tools/gnu/classpath/tools/doclets/xmldoclet/Driver.java
index c613282d3..b08d49026 100644
--- a/tools/gnu/classpath/tools/doclets/xmldoclet/Driver.java
+++ b/tools/gnu/classpath/tools/doclets/xmldoclet/Driver.java
@@ -1,2451 +1,2451 @@
-/* gnu.classpath.tools.doclets.xmldoclet.Driver
- Copyright (C) 2001 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
-
-package gnu.classpath.tools.doclets.xmldoclet;
-
-import com.sun.javadoc.*;
-import java.io.*;
-
-import com.sun.tools.doclets.Taglet;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-
-import java.text.DateFormat;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.HashSet;
-import java.util.TreeSet;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.Properties;
-import java.util.Set;
-import java.util.SortedSet;
-import java.util.StringTokenizer;
-import java.util.TreeMap;
-
-import gnu.classpath.tools.gjdoc.TemporaryStore;
-import gnu.classpath.tools.gjdoc.GjdocPackageDoc;
-
-import gnu.classpath.tools.doclets.PackageGroup;
-import gnu.classpath.tools.doclets.PackageMatcher;
-import gnu.classpath.tools.doclets.InvalidPackageWildcardException;
-
-import gnu.classpath.tools.doclets.xmldoclet.doctranslet.DocTranslet;
-import gnu.classpath.tools.doclets.xmldoclet.doctranslet.DocTransletOptions;
-
-import gnu.classpath.tools.taglets.AuthorTaglet;
-import gnu.classpath.tools.taglets.VersionTaglet;
-import gnu.classpath.tools.taglets.SinceTaglet;
-import gnu.classpath.tools.taglets.DeprecatedTaglet;
-import gnu.classpath.tools.taglets.GenericTaglet;
-import gnu.classpath.tools.doclets.StandardTaglet;
-
-import gnu.classpath.tools.java2xhtml.Java2xhtml;
-
-import gnu.classpath.tools.IOToolkit;
-import gnu.classpath.tools.FileSystemClassLoader;
-
-/**
- * A Doclet which retrieves all information presented by the Doclet
- * API, dumping it to stdout in XML format.
- *
- * @author Julian Scheid
- */
-public class Driver {
-
- public static final String XMLDOCLET_VERSION = "0.6.1";
-
- /**
- * Used for redirecting error messages to <code>/dev/null</code>.
- */
- private static class NullErrorReporter implements DocErrorReporter {
- public void printError(String ignore) {}
- public void printWarning(String ignore) {}
- public void printNotice(String ignore) {}
- }
-
- /*
- * Taglet context constants.
- */
- private static final int CONTEXT_CONSTRUCTOR = 1;
- private static final int CONTEXT_FIELD = 2;
- private static final int CONTEXT_METHOD = 3;
- private static final int CONTEXT_OVERVIEW = 4;
- private static final int CONTEXT_PACKAGE = 5;
- private static final int CONTEXT_TYPE = 6;
-
- /**
- * All XML output will go to this stream.
- */
- private PrintWriter out;
-
- /**
- * How many spaces to indent each XML node level,
- * i.e. Tab size for output.
- */
- private static int indentStep = 1;
-
- /**
- * Won't output superfluous spaces if set to true.
- * If set to false, output will be more legible.
- */
- private boolean compress = false;
-
- /**
- * Won't output warning messages while fixing
- * HTML code if set to true.
- */
- private boolean noHTMLWarn = false;
-
- /**
- * Won't output warning messages when encountering tags
- * that look like an email address if set to true.
- */
- private boolean noEmailWarn = false;
-
- /**
- * Will fix HTML if necessary so that each comment
- * contains valid XML code if set to true. If set
- * to false, HTML code will not be modified and
- * instead encapsulated in a CDATA section.
- */
- private boolean fixHTML = true;
-
- /**
- * User-specified name of the directory where the final version of
- * the generated files will be written to.
- *
- * If no XSLT sheet is given, the XML output will go directly into
- * this directory. Otherwise, XML output will go to a temporary
- * directory and XSLT output will go to this directory.
- */
- private File targetDirectory = null;
-
- /**
- * Directory where XML output will be written to. If no XSLT
- * sheet was given, this is the target directory specified
- * by the user. Otherwise, this is a temporary directory.
- */
- private File xmlTargetDirectory;
-
- /**
- * Contains a number of TargetContexts which describe which XSLT
- * sheet to apply to the output of this doclet, to what directory
- * the XSLT output is written, and which postprocess driver to use
- * to process XSLT output.
- */
- private List targets = new ArrayList();
-
- /**
- * XML text to include at the end of every generated page. Read
- * from the file specified on the command line using -bottomnote.
- * If present, this will be written to the main output file
- * (index.xml) in node /gjdoc:rootDoc/gjdoc:bottomnote.
- */
- private String bottomNote;
-
- /**
- * Brief description of the package set. Can be specified on the
- * command line using -title. This will be written to the main
- * output file (index.xml) in node
- * /gjdoc:rootDoc/gjdoc:title. The HTML generating XSLT sheet
- * uses this for example in window titles.
- */
- private String title;
-
- /**
- * Path to the directory where temporary files should be stored.
- * Defaults to system tempdir, but can be overridden by user
- * with -workpath.
- */
- private String workingPath = System.getProperty("java.io.tmpdir");
-
- /**
- * Temporary directory created by this doclet where all
- * temporary files will be stored in. If no temporary
- * files are needed (i.e. no XSLT postprocessing stage
- * specified by user), this is <code>null</code>.
- */
- private File workingDirectory;
-
- /**
- * Whether to deep-copy the doc-files subdirectory.
- */
- private boolean docFilesSubdirsEnabled = false;
-
- /**
- * Which direct subdirectories of the doc-files directories to exclude.
- * Set of String.
- */
- private Set excludeDocFilesSubDirs = new HashSet();
-
- /**
- * Stores the Doclet API RootDoc we are operating on.
- */
- private RootDoc rootDoc;
-
- /**
- * XML namespace prefix used for all tags, except for HTML
- * tags copied from Javadoc comments. Excluding colon.
- */
- public static final String tagPrefix = "gjdoc";
-
- /**
- * Classpath for loading Taglet classes.
- */
- private String tagletPath = null;
-
- /**
- * The current class that is being processed.
- * Set in outputClassDoc().
- */
- private ClassDoc currentClass;
-
- /**
- * The current member that is being processed.
- * Set in outputMemberDoc().
- */
- private MemberDoc currentMember;
-
- /**
- * The current constructor/method that is being processed.
- * Set in outputExecutableMemberDoc().
- */
- private ExecutableMemberDoc currentExecMember;
-
- /**
- * Mapping from tag type to Taglet for user Taglets specified on
- * the command line.
- */
- private Map tagletMap = new LinkedHashMap();
-
- /**
- * Keeps track of the tags mentioned by the user during option
- * processiong so that an error can be emitted if a tag is
- * mentioned more than once.
- */
- private List mentionedTags = new LinkedList();
-
- /**
- * Stores options to be passed to the DocTranslet.
- */
- private DocTransletOptions docTransletOptions = new DocTransletOptions();
-
- /**
- * Stores the package groups specified in the user
- * options. Contains objects of type PackageGroup.
- */
- private List packageGroups = new LinkedList();
-
- private HtmlRepairer htmlRepairer;
-
- public static boolean start(TemporaryStore _rootDocWrapper) {
- return new Driver().instanceStart((RootDoc)_rootDocWrapper.getAndClear());
- }
-
- /**
- * Official Doclet entry point.
- */
- public static boolean start(RootDoc _rootDoc) {
-
- // Create a new XmlDoclet instance and delegate control.
- TemporaryStore tstore = new TemporaryStore(_rootDoc);
- _rootDoc = null;
- return new Driver().instanceStart((RootDoc)tstore.getAndClear());
- }
-
- /**
- * Output an XML tag describing a com.sun.javadoc.Type object.
- * Assumes that the tag does not have subtags.
- *
- * @param level Level of indentation. Will be multiplied by
- * <code>indentStep</code> to yield actual amount
- * of whitespace inserted at start of line.
- * @param tag Identifier for the XML tag being output.
- * @param type The Javadoc Type to be output.
- */
- protected void outputType(int level, String tag, Type type) {
- outputType(level, tag, type, true);
- }
-
- protected void outputType(int level, String tag, Type type, boolean atomic) {
-
- boolean isIncluded = false;
- ClassDoc typeAsClassDoc = type.asClassDoc();
- String packageName = null;
- if (null != typeAsClassDoc) {
- isIncluded = typeAsClassDoc.isIncluded();
- packageName = typeAsClassDoc.containingPackage().name();
- }
- println(level, "<"+tagPrefix+":"+tag + " typename=\""+type.typeName()+"\""+
- " qualifiedtypename=\""+type.qualifiedTypeName()+"\""
- +(type.dimension().length()==0?"":" dimension=\""+type.dimension()+"\"")
- +(isIncluded?" isIncluded=\"true\"" : "")
- +((null != packageName)?" package=\"" + packageName + "\"" : "")
- +(atomic?"/":"")+">");
- }
-
- protected void outputExecutableMemberDocBody(int level, ExecutableMemberDoc memberDoc) {
-
- currentExecMember = memberDoc;
-
- outputMemberDocBody(level, memberDoc);
-
- Parameter[] parameters = memberDoc.parameters();
- for (int i=0, ilim=parameters.length; i<ilim; ++i) {
- Parameter parameter = parameters[i];
- outputType(level, "parameter name=\""+parameter.name()+"\"", parameter.type());
- }
-
- ClassDoc[] exceptions = memberDoc.thrownExceptions();
- for (int i=0, ilim=exceptions.length; i<ilim; ++i) {
- ClassDoc exception = exceptions[i];
- outputType(level, "thrownException", exception);
- }
-
- printAtomTag(level, "signature full=\""+memberDoc.signature()+"\" flat=\""+memberDoc.flatSignature()+"\"");
-
- if (memberDoc.isNative()) {
- printAtomTag(level, "isNative");
- }
-
- if (memberDoc.isSynchronized()) {
- printAtomTag(level, "isSynchronized");
- }
- }
-
- protected void outputMethodDoc(int level, MethodDoc methodDoc) {
- println();
- printOpenTag(level, "methoddoc name=\""+methodDoc.name()+"\"");
- outputExecutableMemberDocBody(level+1, methodDoc);
- outputType(level+1, "returns", methodDoc.returnType());
- printCloseTag(level, "methoddoc");
- }
-
- protected void outputMemberDocBody(int level, MemberDoc memberDoc) {
- currentMember = memberDoc;
- outputProgramElementDocBody(level, memberDoc);
- }
-
- protected void outputFieldDocBody(int level, FieldDoc fieldDoc) {
- outputType(level, "type", fieldDoc.type());
- if (fieldDoc.isTransient()) {
- printAtomTag(level, "isTransient");
- }
- if (fieldDoc.isVolatile()) {
- printAtomTag(level, "isVolatile");
- }
- }
-
- private void outputFieldDoc(int level, FieldDoc fieldDoc) {
- println();
- printOpenTag(level, "fielddoc name=\""+fieldDoc.name()+"\"");
- outputMemberDocBody(level+1, fieldDoc);
- outputFieldDocBody(level+1, fieldDoc);
- printCloseTag(level, "fielddoc");
- }
-
- protected void outputConstructorDoc(int level, ConstructorDoc constructorDoc) {
- println();
- printOpenTag(level, "constructordoc name=\""+constructorDoc.name()+"\"");
- outputExecutableMemberDocBody(level+1, constructorDoc);
- printCloseTag(level, "constructordoc");
- }
-
- protected void outputSuperInterfacesRec(int level, ClassDoc classDoc) {
- if (null!=classDoc) {
- ClassDoc[] interfaces = classDoc.interfaces();
- if (null != interfaces) {
- for (int i=0, ilim=interfaces.length; i<ilim; ++i) {
- outputType(level, "superimplements", interfaces[i]);
- }
- }
- outputSuperInterfacesRec(level, classDoc.superclass());
- }
- }
-
- protected void outputClassDocSummary(ClassDoc classDoc) {
- println();
- printOpenTag(1, "classdoc name=\""+classDoc.name()+"\" qualifiedtypename=\""+classDoc.qualifiedName()+"\" isIncluded=\"true\"");
- if (null!=classDoc.superclass()) {
- outputType(2, "superclass", classDoc.superclass());
- }
-
- ClassDoc[] interfaces = classDoc.interfaces();
- for (int i=0, ilim=interfaces.length; i<ilim; ++i) {
- outputType(2, "implements", interfaces[i]);
- }
- outputSuperInterfacesRec(2, classDoc.superclass());
-
- printAtomTag(2, "containingPackage name=\""+classDoc.containingPackage().name()+"\"");
- if (classDoc.isError()) {
- printAtomTag(2, "isError");
- }
- if (classDoc.isException()) {
- printAtomTag(2, "isException");
- }
- if (classDoc.isInterface()) {
- printAtomTag(2, "isInterface");
- }
- if (classDoc.isOrdinaryClass()) {
- printAtomTag(2, "isOrdinaryClass");
- }
-
- printCloseTag(1, "classdoc");
- }
-
- protected void outputPackageDoc(PackageDoc packageDoc) {
- println();
- printOpenTag(1, "packagedoc name=\""+packageDoc.name()+"\"");
- if (packageDoc.firstSentenceTags().length > 0) {
- printOpenTag(2, "firstSentenceTags", false);
- outputTags(3, packageDoc.firstSentenceTags(), true, CONTEXT_PACKAGE);
- printCloseTag(0, "firstSentenceTags");
- printOpenTag(2, "inlineTags", false);
- outputTags(3, packageDoc.inlineTags(), true, CONTEXT_PACKAGE);
- printCloseTag(0, "inlineTags");
- }
-
- if (packageDoc.tags().length > 0) {
- printOpenTag(2, "tags");
- outputTags(3, packageDoc.tags(), true, CONTEXT_PACKAGE);
- printCloseTag(2, "tags");
- }
-
- if (packageDoc.seeTags().length > 0) {
- printOpenTag(2, "seeTags");
- outputTags(3, packageDoc.seeTags(), true, CONTEXT_PACKAGE);
- printCloseTag(2, "seeTags");
- }
-
- ClassDoc[] allClasses = (ClassDoc[]) packageDoc.allClasses().clone();
- Arrays.sort(allClasses);
-
- if (false) {
- for (int i = 0, ilim = allClasses.length; i < ilim; ++ i) {
- printAtomTag(2, "containsClass qualifiedtypename=\""+allClasses[i].qualifiedTypeName()+"\"");
- }
- }
-
- printCloseTag(1, "packagedoc");
- }
-
- protected void outputClassDoc(ClassDoc classDoc) throws IOException {
-
- currentClass = classDoc;
-
- println();
- printOpenTag(1, "classdoc xmlns=\"http://www.w3.org/TR/REC-html40\" xmlns:"+tagPrefix+"=\"http://www.gnu.org/software/cp-tools/gjdocxml\" name=\""+classDoc.name()+"\" qualifiedtypename=\""+classDoc.qualifiedName()+"\"");
-
- ClassDoc[] interfaces = classDoc.interfaces();
- for (int i=0, ilim=interfaces.length; i<ilim; ++i) {
- outputType(2, "implements", interfaces[i]);
- }
- outputSuperInterfacesRec(2, classDoc.superclass());
-
- outputProgramElementDocBody(2, classDoc);
- if (classDoc.isAbstract())
- printAtomTag(2, "isAbstract");
- if (classDoc.isSerializable())
- printAtomTag(2, "isSerializable");
- if (classDoc.isExternalizable())
- printAtomTag(2, "isExternalizable");
- if (classDoc.definesSerializableFields()) {
- printAtomTag(2, "definesSerializableFields");
- }
-
- ConstructorDoc[] constructors = classDoc.constructors();
- for (int i=0, ilim=constructors.length; i<ilim; ++i) {
- outputConstructorDoc(2, constructors[i]);
- }
-
- MethodDoc[] methods = classDoc.methods();
- for (int i=0, ilim=methods.length; i<ilim; ++i) {
- outputMethodDoc(2, methods[i]);
- }
-
- FieldDoc[] fields = classDoc.fields();
- for (int i=0, ilim=fields.length; i<ilim; ++i) {
- outputFieldDoc(2, fields[i]);
- }
-
- if (classDoc.serializableFields().length > 0) {
- printOpenTag(2, "serializableFields");
-
- FieldDoc[] sfields = classDoc.serializableFields();
- for (int i=0, ilim=sfields.length; i<ilim; ++i) {
- outputFieldDoc(2, sfields[i]);
- }
- printCloseTag(2, "serializableFields");
- }
-
- Java2xhtml java2xhtml = new Java2xhtml();
- Properties properties = new Properties();
- properties.setProperty("isCodeSnippet", "true");
- properties.setProperty("hasLineNumbers", "true");
- java2xhtml.setProperties(properties);
-
- if (null == classDoc.containingClass() && docTransletOptions.linksource) {
- printOpenTag(2, "source");
- StringWriter sourceBuffer = new StringWriter();
- File sourceFile = new File(((GjdocPackageDoc)classDoc.containingPackage()).packageDirectory(),
- classDoc.name() + ".java");
- FileReader sourceReader = new FileReader(sourceFile);
- IOToolkit.copyStream(sourceReader, sourceBuffer);
- print(java2xhtml.makeHTML(sourceBuffer.getBuffer(), sourceFile.getName()));
- printCloseTag(2, "source");
- }
-
- ClassDoc superclassDoc = classDoc.superclass();
- while (superclassDoc != null) {
- outputType(2, "superclass", superclassDoc, false);
-
- // FIXME: remove the following after adjusting the XSLT sheets:
- printAtomTag(3, "containingPackage name=\"" + superclassDoc.containingPackage().name() + "\"");
-
- MethodDoc[] superMethods = superclassDoc.methods();
- if (null != superMethods) {
- for (int i=0, ilim=superMethods.length; i<ilim; ++i) {
- printAtomTag(3, "methoddoc name=\"" + superMethods[i].name() + "\" signature=\"" + superMethods[i].signature() + "\"");
- }
- }
-
- FieldDoc[] superFields = superclassDoc.fields();
- if (null != superFields) {
- for (int i=0, ilim=superFields.length; i<ilim; ++i) {
- printAtomTag(3, "fielddoc name=\"" + superFields[i].name() + "\"");
- }
- }
- printCloseTag(2, "superclass");
-
- superclassDoc = superclassDoc.superclass();
- }
-
- outputUsage(classDoc, 2);
-
- printCloseTag(1, "classdoc");
-
- currentClass = null;
- currentMember = null;
- currentExecMember = null;
- }
-
- protected int outputHeritageOpen(int level, ClassDoc classDoc) {
-
- ClassDoc superClassDoc = classDoc.superclass();
- if (null != superClassDoc) {
- level = outputHeritageOpen(level, superClassDoc);
- ++ level;
- }
- outputType(level, "heritage", classDoc, false);
- return level;
- }
-
- protected void outputHeritageClose(int level, ClassDoc classDoc) {
-
- ClassDoc superClassDoc = classDoc.superclass();
- if (null != superClassDoc) {
- outputHeritageClose(level + 1, superClassDoc);
- }
- printCloseTag(level, "heritage");
- }
-
- protected void outputDocBody(int level, Doc doc) {
-
- int context = CONTEXT_TYPE;
-
- if (doc.isClass()) {
- printAtomTag(level, "isClass");
-
- ClassDoc classDoc = (ClassDoc)doc;
- ClassDoc[] classes = rootDoc.classes();
- for (int i=0, ilim=classes.length; i<ilim; ++i) {
- if (classes[i].superclass() == classDoc) {
- outputType(level, "extended-by", classes[i]);
- }
- }
-
- outputHeritageOpen(level, classDoc);
- outputHeritageClose(level, classDoc);
- }
- if (doc.isConstructor()) {
- printAtomTag(level, "isConstructor");
- context = CONTEXT_CONSTRUCTOR;
- }
- if (doc.isError()) {
- printAtomTag(level, "isError");
- }
- if (doc.isException()) {
- printAtomTag(level, "isException");
- }
- if (doc.isField()) {
- printAtomTag(level, "isField");
- context = CONTEXT_FIELD;
- }
- if (doc.isIncluded()) {
- printAtomTag(level, "isIncluded");
- }
- if (doc.isInterface()) {
- printAtomTag(level, "isInterface");
-
- ClassDoc classDoc = (ClassDoc)doc;
- ClassDoc[] classes = rootDoc.classes();
- for (int i=0, ilim=classes.length; i<ilim; ++i) {
- ClassDoc[] implementedInterfaces = classes[i].interfaces();
- for (int j=0; j<implementedInterfaces.length; ++j) {
- if (implementedInterfaces[j] == classDoc) {
- if (classDoc.isInterface()) {
- outputType(level, "subinterface", classes[i]);
- }
- else {
- outputType(level, "implemented-by", classes[i]);
- }
- break;
- }
- }
- }
- }
- if (doc.isMethod()) {
- printAtomTag(level, "isMethod");
- context = CONTEXT_METHOD;
- }
- if (doc.isOrdinaryClass()) {
- printAtomTag(level, "isOrdinaryClass");
- }
-
- if (doc.inlineTags().length > 0) {
- printOpenTag(level, "inlineTags", false);
- outputTags(level+1, doc.inlineTags(), true, context);
- printCloseTag(0, "inlineTags");
- }
-
- if (doc.firstSentenceTags().length > 0) {
- printOpenTag(level, "firstSentenceTags", false);
- outputTags(level+1, doc.firstSentenceTags(), true, context);
- printCloseTag(0, "firstSentenceTags");
- }
-
- if (doc.tags().length > 0) {
- printOpenTag(level, "tags");
- outputTaglets(level+1, doc.tags(), true, context);
- printCloseTag(level, "tags");
- }
-
- if (doc.seeTags().length > 0) {
- printOpenTag(level, "seeTags");
- outputTags(level+1, doc.seeTags(), true, context);
- printCloseTag(level, "seeTags");
- }
-
- SourcePosition position = doc.position();
- if (null != position) {
- printAtomTag(level, "position file=\"" + position.file().getAbsolutePath() + "\" line=\"" + position.line() + "\" column=\"" + position.column() + "\"");
- }
- }
-
- protected void outputProgramElementDocBody(int level, ProgramElementDoc programElementDoc) {
- outputDocBody(level, programElementDoc);
- printAtomTag(level, "containingPackage name=\""+programElementDoc.containingPackage().name()+"\"");
- if (null!=programElementDoc.containingClass()) {
- outputType(level, "containingClass", programElementDoc.containingClass());
- }
- String access;
- if (programElementDoc.isPublic())
- access="public";
- else if (programElementDoc.isProtected())
- access="protected";
- else if (programElementDoc.isPrivate())
- access="private";
- else if (programElementDoc.isPackagePrivate())
- access="package";
- else
- throw new RuntimeException("Huh? "+programElementDoc+" is neither public, protected, private nor package protected.");
- printAtomTag(level, "access scope=\""+access+"\"");
- if (programElementDoc.isFinal())
- printAtomTag(level, "isFinal");
- if (programElementDoc.isStatic())
- printAtomTag(level, "isStatic");
- }
-
- protected void outputTags(int level, Tag[] tags, boolean descend, int context) {
-
- for (int i=0; i<tags.length; ++i) {
- outputTag(tags[i], level, descend, context, i == tags.length-1);
- }
- }
-
- protected void outputTag(Tag tag, int level, boolean descend, int context, boolean lastTag) {
-
- if (!"Text".equals(tag.name())) {
- printOpenTag(0 /* don't introduce additional whitespace */,
- "tag kind=\""+tag.kind()+"\" name=\""+tag.name()+"\"", false);
- }
- if (tag instanceof ThrowsTag) {
- ThrowsTag throwsTag = (ThrowsTag)tag;
- if (null!=throwsTag.exception()) {
- outputType(level+1, "exception", throwsTag.exception());
- }
- else {
- StringBuffer sb = new StringBuffer("Exception ");
- sb.append(throwsTag.exceptionName());
- sb.append(" not found in ");
- if (currentExecMember instanceof MethodDoc) {
- MethodDoc m = (MethodDoc)currentExecMember;
- sb.append(m.returnType().typeName());
- sb.append(m.returnType().dimension());
- sb.append(' ');
- }
- sb.append(currentClass.qualifiedName());
- sb.append('.');
- sb.append(currentExecMember.name());
- sb.append('(');
- Parameter[] params = currentExecMember.parameters();
- for (int j=0; j < params.length; j++) {
- sb.append(params[j].type().typeName());
- sb.append(params[j].type().dimension());
- sb.append(' ');
- sb.append(params[j].name());
- if (j != params.length-1)
- sb.append(", ");
- }
- sb.append(')');
- printWarning(sb.toString());
-
- printAtomTag(level+1, "exception typename=\""+throwsTag.exceptionName()+"\"");
- }
- }
- else if (tag instanceof ParamTag) {
- ParamTag paramTag = (ParamTag)tag;
- printAtomTag(level+1, "parameter name=\""+paramTag.parameterName()+"\"");
- }
-
- if (null != tag.text()) {
- //printOpenTag(level+1, "text", false);
- if (fixHTML) {
- print(htmlRepairer.getWellformedHTML(tag.text()));
- }
- else {
- print("<![CDATA["+cdata(tag.text())+"]]>");
- }
- //printCloseTag(0 /* don't introduce additional whitespace */, "text");
- }
- else {
- printWarning("Tag got null text: "+tag);
- }
-
- if ((descend && ("@throws".equals(tag.name()) || "@param".equals(tag.name()))) || "@deprecated".equals(tag.name())) {
- if (tag.firstSentenceTags().length>0) {
- printOpenTag(level+1, "firstSentenceTags", false);
- outputTags(level+2, tag.firstSentenceTags(), false, context);
- printCloseTag(0, "firstSentenceTags");
- }
-
- if (tag.inlineTags().length>0) {
- printOpenTag(level+1, "inlineTags", false);
- outputTags(level+2, tag.firstSentenceTags(), false, context);
- printCloseTag(0, "inlineTags");
- }
- }
-
- if (fixHTML && lastTag) {
- String terminateText = htmlRepairer.terminateText();
- if (null != terminateText && terminateText.length() > 0) {
- print(terminateText);
- }
- }
-
- if (!"Text".equals(tag.name())) {
-
- Taglet inlineTaglet = (Taglet)tagletMap.get(tag.name().substring(1));
- if (null != inlineTaglet && inlineTaglet.isInlineTag()) {
- printOpenTag(0, "inlineTagletText", false);
- print(inlineTaglet.toString(tag));
- printCloseTag(0, "inlineTagletText");
- }
-
- printCloseTag(0, "tag", false);
- }
- }
-
- void outputTaglets(int level, Tag[] tags, boolean descend, int context)
- {
- for (Iterator it = tagletMap.keySet().iterator(); it.hasNext(); ) {
- String tagName = (String)it.next();
- Object o = tagletMap.get(tagName);
- Taglet taglet = (Taglet)o;
-
- if (!taglet.isInlineTag()
- && ((context != CONTEXT_CONSTRUCTOR || taglet.inConstructor())
- || (context != CONTEXT_FIELD || taglet.inField())
- || (context != CONTEXT_METHOD || taglet.inMethod())
- || (context != CONTEXT_OVERVIEW || taglet.inOverview())
- || (context != CONTEXT_PACKAGE || taglet.inPackage())
- || (context != CONTEXT_TYPE || taglet.inType()))) {
-
- List tagsOfThisType = new ArrayList();
- for (int i=0, ilim=tags.length; i<ilim; ++i) {
- if (tags[i].name().substring(1).equals(tagName)) {
- tagsOfThisType.add(tags[i]);
- }
- }
-
- if (!tagsOfThisType.isEmpty()) {
- Tag[] tagletTags = (Tag[])tagsOfThisType.toArray(new Tag[tagsOfThisType.size()]);
- if (taglet instanceof StandardTaglet) {
- Iterator tagIterator = tagsOfThisType.iterator();
- while (tagIterator.hasNext()) {
- Tag tag = (Tag)tagIterator.next();
- outputTag(tag, level, descend, context, !tagIterator.hasNext());
- }
- }
- else {
- String tagletString = taglet.toString(tagletTags);
- if (null != tagletString) {
- printOpenTag(0, "tag name=\"" + tagName + "\" taglet-generated=\"true\"");
- if (fixHTML) {
- print(htmlRepairer.getWellformedHTML(tagletString));
- print(htmlRepairer.terminateText());
- }
- else {
- print("<![CDATA["+cdata(tagletString)+"]]>");
- }
- printCloseTag(0, "tag", false);
- }
- }
- }
- }
- }
- }
-
- /**
- * Inofficial entry point. We got an instance here.
- */
- protected boolean instanceStart(RootDoc _rootDoc) {
-
- this.rootDoc = _rootDoc;
- _rootDoc = null;
-
- boolean xmlOnly = true;
-
- // Set the default Taglet order
-
- registerTaglet(new VersionTaglet());
- registerTaglet(new AuthorTaglet());
- //registerTaglet(new SinceTaglet());
- registerTaglet(new StandardTaglet("deprecated"));
- registerTaglet(new StandardTaglet("see"));
- registerTaglet(new StandardTaglet("param"));
-
- // Set the built-in Taglet filter
-
- AuthorTaglet.setTagletEnabled(false);
- VersionTaglet.setTagletEnabled(false);
- SinceTaglet.setTagletEnabled(true);
- DeprecatedTaglet.setTagletEnabled(true);
-
- try {
- {
-
- // Process command line options passed through to this doclet
-
- TargetContext targetContext = null;
-
- TargetContext htmlTargetContext
- = new TargetContext(DocTranslet.fromClasspath("/doctranslets/html/gjdoc.xsl"),
- targetDirectory);
-
- for (int i=0, ilim=rootDoc.options().length; i<ilim; ++i) {
-
- String[] option = rootDoc.options()[i];
- String optionTag = option[0];
-
- if ("-d".equals(optionTag)) {
- if (null == targetDirectory) {
- targetDirectory = new File(option[1]);
- }
- if (null != targetContext) {
- targetContext.setTargetDirectory(targetDirectory);
- }
- }
-
- else if ("-nofixhtml".equals(optionTag)) {
- fixHTML = false;
- printError("-nofixhtml currently not supported.");
- return false;
- }
- else if ("-compress".equals(optionTag)) {
- compress = true;
- }
- else if ("-nohtmlwarn".equals(optionTag)) {
- noHTMLWarn = true;
- }
- else if ("-noemailwarn".equals(optionTag)) {
- noEmailWarn = true;
- }
- else if ("-indentstep".equals(optionTag)) {
- indentStep = Integer.parseInt(option[1]);
- }
- else if ("-doctranslet".equals(optionTag)) {
- targets.add(targetContext = new TargetContext(DocTranslet.fromJarFile(new File(option[1])),
- targetDirectory));
- }
- else if ("-genhtml".equals(optionTag)) {
- htmlTargetContext.setTargetDirectory(targetDirectory);
- targets.add(targetContext = htmlTargetContext);
- xmlOnly = false;
- }
- else if ("-geninfo".equals(optionTag)) {
- targetContext
- = new TargetContext(DocTranslet.fromClasspath("/doctranslets/info/gengj.xsl"),
- targetDirectory);
- targets.add(targetContext);
- if (!fixHTML) {
- printNotice("NOTE: -geninfo implies -fixhtml.");
- fixHTML = true;
- }
- xmlOnly = false;
- }
- else if ("-gendocbook".equals(optionTag)) {
- targetContext = new TargetContext(DocTranslet.fromClasspath("/doctranslets/docbook/gengj.xsl"),
- targetDirectory);
- targets.add(targetContext);
- if (!fixHTML) {
- printNotice("NOTE: -gendocbook implies -fixhtml.");
- fixHTML = true;
- }
- }
- else if ("-genpdf".equals(optionTag)) {
- targetContext
- = new TargetContext(DocTranslet.fromClasspath("/doctranslets/docbook/gengj.xsl"),
- targetDirectory);
- /** "gnu.classpath.tools.doclets.xmldoclet.DocBookPostprocessor") **/
- targets.add(targetContext);
- if (!fixHTML) {
- printNotice("NOTE: -genpdf implies -fixhtml.");
- fixHTML = true;
- }
- }
- else if ("-xmlonly".equals(optionTag)) {
- xmlOnly = true;
- }
- else if ("-bottomnote".equals(optionTag)) {
-
- FileReader reader = new FileReader(option[1]);
- StringWriter writer = new StringWriter();
- char[] buf = new char[256];
- int nread;
- while ((nread = reader.read(buf)) >= 0) {
- writer.write(buf, 0, nread);
- }
- writer.flush();
- bottomNote = writer.toString();
- writer.close();
- reader.close();
- }
- else if ("-title".equals(optionTag)) {
-
- title = option[1];
- }
- else if ("-workpath".equals(optionTag)) {
-
- workingPath = option[1];
- }
- else if ("-tagletpath".equals(optionTag)) {
-
- if (null == tagletPath) {
- tagletPath = option[1];
- }
- else {
- tagletPath = tagletPath + File.pathSeparator + option[1];
- }
- }
- else if ("-taglet".equals(optionTag)) {
-
- boolean tagletLoaded = false;
-
- String useTagletPath = this.tagletPath;
- if (null == useTagletPath) {
- useTagletPath = System.getProperty("java.class.path");
- }
-
- try {
- Class tagletClass;
- try {
- tagletClass
- = new FileSystemClassLoader(useTagletPath).loadClass(option[1]);
- }
- catch (ClassNotFoundException e) {
- // If not found on specified tagletpath, try default classloader
- tagletClass
- = Class.forName(option[1]);
- }
- Method registerTagletMethod
- = tagletClass.getDeclaredMethod("register", new Class[] { java.util.Map.class });
-
- if (!registerTagletMethod.getReturnType().equals(Void.TYPE)) {
- printError("Taglet class '" + option[1] + "' found, but register method doesn't return void.");
- }
- else if (registerTagletMethod.getExceptionTypes().length > 0) {
- printError("Taglet class '" + option[1] + "' found, but register method contains throws clause.");
- }
- else if ((registerTagletMethod.getModifiers() & (Modifier.STATIC | Modifier.PUBLIC | Modifier.ABSTRACT)) != (Modifier.STATIC | Modifier.PUBLIC)) {
- printError("Taglet class '" + option[1] + "' found, but register method isn't public static, or is abstract..");
- }
- else {
- Map tempMap = new HashMap();
- registerTagletMethod.invoke(null, new Object[] { tempMap });
- tagletLoaded = true;
- String name = (String)tempMap.keySet().iterator().next();
- Taglet taglet = (Taglet)tempMap.get(name);
- tagletMap.put(name, taglet);
- mentionedTags.add(taglet);
- }
- }
- catch (NoSuchMethodException e) {
- printError("Taglet class '" + option[1] + "' found, but doesn't contain the register method.");
- }
- catch (SecurityException e) {
- printError("Taglet class '" + option[1] + "' cannot be loaded: " + e.getMessage());
- }
- catch (InvocationTargetException e) {
- printError("Taglet class '" + option[1] + "' found, but register method throws exception: " + e.toString());
- }
- catch (IllegalAccessException e) {
- printError("Taglet class '" + option[1] + "' found, but there was a problem when accessing the register method: " + e.toString());
- }
- catch (IllegalArgumentException e) {
- printError("Taglet class '" + option[1] + "' found, but there was a problem when accessing the register method: " + e.toString());
- }
- catch (ClassNotFoundException e) {
- printError("Taglet class '" + option[1] + "' cannot be found.");
- }
- if (!tagletLoaded) {
- return false;
- }
- }
- else if ("-author".equals(optionTag)) {
- AuthorTaglet.setTagletEnabled(true);
- }
- else if ("-version".equals(optionTag)) {
- VersionTaglet.setTagletEnabled(true);
- }
- else if ("-nosince".equals(optionTag)) {
- SinceTaglet.setTagletEnabled(false);
- }
- else if ("-nodeprecated".equals(optionTag)) {
- DeprecatedTaglet.setTagletEnabled(false);
- }
- else if ("-authormail".equals(optionTag)) {
-
- if ("no-replace".equalsIgnoreCase(option[1])) {
- AuthorTaglet.setEmailReplacementType(AuthorTaglet.EmailReplacement.NO_REPLACEMENT);
- }
- else if ("mailto-name".equalsIgnoreCase(option[1])) {
- AuthorTaglet.setEmailReplacementType(AuthorTaglet.EmailReplacement.MAILTO_NAME);
- }
- else if ("name-mailto-address".equalsIgnoreCase(option[1])) {
- AuthorTaglet.setEmailReplacementType(AuthorTaglet.EmailReplacement.NAME_MAILTO_ADDRESS);
- }
- else if ("name-mangled-address".equalsIgnoreCase(option[1])) {
- AuthorTaglet.setEmailReplacementType(AuthorTaglet.EmailReplacement.NAME_MANGLED_ADDRESS);
- }
- else {
- printError("Invalid value for option '-authortag-email'. Allowed values are:"
- + " no-replace, mailto-name, name-mailto-address, name-mangled-address.");
- return false;
- }
- }
- else if ("-mailmangledot".equals(optionTag)) {
- AuthorTaglet.setDotReplacement(option[1]);
- }
- else if ("-mailmangleat".equals(optionTag)) {
- AuthorTaglet.setAtReplacement(option[1]);
- }
- else if ("-docfilessubdirs".equals(optionTag)) {
- docFilesSubdirsEnabled = true;
- }
- else if ("-excludedocfilessubdir".equals(optionTag)) {
- StringTokenizer st = new StringTokenizer(option[1]);
- while (st.hasMoreTokens()) {
- excludeDocFilesSubDirs.add(st.nextToken());
- }
- }
- else if ("-nonavbar".equals(optionTag)) {
- docTransletOptions.nonavbar = true;
- }
- else if ("-noindex".equals(optionTag)) {
- docTransletOptions.noindex = true;
- }
- else if ("-notree".equals(optionTag)) {
- docTransletOptions.notree = true;
- }
- else if ("-nocomment".equals(optionTag)) {
- docTransletOptions.nocomment = true;
- }
- else if ("-nohelp".equals(optionTag)) {
- docTransletOptions.nohelp = true;
- }
- else if ("-splitindex".equals(optionTag)) {
- docTransletOptions.splitindex = true;
- }
- else if ("-linksource".equals(optionTag)) {
- docTransletOptions.linksource = true;
- }
- else if ("-windowtitle".equals(optionTag)) {
- docTransletOptions.windowtitle = option[1];
- }
- else if ("-helpfile".equals(optionTag)) {
- docTransletOptions.helpfile = new File(option[1]).toURL().toString();
- }
- else if ("-stylesheetfile".equals(optionTag)) {
- docTransletOptions.stylesheetfile = new File(option[1]).toURL().toString();
- }
- else if ("-header".equals(optionTag)) {
- docTransletOptions.header = option[1];
- }
- else if ("-footer".equals(optionTag)) {
- docTransletOptions.footer = option[1];
- }
- else if ("-bottom".equals(optionTag)) {
- docTransletOptions.bottom = option[1];
- }
- else if ("-doctitle".equals(optionTag)) {
- docTransletOptions.doctitle = option[1];
- }
- else if ("-nodeprecatedlist".equals(optionTag)) {
- docTransletOptions.nodeprecatedlist = true;
- }
- else if ("-uses".equals(optionTag)) {
- docTransletOptions.uses = true;
- }
- else if ("-group".equals(optionTag)) {
- if (!processGroupOption(option[1], option[2])) {
- printError("Invalid package wildcard list in -group option \"" + option[1] + "\" " + option[2]);
- return false;
- }
- }
- else if ("-tag".equals(optionTag)) {
- String tagSpec = option[1];
- boolean validTagSpec = false;
- int ndx1 = tagSpec.indexOf(':');
- if (ndx1 < 0) {
- Taglet taglet = (Taglet)tagletMap.get(tagSpec);
- if (null == taglet) {
- printError("There is no standard tag '" + tagSpec + "'.");
- }
- else {
- if (mentionedTags.contains(taglet)) {
- printError("Tag '" + tagSpec + "' has been added or moved before.");
- }
- else {
- mentionedTags.add(taglet);
-
- // re-append taglet
- tagletMap.remove(tagSpec);
- tagletMap.put(tagSpec, taglet);
- }
- }
- }
- else {
- int ndx2 = tagSpec.indexOf(':', ndx1 + 1);
- if (ndx2 > ndx1 && ndx2 < tagSpec.length() - 1) {
- String tagName = tagSpec.substring(0, ndx1);
- String tagHead = null;
- if (tagSpec.charAt(ndx2 + 1) == '\"') {
- if (tagSpec.charAt(tagSpec.length() - 1) == '\"') {
- tagHead = tagSpec.substring(ndx2 + 2, tagSpec.length() - 1);
- validTagSpec = true;
- }
- }
- else {
- tagHead = tagSpec.substring(ndx2 + 1);
- validTagSpec = true;
- }
-
- boolean tagScopeOverview = false;
- boolean tagScopePackages = false;
- boolean tagScopeTypes = false;
- boolean tagScopeConstructors = false;
- boolean tagScopeMethods = false;
- boolean tagScopeFields = false;
- boolean tagDisabled = false;
-
- tag_option_loop:
- for (int n=ndx1+1; n<ndx2; ++n) {
- switch (tagSpec.charAt(n)) {
- case 'X':
- tagDisabled = true;
- break;
- case 'a':
- tagScopeOverview = true;
- tagScopePackages = true;
- tagScopeTypes = true;
- tagScopeConstructors = true;
- tagScopeMethods = true;
- tagScopeFields = true;
- break;
- case 'o':
- tagScopeOverview = true;
- break;
- case 'p':
- tagScopePackages = true;
- break;
- case 't':
- tagScopeTypes = true;
- break;
- case 'c':
- tagScopeConstructors = true;
- break;
- case 'm':
- tagScopeMethods = true;
- break;
- case 'f':
- tagScopeFields = true;
- break;
- default:
- validTagSpec = false;
- break tag_option_loop;
- }
- }
-
- if (validTagSpec) {
- GenericTaglet taglet
- = new GenericTaglet(tagName,
- tagHead,
- tagScopeOverview,
- tagScopePackages,
- tagScopeTypes,
- tagScopeConstructors,
- tagScopeMethods,
- tagScopeFields);
- taglet.setTagletEnabled(!tagDisabled);
- taglet.register(tagletMap);
- mentionedTags.add(taglet);
- }
- }
- }
- if (!validTagSpec) {
- printError("Value for option -tag must be in format \"<tagname>:Xaoptcmf:<taghead>\".");
- }
- }
- }
-
- // Use current directory if target directory hasn't been set.
- if (null == targetDirectory) {
- targetDirectory = new File(System.getProperty("user.dir"));
- }
- if (null != targetContext) {
- targetContext.setTargetDirectory(targetDirectory);
- }
-
- // It is illegal to specify targets AND -xmlonly.
-
- if (xmlOnly && targets.size() > 0) {
-
- printError("You can only specify one of -xmlonly and a target format.");
- return false;
- }
-
- // If no target was specified and XML only was not
- // requested, use HTML as default target.
-
- if (!xmlOnly && targets.size() == 0) {
- targets.add(targetContext = htmlTargetContext);
- }
-
- // Set the same target directory for all output.
-
- // FIXME: Allow separate target directories for different
- // output formats.
-
- for (Iterator it = targets.iterator(); it.hasNext(); ) {
- TargetContext t = (TargetContext)it.next();
- t.setTargetDirectory(targetDirectory);
- }
-
- // Create temporary directory if necessary
-
- if (xmlOnly) {
-
- xmlTargetDirectory = targetDirectory;
- }
- else {
-
- File workingTopDirectory = new File(workingPath);
-
- workingDirectory = new File(workingTopDirectory, "gjdoc.tmp."+System.currentTimeMillis());
-
- if (!workingDirectory.mkdir()) {
- printError("Cannot create temporary directory at "+System.getProperty("java.io.tmpdir"));
- return false;
- }
-
- File xmlTempDirectory = new File(workingDirectory, "xmloutput");
-
- if (!xmlTempDirectory.mkdir()) {
- printError("Cannot create temporary directory for XML output at "+System.getProperty("java.io.tmpdir"));
- return false;
- }
-
- xmlTargetDirectory = xmlTempDirectory;
- }
-
- // Create target directory if necessary
-
- if (!targetDirectory.exists()) {
- printNotice("Creating destination directory: \""
- + targetDirectory + "\"");
- if (!targetDirectory.mkdirs()) {
- printError("Failed to create destination directory \""
- + targetDirectory + "\"");
- return false;
- }
- }
-
- // Check for deprecation
-
- boolean hasDeprecatedClasses = false;
- boolean hasDeprecatedInterfaces = false;
- boolean hasDeprecatedExceptions = false;
- boolean hasDeprecatedErrors = false;
- boolean hasDeprecatedMethods = false;
- boolean hasDeprecatedFields = false;
-
- {
- ClassDoc[] classes = rootDoc.classes();
- for (int i = 0, ilim = classes.length; i < ilim; ++ i) {
- ClassDoc c = classes[i];
- Tag[] deprecatedTags = c.tags("deprecated");
- if (null != deprecatedTags && 0 != deprecatedTags.length) {
- if (c.isInterface()) {
- hasDeprecatedInterfaces = true;
- }
- else if (c.isException()) {
- hasDeprecatedExceptions = true;
- }
- else if (c.isError()) {
- hasDeprecatedErrors = true;
- }
- else /*if (c.isOrdinaryClass())*/ {
- hasDeprecatedClasses = true;
- }
- }
-
- MethodDoc[] methods = c.methods();
- for (int j = 0, jlim = methods.length; j < jlim; ++ j) {
- MethodDoc m = methods[j];
- deprecatedTags = m.tags("deprecated");
- if (null != deprecatedTags && 0 != deprecatedTags.length) {
- hasDeprecatedMethods = true;
- }
- }
-
- FieldDoc[] fields = c.fields();
- for (int j = 0, jlim = fields.length; j < jlim; ++ j) {
- FieldDoc f = fields[j];
- deprecatedTags = f.tags("deprecated");
- if (null != deprecatedTags && 0 != deprecatedTags.length) {
- hasDeprecatedFields = true;
- }
- }
- }
- }
-
- htmlRepairer = new HtmlRepairer(rootDoc, noHTMLWarn, noEmailWarn,
- currentClass, currentMember,
- false);
-
- collectUsage();
-
- // Begin XML generation
-
- printNotice("Writing XML Index file...");
-
- // Assign output stream
-
- setTargetFile("index.xml");
-
- // Output XML document header
-
- println(0, "<?xml version=\"1.0\"?>");
- println("<!DOCTYPE gjdoc SYSTEM \"dtd/gjdoc.dtd\">");
- println();
- printOpenTag(0, "rootdoc xmlns=\"http://www.w3.org/TR/REC-html40\" xmlns:gjdoc=\"http://www.gnu.org/software/cp-tools/gjdocxml\"");
-
- println();
- println(1, "<!-- Tags from overview page, if available -->");
-
- if (rootDoc.firstSentenceTags().length > 0) {
- printOpenTag(2, "firstSentenceTags", false);
- outputTags(3, rootDoc.firstSentenceTags(), true, CONTEXT_PACKAGE);
- printCloseTag(0, "firstSentenceTags");
- }
-
- if (rootDoc.inlineTags().length > 0) {
- printOpenTag(2, "inlineTags");
- outputTags(3, rootDoc.inlineTags(), true, CONTEXT_PACKAGE);
- printCloseTag(2, "inlineTags");
- }
-
- if (null != bottomNote) {
- printOpenTag(1, "bottomnote");
- print(bottomNote);
- printCloseTag(1, "bottomnote");
- }
-
- if (null != title) {
- printOpenTag(1, "title");
- println(2, title);
- printCloseTag(1, "title");
- }
-
- printOpenTag(1, "created");
- println(2, DateFormat.getDateInstance(DateFormat.LONG, Locale.US).format(new java.util.Date()));
- printCloseTag(1, "created");
-
- if (hasDeprecatedClasses) printAtomTag(1, "hasDeprecatedClasses");
- if (hasDeprecatedInterfaces) printAtomTag(1, "hasDeprecatedInterfaces");
- if (hasDeprecatedExceptions) printAtomTag(1, "hasDeprecatedExceptions");
- if (hasDeprecatedErrors) printAtomTag(1, "hasDeprecatedErrors");
- if (hasDeprecatedMethods) printAtomTag(1, "hasDeprecatedMethods");
- if (hasDeprecatedFields) printAtomTag(1, "hasDeprecatedFields");
-
- // Output summary of all classes specified on command line
-
- println();
- println(1, "<!-- Classes specified by user on command line -->");
- ClassDoc[] specifiedClasses = rootDoc.specifiedClasses();
- for (int i=0, ilim=specifiedClasses.length; i<ilim; ++i) {
- ClassDoc sc = specifiedClasses[i];
- printAtomTag(1, "specifiedclass fqname=\""+sc.qualifiedName()+"\" name=\""+sc.name()+"\"");
- }
- specifiedClasses = null;
-
- // Output summary of all packages specified on command line
-
- println();
- println(1, "<!-- Packages specified by user on command line -->");
- PackageDoc[] specifiedPackages = rootDoc.specifiedPackages();
- for (int i=0, ilim=specifiedPackages.length; i<ilim; ++i) {
- PackageDoc sp = specifiedPackages[i];
- printAtomTag(1, "specifiedpackage name=\""+sp.name()+"\"");
- }
- specifiedPackages = null;
-
- // Output package group information specified on the
- // command line
-
- println();
- println(1, "<!-- Package groups specified by user on command line -->");
- {
- Iterator packageGroupIt = packageGroups.iterator();
- while (packageGroupIt.hasNext()) {
- PackageGroup packageGroup = (PackageGroup)packageGroupIt.next();
- SortedSet groupedPackages = packageGroup.getPackages();
- if (groupedPackages.isEmpty()) {
- printWarning("Package group named '"
- + packageGroup.getName() + "' didn't match any packages.");
- }
- else {
- printOpenTag(1, "packagegroup name=\"" + packageGroup.getName() + "\"");
- Iterator groupedPackageIt = groupedPackages.iterator();
- while (groupedPackageIt.hasNext()) {
- PackageDoc groupedPackageDoc = (PackageDoc)groupedPackageIt.next();
- printAtomTag(2, "package name=\"" + groupedPackageDoc.name() + "\"");
- }
- printCloseTag(1, "packagegroup");
- }
- }
- packageGroups = null;
- }
-
- // Output information on all packages for which documentation
- // has been made available via the Doclet API
-
- println();
- println(1, "<!-- Documentation for all packages -->");
- PackageDoc[] packages = rootDoc.specifiedPackages();
- for (int i=0, ilim=packages.length; i<ilim; ++i) {
- PackageDoc c = packages[i];
- outputPackageDoc(c);
- }
- packages = null;
-
- // Output brief summary on all classes for which documentation
- // has been made available via the Doclet API.
- //
- // While this is redundant, it can speed up XSLT
- // processing by orders of magnitude
-
- println();
- println(1, "<!-- Brief summary for all classes -->");
- ClassDoc[] sumclasses = rootDoc.classes();
- for (int i=0, ilim=sumclasses.length; i<ilim; ++i) {
- ClassDoc c = sumclasses[i];
- outputClassDocSummary(c);
- }
- sumclasses = null;
-
- // Output closing tag, finish output stream
-
- println();
- printCloseTag(0, "rootdoc");
-
- closeTargetFile();
-
- createIndexByName();
-
-
-
- // Output information on all classes for which documentation
- // has been made available via the Doclet API
-
- println();
- println(1, "<!-- Documentation for all classes -->");
- ClassDoc[] classes = rootDoc.classes();
- String prevPackageName = null;
- for (int i = 0, ilim = classes.length; i < ilim; ++ i) {
- ClassDoc c = classes[i];
-
- if (isVerbose()) {
- printNotice("Writing XML information for "+c.qualifiedName()+"...");
- }
- else {
- String packageName = c.containingPackage().name();
- if (null == prevPackageName || !packageName.equals(prevPackageName)) {
- printNotice("Writing XML information for "+packageName+"...");
- prevPackageName = packageName;
- }
- }
-
- setTargetFile(c.qualifiedName().replace('/','.')+".xml");
-
- println("<?xml version=\"1.0\"?>");
- println("<!DOCTYPE gjdoc SYSTEM \"dtd/gjdoc.dtd\">");
-
- outputClassDoc(c);
-
- closeTargetFile();
- }
- classes = null;
- }
-
- // Copy DTD files to temporary directory
-
- // FIXME: try to solve this via jar: URLs. but this will
- // probably break libxmlj compatibility (?)
-
- String[] resources = new String[] {
- "gjdoc.dtd",
- "gjdoc-alphaindex.dtd",
- "dbcentx.mod",
- "ent/iso-amsa.ent",
- "ent/iso-amsb.ent",
- "ent/iso-amsc.ent",
- "ent/iso-amsn.ent",
- "ent/iso-amso.ent",
- "ent/iso-amsr.ent",
- "ent/iso-box.ent",
- "ent/iso-cyr1.ent",
- "ent/iso-cyr2.ent",
- "ent/iso-dia.ent",
- "ent/iso-grk1.ent",
- "ent/iso-grk2.ent",
- "ent/iso-grk3.ent",
- "ent/iso-grk4.ent",
- "ent/iso-lat1.ent",
- "ent/iso-lat2.ent",
- "ent/iso-num.ent",
- "ent/iso-pub.ent",
- "ent/iso-tech.ent",
- };
-
- File tempDtdDirectory = new File(xmlTargetDirectory, "dtd");
- File tempDtdEntDirectory = new File(tempDtdDirectory, "ent");
-
- if ((tempDtdDirectory.exists() || tempDtdDirectory.mkdir())
- && (tempDtdEntDirectory.exists() || tempDtdEntDirectory.mkdir())) {
- for (int i = 0; i < resources.length; ++ i) {
- copyResourceToFile("/dtd/" + resources[i],
- new File(tempDtdDirectory, resources[i]));
- }
- }
- else {
- printError("Cannot create temporary directories for DTD data at " + tempDtdDirectory);
- return false;
- }
-
- // Copy package data-dir directory
-
- {
- PackageDoc[] packages = rootDoc.specifiedPackages();
- for (int i=0, ilim=packages.length; i<ilim; ++i) {
- PackageDoc c = packages[i];
- if (c instanceof GjdocPackageDoc) {
- copyPackageDataDir((GjdocPackageDoc)c);
- }
- }
- }
-
- // All information has been output. Apply stylesheet if given.
-
- gnu.classpath.tools.gjdoc.Main.releaseRootDoc();
-
- this.currentClass = null;
- this.currentMember = null;
- this.currentExecMember = null;
-
- System.gc();
-
- // From this point we are only operating on files, so we don't
- // need this anymore and can free up some memory
-
- for (Iterator it = targets.iterator(); it.hasNext(); ) {
-
- TargetContext target = (TargetContext)it.next();
-
- // We have XSLT postprocessing, run DocTranslet.
-
- //DocTranslet docTranslet = DocTranslet.fromClasspath("/doctranslets/html/gjdoc.xsl");
-
- //docTranslet.setOptions(docTransletOptions);
-
- target.getDocTranslet().setOptions(docTransletOptions);
-
- target.getDocTranslet().apply(xmlTargetDirectory,
- target.getTargetDirectory(),
- rootDoc);
- }
-
- // Done
-
- targets = null;
-
- System.gc();
- Runtime.getRuntime().runFinalization();
-
- return true;
- }
- catch (Exception e) {
-
- // Something went wrong. Report to stderr and pass error to
- // Javadoc Reporter
-
- e.printStackTrace();
- printError(e.toString());
-
- Throwable rootCause = e.getCause();
- if (null != rootCause) {
- while (null != rootCause.getCause()) {
- rootCause = rootCause.getCause();
- }
- System.err.println("Root cause:");
- rootCause.printStackTrace();
- }
-
- return false;
- }
- finally {
-
- // In any case, delete the working directory if we created one
-
- if (null != workingDirectory) {
-
- if (!deleteRecursive(workingDirectory)) {
- printWarning("Could not delete temporary directory at "+workingDirectory);
- }
- }
-
- printNotice("Done.");
- }
- }
-
- /**
- * Recursively delete the specified directory and its contents,
- * like <code>rm -Rf directory</code>
- *
- * @return <code>true</code> on success
- */
- private static boolean deleteRecursive(File directory) {
-
- boolean success = true;
-
- File[] files = directory.listFiles();
-
- for (int i=0, ilim=files.length; i<ilim; ++i) {
-
- File file = files[i];
-
- if (file.isDirectory()) {
-
- success = deleteRecursive(file) && success;
- }
- else {
-
- success = file.delete() && success;
- }
- }
-
- return directory.delete() && success;
- }
-
- /**
- * Prints a string to stdout and appends a newline. Convenience
- * method.
- */
- protected void println(String str) {
- out.println(str);
- }
-
- /**
- * Prints a string to stdout without appending a newline.
- * Convenience method.
- */
- protected void print(String str) {
- out.print(str);
- }
-
- /**
- * In standard mode, prints an empty line to stdout.
- * In thight mode, nothing happens.
- * Convenience method.
- */
- protected void println() {
- if (!compress) {
- out.println();
- }
- }
-
- /**
- * In standard mode, prints the given text indented to stdout and appends newline.
- * In tight mode, doesn't print indentation or newlines.
- */
- protected void print(int indentLevel, String msg) {
- if (compress) {
- out.print(msg);
- }
- else {
- StringBuffer indentation = new StringBuffer();
- for (int i=0; i<indentLevel*indentStep; ++i) {
- indentation.append(' ');
- }
- out.print(indentation+msg);
- }
- }
-
- /**
- * In tight mode, prints a message at a given indentation level.
- * In standard mode, appends a newline in addition.
- */
- protected void println(int indentLevel, String msg) {
- print(indentLevel, msg);
- if (!compress) out.println();
- }
-
- /**
- * Prints an atom tag at the given indentation level.
- */
- protected void printAtomTag(int level, String tag) {
- println(level, "<"+tagPrefix+":"+replaceCharsInTag(tag)+"/>");
- }
-
- /**
- * Prints an open tag at the given indentation level.
- */
- protected void printOpenTag(int level, String tag) {
- printOpenTag(level, replaceCharsInTag(tag), true);
- }
-
- /**
- * Prints an open tag at the given indentation level and
- * conditionally appends a newline (if not in tight mode).
- */
- protected void printOpenTag(int level, String tag, boolean appendNewline) {
- if (appendNewline && !compress) {
- println(level, "<"+tagPrefix+":"+replaceCharsInTag(tag)+">");
- }
- else {
- print(level, "<"+tagPrefix+":"+replaceCharsInTag(tag)+">");
- }
- }
-
- /**
- * Prints a close tag at the given indentation level.
- */
- protected void printCloseTag(int level, String tag) {
- printCloseTag(level, tag, true);
- }
-
- /**
- * Prints a close tag at the given indentation level and
- * conditionally appends a newline (if not in tight mode).
- */
- protected void printCloseTag(int level, String tag, boolean appendNewline) {
- if (appendNewline && !compress) {
- println(level, "</"+tagPrefix+":"+replaceCharsInTag(tag)+">");
- }
- else {
- print(level, "</"+tagPrefix+":"+replaceCharsInTag(tag)+">");
- }
- }
-
- public static int optionLength(String option) {
- if ("-d".equals(option)) return 2;
- else if ("-fixhtml".equals(option)) return 1;
- else if ("-compress".equals(option)) return 1;
- else if ("-nohtmlwarn".equals(option)) return 1;
- else if ("-noemailwarn".equals(option)) return 1;
- else if ("-indentstep".equals(option)) return 2;
- else if ("-xslsheet".equals(option)) return 2;
- else if ("-xsltdriver".equals(option)) return 2;
- else if ("-postprocess".equals(option)) return 2;
- else if ("-genhtml".equals(option)) return 1;
- else if ("-geninfo".equals(option)) return 1;
- else if ("-gendocbook".equals(option)) return 1;
- else if ("-xmlonly".equals(option)) return 1;
- else if ("-bottomnote".equals(option)) return 2;
- else if ("-workpath".equals(option)) return 2;
- else if ("-title".equals(option)) return 2;
- else if ("-tagletpath".equals(option)) return 2;
- else if ("-taglet".equals(option)) return 2;
- else if ("-authormail".equals(option)) return 2;
- else if ("-mailmangledot".equals(option)) return 2;
- else if ("-mailmangleat".equals(option)) return 2;
- else if ("-noindex".equals(option)) return 1;
- else if ("-nocomment".equals(option)) return 1;
- else if ("-notree".equals(option)) return 1;
- else if ("-nohelp".equals(option)) return 1;
- else if ("-nonavbar".equals(option)) return 1;
- else if ("-splitindex".equals(option)) return 1;
- else if ("-author".equals(option)) return 1;
- else if ("-version".equals(option)) return 1;
- else if ("-nosince".equals(option)) return 1;
- else if ("-nodeprecated".equals(option)) return 1;
- else if ("-linksource".equals(option)) return 1;
- else if ("-windowtitle".equals(option)) return 2;
- else if ("-helpfile".equals(option)) return 2;
- else if ("-stylesheetfile".equals(option)) return 2;
- else if ("-tag".equals(option)) return 2;
- else if ("-header".equals(option)) return 2;
- else if ("-footer".equals(option)) return 2;
- else if ("-bottom".equals(option)) return 2;
- else if ("-doctitle".equals(option)) return 2;
- else if ("-nodeprecatedlist".equals(option)) return 1;
- else if ("-uses".equals(option)) return 1;
- else if ("-group".equals(option)) return 3;
-
- else return -1;
- }
-
- public static boolean validOptions(String[][] options) {
- return true;
- }
-
-
- /**
- * Workaround for non well-formed comments: fix tag contents
- * by replacing <code>&lt;</code> with <code>&amp;lt;</code>,
- * <code>&gt;</code> with <code>&amp;gt;</code> and
- * <code>&amp;</code> with <code>&amp;amp;</code>.
- *
- * @param tagContent String to process
- *
- * @return given String with all special characters replaced by
- * HTML entities.
- */
- private static String replaceCharsInTag(String tagContent) {
- return
- replaceString(
- replaceString(
- replaceString(
- tagContent,
- "<", "&lt;"
- ),
- ">", "&gt;"
- ),
- "&", "&amp;"
- );
- }
-
- /**
- * Replaces all occurences of string <code>needle</code> within string
- * <code>haystack</code> by string <code>replacement</code>.
- *
- * @param haystack The string to search and replace in.
- * @param needle The string which is searched for.
- * @param replacement The string by which every occurence of <code>needle</code> is replaced.
- */
- private static String replaceString(String haystack, String needle, String replacement) {
- int ndx = haystack.indexOf(needle);
- if (ndx<0)
- return haystack;
- else
- return haystack.substring(0, ndx) + replacement
- + replaceString(haystack.substring(ndx+needle.length()), needle, replacement);
- }
-
- protected void setTargetFile(String filename) throws IOException {
-
- OutputStream fileOut = new FileOutputStream(new File(xmlTargetDirectory, filename));
- out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(fileOut, "UTF8")));;
- }
-
- protected void closeTargetFile() {
-
- out.flush();
- out.close();
- }
-
- private String cdata(String str) {
-
- if (null==str) {
- return str;
- } // end of if ((null==str)
-
- StringBuffer rc = new StringBuffer();
- for (int i=0; i<str.length(); ++i) {
- char c = str.charAt(i);
- if (c==0x09 || c==0x0a || c==0x0d || (c>=0x20 && c<=0xd7ff) || (c>=0xe000 && c<=0xfffd) || (c>=0x10000 && c<=0x10ffff)) {
- rc.append(c);
- }
- else {
- printWarning("Invalid Unicode character 0x"+Integer.toString(c, 16)+" in javadoc markup has been stripped.");
- } // end of else
-
- }
- return rc.toString();
- }
-
- static void copyResourceToFile(String resourceName, File target) throws IOException {
-
- InputStream in = Driver.class.getResourceAsStream(resourceName);
-
- if (null != in) {
-
- FileOutputStream out = new FileOutputStream(target);
- int size;
- byte[] buffer = new byte[512];
- while ((size = in.read(buffer)) >= 0) {
- out.write(buffer, 0, size);
- }
- out.close();
- }
- else {
-
- throw new IOException("Can't find resource named "+resourceName);
- }
- }
-
- private void printError(String error) {
- if (null != rootDoc) {
- rootDoc.printError(error);
- }
- else {
- System.err.println("ERROR: "+error);
- }
- }
-
- private void printWarning(String warning) {
- if (null != rootDoc) {
- rootDoc.printWarning(warning);
- }
- else {
- System.err.println("WARNING: "+warning);
- }
- }
-
- private void printNotice(String notice) {
- if (null != rootDoc) {
- rootDoc.printNotice(notice);
- }
- else {
- System.err.println(notice);
- }
- }
-
- /**
- * Copy the contents of the input directory to the output
- * directory. The output directory must exist.
- */
- private void copyPackageDataDir(GjdocPackageDoc packageDoc) throws IOException {
- File docFilesSourceDirectory
- = new File(packageDoc.packageDirectory(), "doc-files");
- File docFilesTargetDirectory
- = new File(this.targetDirectory,
- packageDoc.name().replace('.', File.separatorChar));
- if (docFilesSourceDirectory.exists()) {
- printNotice("Copying files from " + docFilesSourceDirectory);
- copyDirectory(docFilesSourceDirectory, docFilesTargetDirectory,
- docFilesSubdirsEnabled,
- excludeDocFilesSubDirs);
- }
- }
-
- /**
- * Recursively copy the contents of the input directory to the
- * output directory. The output directory must exist.
- */
- private static void copyDirectory(File sourceDir, File targetDir,
- boolean recursive,
- Set excludeDirs) throws IOException {
- if (!targetDir.exists() && !targetDir.mkdirs()) {
- throw new IOException("Cannot create directory " + targetDir);
- }
-
- File[] sourceFiles = sourceDir.listFiles();
- for (int i=0; i<sourceFiles.length; ++i) {
- if (sourceFiles[i].isDirectory()) {
- if (recursive && (null == excludeDirs
- || !excludeDirs.contains(sourceFiles[i].getName()))) {
- File targetSubDir = new File(targetDir,
- sourceFiles[i].getName());
- if (targetSubDir.exists() || targetSubDir.mkdir()) {
- copyDirectory(sourceFiles[i], targetSubDir, recursive, null);
- }
- else {
- throw new IOException("Cannot create directory " + targetSubDir);
- }
- }
- }
- else {
- copyFile(sourceFiles[i], new File(targetDir, sourceFiles[i].getName()));
- }
- }
- }
-
- /**
- * Copy the contents of the input file to the output file. The
- * output file's parent directory must exist.
- */
- private static void copyFile(File sourceFile, File targetFile) throws IOException {
-
- InputStream in = new FileInputStream(sourceFile);
- OutputStream out = new FileOutputStream(targetFile);
- int nread;
- byte[] buf = new byte[512];
- while ((nread = in.read(buf)) >= 0) {
- out.write(buf, 0, nread);
- }
- in.close();
- out.close();
- }
-
- private void createIndexByName() throws IOException {
- // Create index
-
- // Collect index
-
- Map indexMap = new TreeMap(new Comparator() {
- public int compare(Object o1, Object o2) {
- return o1.toString().toLowerCase().compareTo(o2.toString().toLowerCase());
- }
- });
-
- // Add packages to index
-
- PackageDoc[] packages = rootDoc.specifiedPackages();
- for (int i=0, ilim=packages.length; i<ilim; ++i) {
- PackageDoc c = packages[i];
- indexMap.put(c.name(), c);
- }
-
- // Add classes, fields and methods to index
-
- ClassDoc[] sumclasses = rootDoc.classes();
- for (int i=0, ilim=sumclasses.length; i<ilim; ++i) {
- ClassDoc c = sumclasses[i];
- if (null == c.containingClass()) {
- indexMap.put(c.name(), c);
- }
- else {
- indexMap.put(c.name().substring(c.containingClass().name().length() + 1), c);
- }
- FieldDoc[] fields = c.fields();
- for (int j=0, jlim=fields.length; j<jlim; ++j) {
- indexMap.put(fields[j].name(), fields[j]);
- }
- MethodDoc[] methods = c.methods();
- for (int j=0, jlim=methods.length; j<jlim; ++j) {
- MethodDoc method = methods[j];
- StringBuffer signature = new StringBuffer();
- signature.append(method.name());
- signature.append('(');
- Parameter[] parameters = method.parameters();
- for (int k=0, klim=parameters.length; k<klim; ++k) {
- if (k > 0) {
- signature.append(", ");
- }
- signature.append(parameters[k].typeName());
- }
- signature.append(')');
- indexMap.put(signature.toString(), method);
- }
- }
-
- // Assign output stream
-
- setTargetFile("alphaindex.xml");
-
- // Output XML document header
-
- println(0, "<?xml version=\"1.0\"?>");
- println("<!DOCTYPE gjdoc SYSTEM \"dtd/gjdoc-alphaindex.dtd\">");
- println();
- printOpenTag(0, "alphaindex xmlns=\"http://www.w3.org/TR/REC-html40\" xmlns:gjdoc=\"http://www.gnu.org/software/cp-tools/gjdocxml\"");
-
- Iterator it = indexMap.keySet().iterator();
-
- char previousCategoryLetter = '\0';
- boolean categoryOpen = false;
-
- while (it.hasNext()) {
- String key = (String)it.next();
- Doc entry = (Doc)indexMap.get(key);
-
- char firstChar = Character.toUpperCase(key.charAt(0));
- if (firstChar != previousCategoryLetter) {
- if (categoryOpen) {
- printCloseTag(1, "category");
- }
- printOpenTag(1, "category letter=\"" + firstChar + "\"");
- categoryOpen = true;
- previousCategoryLetter = firstChar;
- }
-
- printOpenTag(2, "entry name=\"" + key + "\"");
- if (entry instanceof PackageDoc) {
- printAtomTag(3, "isPackage");
- }
- else if (entry instanceof ClassDoc) {
- printAtomTag(3, "isClass");
- ClassDoc centry = (ClassDoc)entry;
- currentClass = centry;
- printAtomTag(3, "containingPackage name=\"" + centry.containingPackage().name() + "\"");
- if (null != centry.containingClass()) {
- printAtomTag(3, "containingClass name=\"" + centry.containingClass().name() + "\"");
- }
- if (centry.isInterface()) {
- printAtomTag(3, "isInterface");
- }
- if (centry.isException()) {
- printAtomTag(3, "isException");
- }
- if (centry.isError()) {
- printAtomTag(3, "isError");
- }
- if (centry.isOrdinaryClass()) {
- printAtomTag(3, "isOrdinaryClass");
- }
- }
- else if (entry instanceof ProgramElementDoc) {
- ProgramElementDoc pentry = (ProgramElementDoc)entry;
- currentClass = pentry.containingClass();
- printAtomTag(3, "containingPackage name=\"" + pentry.containingPackage().name() + "\"");
- printAtomTag(3, "containingClass name=\"" + pentry.containingClass().name() + "\"");
- if (pentry.isMethod()) {
- printAtomTag(3, "isMethod");
- ExecutableMemberDoc mentry = (ExecutableMemberDoc)pentry;
- printAtomTag(3, "signature full=\""+mentry.signature()+"\" flat=\""+mentry.flatSignature()+"\"");
- printAtomTag(3, "method name=\"" + mentry.name() + "\"");
- }
- if (pentry.isField()) {
- printAtomTag(3, "isField");
- }
- }
-
- Tag[] tags = entry.firstSentenceTags();
- for (int i=0, ilim=tags.length; i<ilim; ++i) {
- Tag tag = tags[i];
- if (tag.firstSentenceTags().length>0) {
- printOpenTag(3, "firstSentenceTags", false);
- outputTags(4, tag.firstSentenceTags(), false, CONTEXT_TYPE);
- printCloseTag(3, "firstSentenceTags");
- }
- }
-
-
- printCloseTag(2, "entry");
- }
-
- if (categoryOpen) {
- printCloseTag(1, "category");
- }
-
- printCloseTag(0, "alphaindex");
-
- closeTargetFile();
- }
-
- private static class UsageType
- {
- public static final UsageType CLASS_DERIVED_FROM = new UsageType("class-derived-from");
- public static final UsageType FIELD_OF_TYPE = new UsageType("field-of-type");
- public static final UsageType METHOD_WITH_RETURN_TYPE = new UsageType("method-with-return-type");
- public static final UsageType METHOD_WITH_PARAMETER_TYPE = new UsageType("method-with-parameter-type");
- public static final UsageType METHOD_WITH_THROWN_TYPE = new UsageType("method-with-thrown-type");
- public static final UsageType CONSTRUCTOR_WITH_PARAMETER_TYPE = new UsageType("constructor-with-parameter-type");
- public static final UsageType CONSTRUCTOR_WITH_THROWN_TYPE = new UsageType("constructor-with-thrown-type");
- private String id;
-
- private UsageType(String id)
- {
- this.id = id;
- }
-
- public String toString() {
- return "UsageType{id=" + id + "}";
- }
-
- public String getId() {
- return id;
- }
- }
-
- /**
- * ClassDoc -> (PackageDoc -> (UsageType -> (Set of Doc)))
- */
- private Map usedClassToPackagesMap = new HashMap();
-
- private void addUsedBy(ClassDoc usedClass, UsageType usageType, Doc user, PackageDoc userPackage)
- {
- Map packageToUsageTypeMap = (Map)usedClassToPackagesMap.get(usedClass);
- if (null == packageToUsageTypeMap) {
- packageToUsageTypeMap = new HashMap();
- usedClassToPackagesMap.put(usedClass, packageToUsageTypeMap);
- }
-
- Map usageTypeToUsersMap = (Map)packageToUsageTypeMap.get(userPackage);
- if (null == usageTypeToUsersMap) {
- usageTypeToUsersMap = new HashMap();
- packageToUsageTypeMap.put(userPackage, usageTypeToUsersMap);
- }
-
- Set userSet = (Set)usageTypeToUsersMap.get(usageType);
- if (null == userSet) {
- userSet = new TreeSet(); // FIXME: we need the collator from Main here
- usageTypeToUsersMap.put(usageType, userSet);
- }
- userSet.add(user);
- }
-
- /**
- * Create the cross reference database.
- */
- private void collectUsage() {
-
- ClassDoc[] classes = rootDoc.classes();
- for (int i = 0, ilim = classes.length; i < ilim; ++ i) {
- ClassDoc clazz = classes[i];
-
- // classes derived from
- for (ClassDoc superclass = clazz.superclass(); superclass != null;
- superclass = superclass.superclass()) {
- addUsedBy(superclass, UsageType.CLASS_DERIVED_FROM, clazz, clazz.containingPackage());
- }
-
- FieldDoc[] fields = clazz.fields();
- for (int j = 0, jlim = fields.length; j < jlim; ++ j) {
- FieldDoc field = fields[j];
-
- // fields of type
- ClassDoc fieldType = field.type().asClassDoc();
- if (null != fieldType) {
- addUsedBy(fieldType, UsageType.FIELD_OF_TYPE,
- field, clazz.containingPackage());
- }
- }
-
- MethodDoc[] methods = clazz.methods();
- for (int j = 0, jlim = methods.length; j < jlim; ++ j) {
- MethodDoc method = methods[j];
-
- // methods with return type
-
- ClassDoc returnType = method.returnType().asClassDoc();
- if (null != returnType) {
- addUsedBy(returnType, UsageType.METHOD_WITH_RETURN_TYPE,
- method, clazz.containingPackage());
- }
- Parameter[] parameters = method.parameters();
- for (int k=0; k<parameters.length; ++k) {
-
- // methods with parameter type
-
- Parameter parameter = parameters[k];
- ClassDoc parameterType = parameter.type().asClassDoc();
- if (null != parameterType) {
- addUsedBy(parameterType, UsageType.METHOD_WITH_PARAMETER_TYPE,
- method, clazz.containingPackage());
- }
- }
-
- // methods which throw
-
- ClassDoc[] thrownExceptions = method.thrownExceptions();
- for (int k = 0, klim = thrownExceptions.length; k < klim; ++ k) {
- ClassDoc thrownException = thrownExceptions[k];
- addUsedBy(thrownException, UsageType.METHOD_WITH_THROWN_TYPE,
- method, clazz.containingPackage());
- }
- }
-
- ConstructorDoc[] constructors = clazz.constructors();
- for (int j = 0, jlim = constructors.length; j < jlim; ++ j) {
-
- ConstructorDoc constructor = constructors[j];
-
- Parameter[] parameters = constructor.parameters();
- for (int k = 0, klim = parameters.length; k < klim; ++ k) {
-
- // constructors with parameter type
-
- Parameter parameter = parameters[k];
- ClassDoc parameterType = parameter.type().asClassDoc();
- if (null != parameterType) {
- addUsedBy(parameterType, UsageType.CONSTRUCTOR_WITH_PARAMETER_TYPE,
- constructor, clazz.containingPackage());
- }
- }
-
- // constructors which throw
-
- ClassDoc[] thrownExceptions = constructor.thrownExceptions();
- for (int k = 0, klim = thrownExceptions.length; k < klim; ++ k) {
- ClassDoc thrownException = thrownExceptions[k];
- addUsedBy(thrownException, UsageType.CONSTRUCTOR_WITH_THROWN_TYPE,
- constructor, clazz.containingPackage());
- }
- }
- }
- }
-
- private void outputUsage(ClassDoc clazz, int level) {
-
- Map packageToUsageTypeMap = (Map)usedClassToPackagesMap.get(clazz);
- if (null != packageToUsageTypeMap) {
- printOpenTag(level, "references");
-
- Iterator packagesIterator = packageToUsageTypeMap.keySet().iterator();
-
- while (packagesIterator.hasNext()) {
- PackageDoc packageDoc = (PackageDoc)packagesIterator.next();
- printOpenTag(level + 1, "referencing-package name=\"" + packageDoc.name() + "\"");
- Map usageTypeToUsersMap = (Map)packageToUsageTypeMap.get(packageDoc);
- Iterator usageTypeIterator = usageTypeToUsersMap.keySet().iterator();
- while (usageTypeIterator.hasNext()) {
- UsageType usageType = (UsageType)usageTypeIterator.next();
- printOpenTag(level + 2, "usage-type id=\"" + usageType.getId() + "\"");
- Set users = (Set)usageTypeToUsersMap.get(usageType);
- Iterator userIterator = users.iterator();
- while (userIterator.hasNext()) {
- Doc user = (Doc)userIterator.next();
- if (user instanceof ClassDoc) {
- printAtomTag(level + 3, "user"
- + " class=\"" + ((ClassDoc)user).name() + "\"");
- }
- else if (user instanceof FieldDoc) {
- FieldDoc fieldDoc = (FieldDoc)user;
- printAtomTag(level + 3, "user"
- + " class=\"" + fieldDoc.containingClass().name() + "\""
- + " field=\"" + fieldDoc.name() + "\"");
- }
- else if (user instanceof MethodDoc) {
- MethodDoc methodDoc = (MethodDoc)user;
- printAtomTag(level + 3, "user"
- + " class=\"" + methodDoc.containingClass().name() + "\""
- + " method=\"" + methodDoc.name() + "\""
- + " signature=\"" + methodDoc.signature() + "\""
- + " flatSignature=\"" + methodDoc.flatSignature() + "\"");
- }
- else if (user instanceof ConstructorDoc) {
- ConstructorDoc constructorDoc = (ConstructorDoc)user;
- printAtomTag(level + 3, "user"
- + " class=\"" + constructorDoc.containingClass().name() + "\""
- + " signature=\"" + constructorDoc.signature() + "\""
- + " flatSignature=\"" + constructorDoc.flatSignature() + "\"");
- }
- }
- printCloseTag(level +2, "usage-type");
- }
- printCloseTag(level + 1, "referencing-package");
- }
-
- printCloseTag(level, "references");
- }
- }
-
- private boolean processGroupOption(String groupName, String colonSeparatedPackageList)
- {
- try {
- PackageMatcher packageMatcher = new PackageMatcher();
-
- StringTokenizer tokenizer = new StringTokenizer(colonSeparatedPackageList, ":");
- while (tokenizer.hasMoreTokens()) {
- String packageWildcard = tokenizer.nextToken();
- packageMatcher.addWildcard(packageWildcard);
- }
-
- SortedSet groupPackages = packageMatcher.filter(rootDoc.specifiedPackages());
-
- packageGroups.add(new PackageGroup(groupName, groupPackages));
-
- return true;
- }
- catch (InvalidPackageWildcardException e) {
- return false;
- }
- }
-
- private void registerTaglet(Taglet taglet)
- {
- tagletMap.put(taglet.getName(), taglet);
- }
-
- private boolean isVerbose()
- {
- return false;
- }
-}
+/* gnu.classpath.tools.doclets.xmldoclet.Driver
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.doclets.xmldoclet;
+
+import com.sun.javadoc.*;
+import java.io.*;
+
+import com.sun.tools.doclets.Taglet;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+
+import java.text.DateFormat;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.HashSet;
+import java.util.TreeSet;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Properties;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.StringTokenizer;
+import java.util.TreeMap;
+
+import gnu.classpath.tools.gjdoc.TemporaryStore;
+import gnu.classpath.tools.gjdoc.GjdocPackageDoc;
+
+import gnu.classpath.tools.doclets.PackageGroup;
+import gnu.classpath.tools.doclets.PackageMatcher;
+import gnu.classpath.tools.doclets.InvalidPackageWildcardException;
+
+import gnu.classpath.tools.doclets.xmldoclet.doctranslet.DocTranslet;
+import gnu.classpath.tools.doclets.xmldoclet.doctranslet.DocTransletOptions;
+
+import gnu.classpath.tools.taglets.AuthorTaglet;
+import gnu.classpath.tools.taglets.VersionTaglet;
+import gnu.classpath.tools.taglets.SinceTaglet;
+import gnu.classpath.tools.taglets.DeprecatedTaglet;
+import gnu.classpath.tools.taglets.GenericTaglet;
+import gnu.classpath.tools.doclets.StandardTaglet;
+
+import gnu.classpath.tools.java2xhtml.Java2xhtml;
+
+import gnu.classpath.tools.IOToolkit;
+import gnu.classpath.tools.FileSystemClassLoader;
+
+/**
+ * A Doclet which retrieves all information presented by the Doclet
+ * API, dumping it to stdout in XML format.
+ *
+ * @author Julian Scheid
+ */
+public class Driver {
+
+ public static final String XMLDOCLET_VERSION = "0.6.1";
+
+ /**
+ * Used for redirecting error messages to <code>/dev/null</code>.
+ */
+ private static class NullErrorReporter implements DocErrorReporter {
+ public void printError(String ignore) {}
+ public void printWarning(String ignore) {}
+ public void printNotice(String ignore) {}
+ }
+
+ /*
+ * Taglet context constants.
+ */
+ private static final int CONTEXT_CONSTRUCTOR = 1;
+ private static final int CONTEXT_FIELD = 2;
+ private static final int CONTEXT_METHOD = 3;
+ private static final int CONTEXT_OVERVIEW = 4;
+ private static final int CONTEXT_PACKAGE = 5;
+ private static final int CONTEXT_TYPE = 6;
+
+ /**
+ * All XML output will go to this stream.
+ */
+ private PrintWriter out;
+
+ /**
+ * How many spaces to indent each XML node level,
+ * i.e. Tab size for output.
+ */
+ private static int indentStep = 1;
+
+ /**
+ * Won't output superfluous spaces if set to true.
+ * If set to false, output will be more legible.
+ */
+ private boolean compress = false;
+
+ /**
+ * Won't output warning messages while fixing
+ * HTML code if set to true.
+ */
+ private boolean noHTMLWarn = false;
+
+ /**
+ * Won't output warning messages when encountering tags
+ * that look like an email address if set to true.
+ */
+ private boolean noEmailWarn = false;
+
+ /**
+ * Will fix HTML if necessary so that each comment
+ * contains valid XML code if set to true. If set
+ * to false, HTML code will not be modified and
+ * instead encapsulated in a CDATA section.
+ */
+ private boolean fixHTML = true;
+
+ /**
+ * User-specified name of the directory where the final version of
+ * the generated files will be written to.
+ *
+ * If no XSLT sheet is given, the XML output will go directly into
+ * this directory. Otherwise, XML output will go to a temporary
+ * directory and XSLT output will go to this directory.
+ */
+ private File targetDirectory = null;
+
+ /**
+ * Directory where XML output will be written to. If no XSLT
+ * sheet was given, this is the target directory specified
+ * by the user. Otherwise, this is a temporary directory.
+ */
+ private File xmlTargetDirectory;
+
+ /**
+ * Contains a number of TargetContexts which describe which XSLT
+ * sheet to apply to the output of this doclet, to what directory
+ * the XSLT output is written, and which postprocess driver to use
+ * to process XSLT output.
+ */
+ private List targets = new ArrayList();
+
+ /**
+ * XML text to include at the end of every generated page. Read
+ * from the file specified on the command line using -bottomnote.
+ * If present, this will be written to the main output file
+ * (index.xml) in node /gjdoc:rootDoc/gjdoc:bottomnote.
+ */
+ private String bottomNote;
+
+ /**
+ * Brief description of the package set. Can be specified on the
+ * command line using -title. This will be written to the main
+ * output file (index.xml) in node
+ * /gjdoc:rootDoc/gjdoc:title. The HTML generating XSLT sheet
+ * uses this for example in window titles.
+ */
+ private String title;
+
+ /**
+ * Path to the directory where temporary files should be stored.
+ * Defaults to system tempdir, but can be overridden by user
+ * with -workpath.
+ */
+ private String workingPath = System.getProperty("java.io.tmpdir");
+
+ /**
+ * Temporary directory created by this doclet where all
+ * temporary files will be stored in. If no temporary
+ * files are needed (i.e. no XSLT postprocessing stage
+ * specified by user), this is <code>null</code>.
+ */
+ private File workingDirectory;
+
+ /**
+ * Whether to deep-copy the doc-files subdirectory.
+ */
+ private boolean docFilesSubdirsEnabled = false;
+
+ /**
+ * Which direct subdirectories of the doc-files directories to exclude.
+ * Set of String.
+ */
+ private Set excludeDocFilesSubDirs = new HashSet();
+
+ /**
+ * Stores the Doclet API RootDoc we are operating on.
+ */
+ private RootDoc rootDoc;
+
+ /**
+ * XML namespace prefix used for all tags, except for HTML
+ * tags copied from Javadoc comments. Excluding colon.
+ */
+ public static final String tagPrefix = "gjdoc";
+
+ /**
+ * Classpath for loading Taglet classes.
+ */
+ private String tagletPath = null;
+
+ /**
+ * The current class that is being processed.
+ * Set in outputClassDoc().
+ */
+ private ClassDoc currentClass;
+
+ /**
+ * The current member that is being processed.
+ * Set in outputMemberDoc().
+ */
+ private MemberDoc currentMember;
+
+ /**
+ * The current constructor/method that is being processed.
+ * Set in outputExecutableMemberDoc().
+ */
+ private ExecutableMemberDoc currentExecMember;
+
+ /**
+ * Mapping from tag type to Taglet for user Taglets specified on
+ * the command line.
+ */
+ private Map tagletMap = new LinkedHashMap();
+
+ /**
+ * Keeps track of the tags mentioned by the user during option
+ * processiong so that an error can be emitted if a tag is
+ * mentioned more than once.
+ */
+ private List mentionedTags = new LinkedList();
+
+ /**
+ * Stores options to be passed to the DocTranslet.
+ */
+ private DocTransletOptions docTransletOptions = new DocTransletOptions();
+
+ /**
+ * Stores the package groups specified in the user
+ * options. Contains objects of type PackageGroup.
+ */
+ private List packageGroups = new LinkedList();
+
+ private HtmlRepairer htmlRepairer;
+
+ public static boolean start(TemporaryStore _rootDocWrapper) {
+ return new Driver().instanceStart((RootDoc)_rootDocWrapper.getAndClear());
+ }
+
+ /**
+ * Official Doclet entry point.
+ */
+ public static boolean start(RootDoc _rootDoc) {
+
+ // Create a new XmlDoclet instance and delegate control.
+ TemporaryStore tstore = new TemporaryStore(_rootDoc);
+ _rootDoc = null;
+ return new Driver().instanceStart((RootDoc)tstore.getAndClear());
+ }
+
+ /**
+ * Output an XML tag describing a com.sun.javadoc.Type object.
+ * Assumes that the tag does not have subtags.
+ *
+ * @param level Level of indentation. Will be multiplied by
+ * <code>indentStep</code> to yield actual amount
+ * of whitespace inserted at start of line.
+ * @param tag Identifier for the XML tag being output.
+ * @param type The Javadoc Type to be output.
+ */
+ protected void outputType(int level, String tag, Type type) {
+ outputType(level, tag, type, true);
+ }
+
+ protected void outputType(int level, String tag, Type type, boolean atomic) {
+
+ boolean isIncluded = false;
+ ClassDoc typeAsClassDoc = type.asClassDoc();
+ String packageName = null;
+ if (null != typeAsClassDoc) {
+ isIncluded = typeAsClassDoc.isIncluded();
+ packageName = typeAsClassDoc.containingPackage().name();
+ }
+ println(level, "<"+tagPrefix+":"+tag + " typename=\""+type.typeName()+"\""+
+ " qualifiedtypename=\""+type.qualifiedTypeName()+"\""
+ +(type.dimension().length()==0?"":" dimension=\""+type.dimension()+"\"")
+ +(isIncluded?" isIncluded=\"true\"" : "")
+ +((null != packageName)?" package=\"" + packageName + "\"" : "")
+ +(atomic?"/":"")+">");
+ }
+
+ protected void outputExecutableMemberDocBody(int level, ExecutableMemberDoc memberDoc) {
+
+ currentExecMember = memberDoc;
+
+ outputMemberDocBody(level, memberDoc);
+
+ Parameter[] parameters = memberDoc.parameters();
+ for (int i=0, ilim=parameters.length; i<ilim; ++i) {
+ Parameter parameter = parameters[i];
+ outputType(level, "parameter name=\""+parameter.name()+"\"", parameter.type());
+ }
+
+ ClassDoc[] exceptions = memberDoc.thrownExceptions();
+ for (int i=0, ilim=exceptions.length; i<ilim; ++i) {
+ ClassDoc exception = exceptions[i];
+ outputType(level, "thrownException", exception);
+ }
+
+ printAtomTag(level, "signature full=\""+memberDoc.signature()+"\" flat=\""+memberDoc.flatSignature()+"\"");
+
+ if (memberDoc.isNative()) {
+ printAtomTag(level, "isNative");
+ }
+
+ if (memberDoc.isSynchronized()) {
+ printAtomTag(level, "isSynchronized");
+ }
+ }
+
+ protected void outputMethodDoc(int level, MethodDoc methodDoc) {
+ println();
+ printOpenTag(level, "methoddoc name=\""+methodDoc.name()+"\"");
+ outputExecutableMemberDocBody(level+1, methodDoc);
+ outputType(level+1, "returns", methodDoc.returnType());
+ printCloseTag(level, "methoddoc");
+ }
+
+ protected void outputMemberDocBody(int level, MemberDoc memberDoc) {
+ currentMember = memberDoc;
+ outputProgramElementDocBody(level, memberDoc);
+ }
+
+ protected void outputFieldDocBody(int level, FieldDoc fieldDoc) {
+ outputType(level, "type", fieldDoc.type());
+ if (fieldDoc.isTransient()) {
+ printAtomTag(level, "isTransient");
+ }
+ if (fieldDoc.isVolatile()) {
+ printAtomTag(level, "isVolatile");
+ }
+ }
+
+ private void outputFieldDoc(int level, FieldDoc fieldDoc) {
+ println();
+ printOpenTag(level, "fielddoc name=\""+fieldDoc.name()+"\"");
+ outputMemberDocBody(level+1, fieldDoc);
+ outputFieldDocBody(level+1, fieldDoc);
+ printCloseTag(level, "fielddoc");
+ }
+
+ protected void outputConstructorDoc(int level, ConstructorDoc constructorDoc) {
+ println();
+ printOpenTag(level, "constructordoc name=\""+constructorDoc.name()+"\"");
+ outputExecutableMemberDocBody(level+1, constructorDoc);
+ printCloseTag(level, "constructordoc");
+ }
+
+ protected void outputSuperInterfacesRec(int level, ClassDoc classDoc) {
+ if (null!=classDoc) {
+ ClassDoc[] interfaces = classDoc.interfaces();
+ if (null != interfaces) {
+ for (int i=0, ilim=interfaces.length; i<ilim; ++i) {
+ outputType(level, "superimplements", interfaces[i]);
+ }
+ }
+ outputSuperInterfacesRec(level, classDoc.superclass());
+ }
+ }
+
+ protected void outputClassDocSummary(ClassDoc classDoc) {
+ println();
+ printOpenTag(1, "classdoc name=\""+classDoc.name()+"\" qualifiedtypename=\""+classDoc.qualifiedName()+"\" isIncluded=\"true\"");
+ if (null!=classDoc.superclass()) {
+ outputType(2, "superclass", classDoc.superclass());
+ }
+
+ ClassDoc[] interfaces = classDoc.interfaces();
+ for (int i=0, ilim=interfaces.length; i<ilim; ++i) {
+ outputType(2, "implements", interfaces[i]);
+ }
+ outputSuperInterfacesRec(2, classDoc.superclass());
+
+ printAtomTag(2, "containingPackage name=\""+classDoc.containingPackage().name()+"\"");
+ if (classDoc.isError()) {
+ printAtomTag(2, "isError");
+ }
+ if (classDoc.isException()) {
+ printAtomTag(2, "isException");
+ }
+ if (classDoc.isInterface()) {
+ printAtomTag(2, "isInterface");
+ }
+ if (classDoc.isOrdinaryClass()) {
+ printAtomTag(2, "isOrdinaryClass");
+ }
+
+ printCloseTag(1, "classdoc");
+ }
+
+ protected void outputPackageDoc(PackageDoc packageDoc) {
+ println();
+ printOpenTag(1, "packagedoc name=\""+packageDoc.name()+"\"");
+ if (packageDoc.firstSentenceTags().length > 0) {
+ printOpenTag(2, "firstSentenceTags", false);
+ outputTags(3, packageDoc.firstSentenceTags(), true, CONTEXT_PACKAGE);
+ printCloseTag(0, "firstSentenceTags");
+ printOpenTag(2, "inlineTags", false);
+ outputTags(3, packageDoc.inlineTags(), true, CONTEXT_PACKAGE);
+ printCloseTag(0, "inlineTags");
+ }
+
+ if (packageDoc.tags().length > 0) {
+ printOpenTag(2, "tags");
+ outputTags(3, packageDoc.tags(), true, CONTEXT_PACKAGE);
+ printCloseTag(2, "tags");
+ }
+
+ if (packageDoc.seeTags().length > 0) {
+ printOpenTag(2, "seeTags");
+ outputTags(3, packageDoc.seeTags(), true, CONTEXT_PACKAGE);
+ printCloseTag(2, "seeTags");
+ }
+
+ ClassDoc[] allClasses = (ClassDoc[]) packageDoc.allClasses().clone();
+ Arrays.sort(allClasses);
+
+ if (false) {
+ for (int i = 0, ilim = allClasses.length; i < ilim; ++ i) {
+ printAtomTag(2, "containsClass qualifiedtypename=\""+allClasses[i].qualifiedTypeName()+"\"");
+ }
+ }
+
+ printCloseTag(1, "packagedoc");
+ }
+
+ protected void outputClassDoc(ClassDoc classDoc) throws IOException {
+
+ currentClass = classDoc;
+
+ println();
+ printOpenTag(1, "classdoc xmlns=\"http://www.w3.org/TR/REC-html40\" xmlns:"+tagPrefix+"=\"http://www.gnu.org/software/cp-tools/gjdocxml\" name=\""+classDoc.name()+"\" qualifiedtypename=\""+classDoc.qualifiedName()+"\"");
+
+ ClassDoc[] interfaces = classDoc.interfaces();
+ for (int i=0, ilim=interfaces.length; i<ilim; ++i) {
+ outputType(2, "implements", interfaces[i]);
+ }
+ outputSuperInterfacesRec(2, classDoc.superclass());
+
+ outputProgramElementDocBody(2, classDoc);
+ if (classDoc.isAbstract())
+ printAtomTag(2, "isAbstract");
+ if (classDoc.isSerializable())
+ printAtomTag(2, "isSerializable");
+ if (classDoc.isExternalizable())
+ printAtomTag(2, "isExternalizable");
+ if (classDoc.definesSerializableFields()) {
+ printAtomTag(2, "definesSerializableFields");
+ }
+
+ ConstructorDoc[] constructors = classDoc.constructors();
+ for (int i=0, ilim=constructors.length; i<ilim; ++i) {
+ outputConstructorDoc(2, constructors[i]);
+ }
+
+ MethodDoc[] methods = classDoc.methods();
+ for (int i=0, ilim=methods.length; i<ilim; ++i) {
+ outputMethodDoc(2, methods[i]);
+ }
+
+ FieldDoc[] fields = classDoc.fields();
+ for (int i=0, ilim=fields.length; i<ilim; ++i) {
+ outputFieldDoc(2, fields[i]);
+ }
+
+ if (classDoc.serializableFields().length > 0) {
+ printOpenTag(2, "serializableFields");
+
+ FieldDoc[] sfields = classDoc.serializableFields();
+ for (int i=0, ilim=sfields.length; i<ilim; ++i) {
+ outputFieldDoc(2, sfields[i]);
+ }
+ printCloseTag(2, "serializableFields");
+ }
+
+ Java2xhtml java2xhtml = new Java2xhtml();
+ Properties properties = new Properties();
+ properties.setProperty("isCodeSnippet", "true");
+ properties.setProperty("hasLineNumbers", "true");
+ java2xhtml.setProperties(properties);
+
+ if (null == classDoc.containingClass() && docTransletOptions.linksource) {
+ printOpenTag(2, "source");
+ StringWriter sourceBuffer = new StringWriter();
+ File sourceFile = new File(((GjdocPackageDoc)classDoc.containingPackage()).packageDirectory(),
+ classDoc.name() + ".java");
+ FileReader sourceReader = new FileReader(sourceFile);
+ IOToolkit.copyStream(sourceReader, sourceBuffer);
+ print(java2xhtml.makeHTML(sourceBuffer.getBuffer(), sourceFile.getName()));
+ printCloseTag(2, "source");
+ }
+
+ ClassDoc superclassDoc = classDoc.superclass();
+ while (superclassDoc != null) {
+ outputType(2, "superclass", superclassDoc, false);
+
+ // FIXME: remove the following after adjusting the XSLT sheets:
+ printAtomTag(3, "containingPackage name=\"" + superclassDoc.containingPackage().name() + "\"");
+
+ MethodDoc[] superMethods = superclassDoc.methods();
+ if (null != superMethods) {
+ for (int i=0, ilim=superMethods.length; i<ilim; ++i) {
+ printAtomTag(3, "methoddoc name=\"" + superMethods[i].name() + "\" signature=\"" + superMethods[i].signature() + "\"");
+ }
+ }
+
+ FieldDoc[] superFields = superclassDoc.fields();
+ if (null != superFields) {
+ for (int i=0, ilim=superFields.length; i<ilim; ++i) {
+ printAtomTag(3, "fielddoc name=\"" + superFields[i].name() + "\"");
+ }
+ }
+ printCloseTag(2, "superclass");
+
+ superclassDoc = superclassDoc.superclass();
+ }
+
+ outputUsage(classDoc, 2);
+
+ printCloseTag(1, "classdoc");
+
+ currentClass = null;
+ currentMember = null;
+ currentExecMember = null;
+ }
+
+ protected int outputHeritageOpen(int level, ClassDoc classDoc) {
+
+ ClassDoc superClassDoc = classDoc.superclass();
+ if (null != superClassDoc) {
+ level = outputHeritageOpen(level, superClassDoc);
+ ++ level;
+ }
+ outputType(level, "heritage", classDoc, false);
+ return level;
+ }
+
+ protected void outputHeritageClose(int level, ClassDoc classDoc) {
+
+ ClassDoc superClassDoc = classDoc.superclass();
+ if (null != superClassDoc) {
+ outputHeritageClose(level + 1, superClassDoc);
+ }
+ printCloseTag(level, "heritage");
+ }
+
+ protected void outputDocBody(int level, Doc doc) {
+
+ int context = CONTEXT_TYPE;
+
+ if (doc.isClass()) {
+ printAtomTag(level, "isClass");
+
+ ClassDoc classDoc = (ClassDoc)doc;
+ ClassDoc[] classes = rootDoc.classes();
+ for (int i=0, ilim=classes.length; i<ilim; ++i) {
+ if (classes[i].superclass() == classDoc) {
+ outputType(level, "extended-by", classes[i]);
+ }
+ }
+
+ outputHeritageOpen(level, classDoc);
+ outputHeritageClose(level, classDoc);
+ }
+ if (doc.isConstructor()) {
+ printAtomTag(level, "isConstructor");
+ context = CONTEXT_CONSTRUCTOR;
+ }
+ if (doc.isError()) {
+ printAtomTag(level, "isError");
+ }
+ if (doc.isException()) {
+ printAtomTag(level, "isException");
+ }
+ if (doc.isField()) {
+ printAtomTag(level, "isField");
+ context = CONTEXT_FIELD;
+ }
+ if (doc.isIncluded()) {
+ printAtomTag(level, "isIncluded");
+ }
+ if (doc.isInterface()) {
+ printAtomTag(level, "isInterface");
+
+ ClassDoc classDoc = (ClassDoc)doc;
+ ClassDoc[] classes = rootDoc.classes();
+ for (int i=0, ilim=classes.length; i<ilim; ++i) {
+ ClassDoc[] implementedInterfaces = classes[i].interfaces();
+ for (int j=0; j<implementedInterfaces.length; ++j) {
+ if (implementedInterfaces[j] == classDoc) {
+ if (classDoc.isInterface()) {
+ outputType(level, "subinterface", classes[i]);
+ }
+ else {
+ outputType(level, "implemented-by", classes[i]);
+ }
+ break;
+ }
+ }
+ }
+ }
+ if (doc.isMethod()) {
+ printAtomTag(level, "isMethod");
+ context = CONTEXT_METHOD;
+ }
+ if (doc.isOrdinaryClass()) {
+ printAtomTag(level, "isOrdinaryClass");
+ }
+
+ if (doc.inlineTags().length > 0) {
+ printOpenTag(level, "inlineTags", false);
+ outputTags(level+1, doc.inlineTags(), true, context);
+ printCloseTag(0, "inlineTags");
+ }
+
+ if (doc.firstSentenceTags().length > 0) {
+ printOpenTag(level, "firstSentenceTags", false);
+ outputTags(level+1, doc.firstSentenceTags(), true, context);
+ printCloseTag(0, "firstSentenceTags");
+ }
+
+ if (doc.tags().length > 0) {
+ printOpenTag(level, "tags");
+ outputTaglets(level+1, doc.tags(), true, context);
+ printCloseTag(level, "tags");
+ }
+
+ if (doc.seeTags().length > 0) {
+ printOpenTag(level, "seeTags");
+ outputTags(level+1, doc.seeTags(), true, context);
+ printCloseTag(level, "seeTags");
+ }
+
+ SourcePosition position = doc.position();
+ if (null != position) {
+ printAtomTag(level, "position file=\"" + position.file().getAbsolutePath() + "\" line=\"" + position.line() + "\" column=\"" + position.column() + "\"");
+ }
+ }
+
+ protected void outputProgramElementDocBody(int level, ProgramElementDoc programElementDoc) {
+ outputDocBody(level, programElementDoc);
+ printAtomTag(level, "containingPackage name=\""+programElementDoc.containingPackage().name()+"\"");
+ if (null!=programElementDoc.containingClass()) {
+ outputType(level, "containingClass", programElementDoc.containingClass());
+ }
+ String access;
+ if (programElementDoc.isPublic())
+ access="public";
+ else if (programElementDoc.isProtected())
+ access="protected";
+ else if (programElementDoc.isPrivate())
+ access="private";
+ else if (programElementDoc.isPackagePrivate())
+ access="package";
+ else
+ throw new RuntimeException("Huh? "+programElementDoc+" is neither public, protected, private nor package protected.");
+ printAtomTag(level, "access scope=\""+access+"\"");
+ if (programElementDoc.isFinal())
+ printAtomTag(level, "isFinal");
+ if (programElementDoc.isStatic())
+ printAtomTag(level, "isStatic");
+ }
+
+ protected void outputTags(int level, Tag[] tags, boolean descend, int context) {
+
+ for (int i=0; i<tags.length; ++i) {
+ outputTag(tags[i], level, descend, context, i == tags.length-1);
+ }
+ }
+
+ protected void outputTag(Tag tag, int level, boolean descend, int context, boolean lastTag) {
+
+ if (!"Text".equals(tag.name())) {
+ printOpenTag(0 /* don't introduce additional whitespace */,
+ "tag kind=\""+tag.kind()+"\" name=\""+tag.name()+"\"", false);
+ }
+ if (tag instanceof ThrowsTag) {
+ ThrowsTag throwsTag = (ThrowsTag)tag;
+ if (null!=throwsTag.exception()) {
+ outputType(level+1, "exception", throwsTag.exception());
+ }
+ else {
+ StringBuffer sb = new StringBuffer("Exception ");
+ sb.append(throwsTag.exceptionName());
+ sb.append(" not found in ");
+ if (currentExecMember instanceof MethodDoc) {
+ MethodDoc m = (MethodDoc)currentExecMember;
+ sb.append(m.returnType().typeName());
+ sb.append(m.returnType().dimension());
+ sb.append(' ');
+ }
+ sb.append(currentClass.qualifiedName());
+ sb.append('.');
+ sb.append(currentExecMember.name());
+ sb.append('(');
+ Parameter[] params = currentExecMember.parameters();
+ for (int j=0; j < params.length; j++) {
+ sb.append(params[j].type().typeName());
+ sb.append(params[j].type().dimension());
+ sb.append(' ');
+ sb.append(params[j].name());
+ if (j != params.length-1)
+ sb.append(", ");
+ }
+ sb.append(')');
+ printWarning(sb.toString());
+
+ printAtomTag(level+1, "exception typename=\""+throwsTag.exceptionName()+"\"");
+ }
+ }
+ else if (tag instanceof ParamTag) {
+ ParamTag paramTag = (ParamTag)tag;
+ printAtomTag(level+1, "parameter name=\""+paramTag.parameterName()+"\"");
+ }
+
+ if (null != tag.text()) {
+ //printOpenTag(level+1, "text", false);
+ if (fixHTML) {
+ print(htmlRepairer.getWellformedHTML(tag.text()));
+ }
+ else {
+ print("<![CDATA["+cdata(tag.text())+"]]>");
+ }
+ //printCloseTag(0 /* don't introduce additional whitespace */, "text");
+ }
+ else {
+ printWarning("Tag got null text: "+tag);
+ }
+
+ if ((descend && ("@throws".equals(tag.name()) || "@param".equals(tag.name()))) || "@deprecated".equals(tag.name())) {
+ if (tag.firstSentenceTags().length>0) {
+ printOpenTag(level+1, "firstSentenceTags", false);
+ outputTags(level+2, tag.firstSentenceTags(), false, context);
+ printCloseTag(0, "firstSentenceTags");
+ }
+
+ if (tag.inlineTags().length>0) {
+ printOpenTag(level+1, "inlineTags", false);
+ outputTags(level+2, tag.firstSentenceTags(), false, context);
+ printCloseTag(0, "inlineTags");
+ }
+ }
+
+ if (fixHTML && lastTag) {
+ String terminateText = htmlRepairer.terminateText();
+ if (null != terminateText && terminateText.length() > 0) {
+ print(terminateText);
+ }
+ }
+
+ if (!"Text".equals(tag.name())) {
+
+ Taglet inlineTaglet = (Taglet)tagletMap.get(tag.name().substring(1));
+ if (null != inlineTaglet && inlineTaglet.isInlineTag()) {
+ printOpenTag(0, "inlineTagletText", false);
+ print(inlineTaglet.toString(tag));
+ printCloseTag(0, "inlineTagletText");
+ }
+
+ printCloseTag(0, "tag", false);
+ }
+ }
+
+ void outputTaglets(int level, Tag[] tags, boolean descend, int context)
+ {
+ for (Iterator it = tagletMap.keySet().iterator(); it.hasNext(); ) {
+ String tagName = (String)it.next();
+ Object o = tagletMap.get(tagName);
+ Taglet taglet = (Taglet)o;
+
+ if (!taglet.isInlineTag()
+ && ((context != CONTEXT_CONSTRUCTOR || taglet.inConstructor())
+ || (context != CONTEXT_FIELD || taglet.inField())
+ || (context != CONTEXT_METHOD || taglet.inMethod())
+ || (context != CONTEXT_OVERVIEW || taglet.inOverview())
+ || (context != CONTEXT_PACKAGE || taglet.inPackage())
+ || (context != CONTEXT_TYPE || taglet.inType()))) {
+
+ List tagsOfThisType = new ArrayList();
+ for (int i=0, ilim=tags.length; i<ilim; ++i) {
+ if (tags[i].name().substring(1).equals(tagName)) {
+ tagsOfThisType.add(tags[i]);
+ }
+ }
+
+ if (!tagsOfThisType.isEmpty()) {
+ Tag[] tagletTags = (Tag[])tagsOfThisType.toArray(new Tag[tagsOfThisType.size()]);
+ if (taglet instanceof StandardTaglet) {
+ Iterator tagIterator = tagsOfThisType.iterator();
+ while (tagIterator.hasNext()) {
+ Tag tag = (Tag)tagIterator.next();
+ outputTag(tag, level, descend, context, !tagIterator.hasNext());
+ }
+ }
+ else {
+ String tagletString = taglet.toString(tagletTags);
+ if (null != tagletString) {
+ printOpenTag(0, "tag name=\"" + tagName + "\" taglet-generated=\"true\"");
+ if (fixHTML) {
+ print(htmlRepairer.getWellformedHTML(tagletString));
+ print(htmlRepairer.terminateText());
+ }
+ else {
+ print("<![CDATA["+cdata(tagletString)+"]]>");
+ }
+ printCloseTag(0, "tag", false);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Inofficial entry point. We got an instance here.
+ */
+ protected boolean instanceStart(RootDoc _rootDoc) {
+
+ this.rootDoc = _rootDoc;
+ _rootDoc = null;
+
+ boolean xmlOnly = true;
+
+ // Set the default Taglet order
+
+ registerTaglet(new VersionTaglet());
+ registerTaglet(new AuthorTaglet());
+ //registerTaglet(new SinceTaglet());
+ registerTaglet(new StandardTaglet("deprecated"));
+ registerTaglet(new StandardTaglet("see"));
+ registerTaglet(new StandardTaglet("param"));
+
+ // Set the built-in Taglet filter
+
+ AuthorTaglet.setTagletEnabled(false);
+ VersionTaglet.setTagletEnabled(false);
+ SinceTaglet.setTagletEnabled(true);
+ DeprecatedTaglet.setTagletEnabled(true);
+
+ try {
+ {
+
+ // Process command line options passed through to this doclet
+
+ TargetContext targetContext = null;
+
+ TargetContext htmlTargetContext
+ = new TargetContext(DocTranslet.fromClasspath("/doctranslets/html/gjdoc.xsl"),
+ targetDirectory);
+
+ for (int i=0, ilim=rootDoc.options().length; i<ilim; ++i) {
+
+ String[] option = rootDoc.options()[i];
+ String optionTag = option[0];
+
+ if ("-d".equals(optionTag)) {
+ if (null == targetDirectory) {
+ targetDirectory = new File(option[1]);
+ }
+ if (null != targetContext) {
+ targetContext.setTargetDirectory(targetDirectory);
+ }
+ }
+
+ else if ("-nofixhtml".equals(optionTag)) {
+ fixHTML = false;
+ printError("-nofixhtml currently not supported.");
+ return false;
+ }
+ else if ("-compress".equals(optionTag)) {
+ compress = true;
+ }
+ else if ("-nohtmlwarn".equals(optionTag)) {
+ noHTMLWarn = true;
+ }
+ else if ("-noemailwarn".equals(optionTag)) {
+ noEmailWarn = true;
+ }
+ else if ("-indentstep".equals(optionTag)) {
+ indentStep = Integer.parseInt(option[1]);
+ }
+ else if ("-doctranslet".equals(optionTag)) {
+ targets.add(targetContext = new TargetContext(DocTranslet.fromJarFile(new File(option[1])),
+ targetDirectory));
+ }
+ else if ("-genhtml".equals(optionTag)) {
+ htmlTargetContext.setTargetDirectory(targetDirectory);
+ targets.add(targetContext = htmlTargetContext);
+ xmlOnly = false;
+ }
+ else if ("-geninfo".equals(optionTag)) {
+ targetContext
+ = new TargetContext(DocTranslet.fromClasspath("/doctranslets/info/gengj.xsl"),
+ targetDirectory);
+ targets.add(targetContext);
+ if (!fixHTML) {
+ printNotice("NOTE: -geninfo implies -fixhtml.");
+ fixHTML = true;
+ }
+ xmlOnly = false;
+ }
+ else if ("-gendocbook".equals(optionTag)) {
+ targetContext = new TargetContext(DocTranslet.fromClasspath("/doctranslets/docbook/gengj.xsl"),
+ targetDirectory);
+ targets.add(targetContext);
+ if (!fixHTML) {
+ printNotice("NOTE: -gendocbook implies -fixhtml.");
+ fixHTML = true;
+ }
+ }
+ else if ("-genpdf".equals(optionTag)) {
+ targetContext
+ = new TargetContext(DocTranslet.fromClasspath("/doctranslets/docbook/gengj.xsl"),
+ targetDirectory);
+ /** "gnu.classpath.tools.doclets.xmldoclet.DocBookPostprocessor") **/
+ targets.add(targetContext);
+ if (!fixHTML) {
+ printNotice("NOTE: -genpdf implies -fixhtml.");
+ fixHTML = true;
+ }
+ }
+ else if ("-xmlonly".equals(optionTag)) {
+ xmlOnly = true;
+ }
+ else if ("-bottomnote".equals(optionTag)) {
+
+ FileReader reader = new FileReader(option[1]);
+ StringWriter writer = new StringWriter();
+ char[] buf = new char[256];
+ int nread;
+ while ((nread = reader.read(buf)) >= 0) {
+ writer.write(buf, 0, nread);
+ }
+ writer.flush();
+ bottomNote = writer.toString();
+ writer.close();
+ reader.close();
+ }
+ else if ("-title".equals(optionTag)) {
+
+ title = option[1];
+ }
+ else if ("-workpath".equals(optionTag)) {
+
+ workingPath = option[1];
+ }
+ else if ("-tagletpath".equals(optionTag)) {
+
+ if (null == tagletPath) {
+ tagletPath = option[1];
+ }
+ else {
+ tagletPath = tagletPath + File.pathSeparator + option[1];
+ }
+ }
+ else if ("-taglet".equals(optionTag)) {
+
+ boolean tagletLoaded = false;
+
+ String useTagletPath = this.tagletPath;
+ if (null == useTagletPath) {
+ useTagletPath = System.getProperty("java.class.path");
+ }
+
+ try {
+ Class tagletClass;
+ try {
+ tagletClass
+ = new FileSystemClassLoader(useTagletPath).loadClass(option[1]);
+ }
+ catch (ClassNotFoundException e) {
+ // If not found on specified tagletpath, try default classloader
+ tagletClass
+ = Class.forName(option[1]);
+ }
+ Method registerTagletMethod
+ = tagletClass.getDeclaredMethod("register", new Class[] { java.util.Map.class });
+
+ if (!registerTagletMethod.getReturnType().equals(Void.TYPE)) {
+ printError("Taglet class '" + option[1] + "' found, but register method doesn't return void.");
+ }
+ else if (registerTagletMethod.getExceptionTypes().length > 0) {
+ printError("Taglet class '" + option[1] + "' found, but register method contains throws clause.");
+ }
+ else if ((registerTagletMethod.getModifiers() & (Modifier.STATIC | Modifier.PUBLIC | Modifier.ABSTRACT)) != (Modifier.STATIC | Modifier.PUBLIC)) {
+ printError("Taglet class '" + option[1] + "' found, but register method isn't public static, or is abstract..");
+ }
+ else {
+ Map tempMap = new HashMap();
+ registerTagletMethod.invoke(null, new Object[] { tempMap });
+ tagletLoaded = true;
+ String name = (String)tempMap.keySet().iterator().next();
+ Taglet taglet = (Taglet)tempMap.get(name);
+ tagletMap.put(name, taglet);
+ mentionedTags.add(taglet);
+ }
+ }
+ catch (NoSuchMethodException e) {
+ printError("Taglet class '" + option[1] + "' found, but doesn't contain the register method.");
+ }
+ catch (SecurityException e) {
+ printError("Taglet class '" + option[1] + "' cannot be loaded: " + e.getMessage());
+ }
+ catch (InvocationTargetException e) {
+ printError("Taglet class '" + option[1] + "' found, but register method throws exception: " + e.toString());
+ }
+ catch (IllegalAccessException e) {
+ printError("Taglet class '" + option[1] + "' found, but there was a problem when accessing the register method: " + e.toString());
+ }
+ catch (IllegalArgumentException e) {
+ printError("Taglet class '" + option[1] + "' found, but there was a problem when accessing the register method: " + e.toString());
+ }
+ catch (ClassNotFoundException e) {
+ printError("Taglet class '" + option[1] + "' cannot be found.");
+ }
+ if (!tagletLoaded) {
+ return false;
+ }
+ }
+ else if ("-author".equals(optionTag)) {
+ AuthorTaglet.setTagletEnabled(true);
+ }
+ else if ("-version".equals(optionTag)) {
+ VersionTaglet.setTagletEnabled(true);
+ }
+ else if ("-nosince".equals(optionTag)) {
+ SinceTaglet.setTagletEnabled(false);
+ }
+ else if ("-nodeprecated".equals(optionTag)) {
+ DeprecatedTaglet.setTagletEnabled(false);
+ }
+ else if ("-authormail".equals(optionTag)) {
+
+ if ("no-replace".equalsIgnoreCase(option[1])) {
+ AuthorTaglet.setEmailReplacementType(AuthorTaglet.EmailReplacement.NO_REPLACEMENT);
+ }
+ else if ("mailto-name".equalsIgnoreCase(option[1])) {
+ AuthorTaglet.setEmailReplacementType(AuthorTaglet.EmailReplacement.MAILTO_NAME);
+ }
+ else if ("name-mailto-address".equalsIgnoreCase(option[1])) {
+ AuthorTaglet.setEmailReplacementType(AuthorTaglet.EmailReplacement.NAME_MAILTO_ADDRESS);
+ }
+ else if ("name-mangled-address".equalsIgnoreCase(option[1])) {
+ AuthorTaglet.setEmailReplacementType(AuthorTaglet.EmailReplacement.NAME_MANGLED_ADDRESS);
+ }
+ else {
+ printError("Invalid value for option '-authortag-email'. Allowed values are:"
+ + " no-replace, mailto-name, name-mailto-address, name-mangled-address.");
+ return false;
+ }
+ }
+ else if ("-mailmangledot".equals(optionTag)) {
+ AuthorTaglet.setDotReplacement(option[1]);
+ }
+ else if ("-mailmangleat".equals(optionTag)) {
+ AuthorTaglet.setAtReplacement(option[1]);
+ }
+ else if ("-docfilessubdirs".equals(optionTag)) {
+ docFilesSubdirsEnabled = true;
+ }
+ else if ("-excludedocfilessubdir".equals(optionTag)) {
+ StringTokenizer st = new StringTokenizer(option[1]);
+ while (st.hasMoreTokens()) {
+ excludeDocFilesSubDirs.add(st.nextToken());
+ }
+ }
+ else if ("-nonavbar".equals(optionTag)) {
+ docTransletOptions.nonavbar = true;
+ }
+ else if ("-noindex".equals(optionTag)) {
+ docTransletOptions.noindex = true;
+ }
+ else if ("-notree".equals(optionTag)) {
+ docTransletOptions.notree = true;
+ }
+ else if ("-nocomment".equals(optionTag)) {
+ docTransletOptions.nocomment = true;
+ }
+ else if ("-nohelp".equals(optionTag)) {
+ docTransletOptions.nohelp = true;
+ }
+ else if ("-splitindex".equals(optionTag)) {
+ docTransletOptions.splitindex = true;
+ }
+ else if ("-linksource".equals(optionTag)) {
+ docTransletOptions.linksource = true;
+ }
+ else if ("-windowtitle".equals(optionTag)) {
+ docTransletOptions.windowtitle = option[1];
+ }
+ else if ("-helpfile".equals(optionTag)) {
+ docTransletOptions.helpfile = new File(option[1]).toURL().toString();
+ }
+ else if ("-stylesheetfile".equals(optionTag)) {
+ docTransletOptions.stylesheetfile = new File(option[1]).toURL().toString();
+ }
+ else if ("-header".equals(optionTag)) {
+ docTransletOptions.header = option[1];
+ }
+ else if ("-footer".equals(optionTag)) {
+ docTransletOptions.footer = option[1];
+ }
+ else if ("-bottom".equals(optionTag)) {
+ docTransletOptions.bottom = option[1];
+ }
+ else if ("-doctitle".equals(optionTag)) {
+ docTransletOptions.doctitle = option[1];
+ }
+ else if ("-nodeprecatedlist".equals(optionTag)) {
+ docTransletOptions.nodeprecatedlist = true;
+ }
+ else if ("-uses".equals(optionTag)) {
+ docTransletOptions.uses = true;
+ }
+ else if ("-group".equals(optionTag)) {
+ if (!processGroupOption(option[1], option[2])) {
+ printError("Invalid package wildcard list in -group option \"" + option[1] + "\" " + option[2]);
+ return false;
+ }
+ }
+ else if ("-tag".equals(optionTag)) {
+ String tagSpec = option[1];
+ boolean validTagSpec = false;
+ int ndx1 = tagSpec.indexOf(':');
+ if (ndx1 < 0) {
+ Taglet taglet = (Taglet)tagletMap.get(tagSpec);
+ if (null == taglet) {
+ printError("There is no standard tag '" + tagSpec + "'.");
+ }
+ else {
+ if (mentionedTags.contains(taglet)) {
+ printError("Tag '" + tagSpec + "' has been added or moved before.");
+ }
+ else {
+ mentionedTags.add(taglet);
+
+ // re-append taglet
+ tagletMap.remove(tagSpec);
+ tagletMap.put(tagSpec, taglet);
+ }
+ }
+ }
+ else {
+ int ndx2 = tagSpec.indexOf(':', ndx1 + 1);
+ if (ndx2 > ndx1 && ndx2 < tagSpec.length() - 1) {
+ String tagName = tagSpec.substring(0, ndx1);
+ String tagHead = null;
+ if (tagSpec.charAt(ndx2 + 1) == '\"') {
+ if (tagSpec.charAt(tagSpec.length() - 1) == '\"') {
+ tagHead = tagSpec.substring(ndx2 + 2, tagSpec.length() - 1);
+ validTagSpec = true;
+ }
+ }
+ else {
+ tagHead = tagSpec.substring(ndx2 + 1);
+ validTagSpec = true;
+ }
+
+ boolean tagScopeOverview = false;
+ boolean tagScopePackages = false;
+ boolean tagScopeTypes = false;
+ boolean tagScopeConstructors = false;
+ boolean tagScopeMethods = false;
+ boolean tagScopeFields = false;
+ boolean tagDisabled = false;
+
+ tag_option_loop:
+ for (int n=ndx1+1; n<ndx2; ++n) {
+ switch (tagSpec.charAt(n)) {
+ case 'X':
+ tagDisabled = true;
+ break;
+ case 'a':
+ tagScopeOverview = true;
+ tagScopePackages = true;
+ tagScopeTypes = true;
+ tagScopeConstructors = true;
+ tagScopeMethods = true;
+ tagScopeFields = true;
+ break;
+ case 'o':
+ tagScopeOverview = true;
+ break;
+ case 'p':
+ tagScopePackages = true;
+ break;
+ case 't':
+ tagScopeTypes = true;
+ break;
+ case 'c':
+ tagScopeConstructors = true;
+ break;
+ case 'm':
+ tagScopeMethods = true;
+ break;
+ case 'f':
+ tagScopeFields = true;
+ break;
+ default:
+ validTagSpec = false;
+ break tag_option_loop;
+ }
+ }
+
+ if (validTagSpec) {
+ GenericTaglet taglet
+ = new GenericTaglet(tagName,
+ tagHead,
+ tagScopeOverview,
+ tagScopePackages,
+ tagScopeTypes,
+ tagScopeConstructors,
+ tagScopeMethods,
+ tagScopeFields);
+ taglet.setTagletEnabled(!tagDisabled);
+ taglet.register(tagletMap);
+ mentionedTags.add(taglet);
+ }
+ }
+ }
+ if (!validTagSpec) {
+ printError("Value for option -tag must be in format \"<tagname>:Xaoptcmf:<taghead>\".");
+ }
+ }
+ }
+
+ // Use current directory if target directory hasn't been set.
+ if (null == targetDirectory) {
+ targetDirectory = new File(System.getProperty("user.dir"));
+ }
+ if (null != targetContext) {
+ targetContext.setTargetDirectory(targetDirectory);
+ }
+
+ // It is illegal to specify targets AND -xmlonly.
+
+ if (xmlOnly && targets.size() > 0) {
+
+ printError("You can only specify one of -xmlonly and a target format.");
+ return false;
+ }
+
+ // If no target was specified and XML only was not
+ // requested, use HTML as default target.
+
+ if (!xmlOnly && targets.size() == 0) {
+ targets.add(targetContext = htmlTargetContext);
+ }
+
+ // Set the same target directory for all output.
+
+ // FIXME: Allow separate target directories for different
+ // output formats.
+
+ for (Iterator it = targets.iterator(); it.hasNext(); ) {
+ TargetContext t = (TargetContext)it.next();
+ t.setTargetDirectory(targetDirectory);
+ }
+
+ // Create temporary directory if necessary
+
+ if (xmlOnly) {
+
+ xmlTargetDirectory = targetDirectory;
+ }
+ else {
+
+ File workingTopDirectory = new File(workingPath);
+
+ workingDirectory = new File(workingTopDirectory, "gjdoc.tmp."+System.currentTimeMillis());
+
+ if (!workingDirectory.mkdir()) {
+ printError("Cannot create temporary directory at "+System.getProperty("java.io.tmpdir"));
+ return false;
+ }
+
+ File xmlTempDirectory = new File(workingDirectory, "xmloutput");
+
+ if (!xmlTempDirectory.mkdir()) {
+ printError("Cannot create temporary directory for XML output at "+System.getProperty("java.io.tmpdir"));
+ return false;
+ }
+
+ xmlTargetDirectory = xmlTempDirectory;
+ }
+
+ // Create target directory if necessary
+
+ if (!targetDirectory.exists()) {
+ printNotice("Creating destination directory: \""
+ + targetDirectory + "\"");
+ if (!targetDirectory.mkdirs()) {
+ printError("Failed to create destination directory \""
+ + targetDirectory + "\"");
+ return false;
+ }
+ }
+
+ // Check for deprecation
+
+ boolean hasDeprecatedClasses = false;
+ boolean hasDeprecatedInterfaces = false;
+ boolean hasDeprecatedExceptions = false;
+ boolean hasDeprecatedErrors = false;
+ boolean hasDeprecatedMethods = false;
+ boolean hasDeprecatedFields = false;
+
+ {
+ ClassDoc[] classes = rootDoc.classes();
+ for (int i = 0, ilim = classes.length; i < ilim; ++ i) {
+ ClassDoc c = classes[i];
+ Tag[] deprecatedTags = c.tags("deprecated");
+ if (null != deprecatedTags && 0 != deprecatedTags.length) {
+ if (c.isInterface()) {
+ hasDeprecatedInterfaces = true;
+ }
+ else if (c.isException()) {
+ hasDeprecatedExceptions = true;
+ }
+ else if (c.isError()) {
+ hasDeprecatedErrors = true;
+ }
+ else /*if (c.isOrdinaryClass())*/ {
+ hasDeprecatedClasses = true;
+ }
+ }
+
+ MethodDoc[] methods = c.methods();
+ for (int j = 0, jlim = methods.length; j < jlim; ++ j) {
+ MethodDoc m = methods[j];
+ deprecatedTags = m.tags("deprecated");
+ if (null != deprecatedTags && 0 != deprecatedTags.length) {
+ hasDeprecatedMethods = true;
+ }
+ }
+
+ FieldDoc[] fields = c.fields();
+ for (int j = 0, jlim = fields.length; j < jlim; ++ j) {
+ FieldDoc f = fields[j];
+ deprecatedTags = f.tags("deprecated");
+ if (null != deprecatedTags && 0 != deprecatedTags.length) {
+ hasDeprecatedFields = true;
+ }
+ }
+ }
+ }
+
+ htmlRepairer = new HtmlRepairer(rootDoc, noHTMLWarn, noEmailWarn,
+ currentClass, currentMember,
+ false);
+
+ collectUsage();
+
+ // Begin XML generation
+
+ printNotice("Writing XML Index file...");
+
+ // Assign output stream
+
+ setTargetFile("index.xml");
+
+ // Output XML document header
+
+ println(0, "<?xml version=\"1.0\"?>");
+ println("<!DOCTYPE gjdoc SYSTEM \"dtd/gjdoc.dtd\">");
+ println();
+ printOpenTag(0, "rootdoc xmlns=\"http://www.w3.org/TR/REC-html40\" xmlns:gjdoc=\"http://www.gnu.org/software/cp-tools/gjdocxml\"");
+
+ println();
+ println(1, "<!-- Tags from overview page, if available -->");
+
+ if (rootDoc.firstSentenceTags().length > 0) {
+ printOpenTag(2, "firstSentenceTags", false);
+ outputTags(3, rootDoc.firstSentenceTags(), true, CONTEXT_PACKAGE);
+ printCloseTag(0, "firstSentenceTags");
+ }
+
+ if (rootDoc.inlineTags().length > 0) {
+ printOpenTag(2, "inlineTags");
+ outputTags(3, rootDoc.inlineTags(), true, CONTEXT_PACKAGE);
+ printCloseTag(2, "inlineTags");
+ }
+
+ if (null != bottomNote) {
+ printOpenTag(1, "bottomnote");
+ print(bottomNote);
+ printCloseTag(1, "bottomnote");
+ }
+
+ if (null != title) {
+ printOpenTag(1, "title");
+ println(2, title);
+ printCloseTag(1, "title");
+ }
+
+ printOpenTag(1, "created");
+ println(2, DateFormat.getDateInstance(DateFormat.LONG, Locale.US).format(new java.util.Date()));
+ printCloseTag(1, "created");
+
+ if (hasDeprecatedClasses) printAtomTag(1, "hasDeprecatedClasses");
+ if (hasDeprecatedInterfaces) printAtomTag(1, "hasDeprecatedInterfaces");
+ if (hasDeprecatedExceptions) printAtomTag(1, "hasDeprecatedExceptions");
+ if (hasDeprecatedErrors) printAtomTag(1, "hasDeprecatedErrors");
+ if (hasDeprecatedMethods) printAtomTag(1, "hasDeprecatedMethods");
+ if (hasDeprecatedFields) printAtomTag(1, "hasDeprecatedFields");
+
+ // Output summary of all classes specified on command line
+
+ println();
+ println(1, "<!-- Classes specified by user on command line -->");
+ ClassDoc[] specifiedClasses = rootDoc.specifiedClasses();
+ for (int i=0, ilim=specifiedClasses.length; i<ilim; ++i) {
+ ClassDoc sc = specifiedClasses[i];
+ printAtomTag(1, "specifiedclass fqname=\""+sc.qualifiedName()+"\" name=\""+sc.name()+"\"");
+ }
+ specifiedClasses = null;
+
+ // Output summary of all packages specified on command line
+
+ println();
+ println(1, "<!-- Packages specified by user on command line -->");
+ PackageDoc[] specifiedPackages = rootDoc.specifiedPackages();
+ for (int i=0, ilim=specifiedPackages.length; i<ilim; ++i) {
+ PackageDoc sp = specifiedPackages[i];
+ printAtomTag(1, "specifiedpackage name=\""+sp.name()+"\"");
+ }
+ specifiedPackages = null;
+
+ // Output package group information specified on the
+ // command line
+
+ println();
+ println(1, "<!-- Package groups specified by user on command line -->");
+ {
+ Iterator packageGroupIt = packageGroups.iterator();
+ while (packageGroupIt.hasNext()) {
+ PackageGroup packageGroup = (PackageGroup)packageGroupIt.next();
+ SortedSet groupedPackages = packageGroup.getPackages();
+ if (groupedPackages.isEmpty()) {
+ printWarning("Package group named '"
+ + packageGroup.getName() + "' didn't match any packages.");
+ }
+ else {
+ printOpenTag(1, "packagegroup name=\"" + packageGroup.getName() + "\"");
+ Iterator groupedPackageIt = groupedPackages.iterator();
+ while (groupedPackageIt.hasNext()) {
+ PackageDoc groupedPackageDoc = (PackageDoc)groupedPackageIt.next();
+ printAtomTag(2, "package name=\"" + groupedPackageDoc.name() + "\"");
+ }
+ printCloseTag(1, "packagegroup");
+ }
+ }
+ packageGroups = null;
+ }
+
+ // Output information on all packages for which documentation
+ // has been made available via the Doclet API
+
+ println();
+ println(1, "<!-- Documentation for all packages -->");
+ PackageDoc[] packages = rootDoc.specifiedPackages();
+ for (int i=0, ilim=packages.length; i<ilim; ++i) {
+ PackageDoc c = packages[i];
+ outputPackageDoc(c);
+ }
+ packages = null;
+
+ // Output brief summary on all classes for which documentation
+ // has been made available via the Doclet API.
+ //
+ // While this is redundant, it can speed up XSLT
+ // processing by orders of magnitude
+
+ println();
+ println(1, "<!-- Brief summary for all classes -->");
+ ClassDoc[] sumclasses = rootDoc.classes();
+ for (int i=0, ilim=sumclasses.length; i<ilim; ++i) {
+ ClassDoc c = sumclasses[i];
+ outputClassDocSummary(c);
+ }
+ sumclasses = null;
+
+ // Output closing tag, finish output stream
+
+ println();
+ printCloseTag(0, "rootdoc");
+
+ closeTargetFile();
+
+ createIndexByName();
+
+
+
+ // Output information on all classes for which documentation
+ // has been made available via the Doclet API
+
+ println();
+ println(1, "<!-- Documentation for all classes -->");
+ ClassDoc[] classes = rootDoc.classes();
+ String prevPackageName = null;
+ for (int i = 0, ilim = classes.length; i < ilim; ++ i) {
+ ClassDoc c = classes[i];
+
+ if (isVerbose()) {
+ printNotice("Writing XML information for "+c.qualifiedName()+"...");
+ }
+ else {
+ String packageName = c.containingPackage().name();
+ if (null == prevPackageName || !packageName.equals(prevPackageName)) {
+ printNotice("Writing XML information for "+packageName+"...");
+ prevPackageName = packageName;
+ }
+ }
+
+ setTargetFile(c.qualifiedName().replace('/','.')+".xml");
+
+ println("<?xml version=\"1.0\"?>");
+ println("<!DOCTYPE gjdoc SYSTEM \"dtd/gjdoc.dtd\">");
+
+ outputClassDoc(c);
+
+ closeTargetFile();
+ }
+ classes = null;
+ }
+
+ // Copy DTD files to temporary directory
+
+ // FIXME: try to solve this via jar: URLs. but this will
+ // probably break libxmlj compatibility (?)
+
+ String[] resources = new String[] {
+ "gjdoc.dtd",
+ "gjdoc-alphaindex.dtd",
+ "dbcentx.mod",
+ "ent/iso-amsa.ent",
+ "ent/iso-amsb.ent",
+ "ent/iso-amsc.ent",
+ "ent/iso-amsn.ent",
+ "ent/iso-amso.ent",
+ "ent/iso-amsr.ent",
+ "ent/iso-box.ent",
+ "ent/iso-cyr1.ent",
+ "ent/iso-cyr2.ent",
+ "ent/iso-dia.ent",
+ "ent/iso-grk1.ent",
+ "ent/iso-grk2.ent",
+ "ent/iso-grk3.ent",
+ "ent/iso-grk4.ent",
+ "ent/iso-lat1.ent",
+ "ent/iso-lat2.ent",
+ "ent/iso-num.ent",
+ "ent/iso-pub.ent",
+ "ent/iso-tech.ent",
+ };
+
+ File tempDtdDirectory = new File(xmlTargetDirectory, "dtd");
+ File tempDtdEntDirectory = new File(tempDtdDirectory, "ent");
+
+ if ((tempDtdDirectory.exists() || tempDtdDirectory.mkdir())
+ && (tempDtdEntDirectory.exists() || tempDtdEntDirectory.mkdir())) {
+ for (int i = 0; i < resources.length; ++ i) {
+ copyResourceToFile("/dtd/" + resources[i],
+ new File(tempDtdDirectory, resources[i]));
+ }
+ }
+ else {
+ printError("Cannot create temporary directories for DTD data at " + tempDtdDirectory);
+ return false;
+ }
+
+ // Copy package data-dir directory
+
+ {
+ PackageDoc[] packages = rootDoc.specifiedPackages();
+ for (int i=0, ilim=packages.length; i<ilim; ++i) {
+ PackageDoc c = packages[i];
+ if (c instanceof GjdocPackageDoc) {
+ copyPackageDataDir((GjdocPackageDoc)c);
+ }
+ }
+ }
+
+ // All information has been output. Apply stylesheet if given.
+
+ gnu.classpath.tools.gjdoc.Main.releaseRootDoc();
+
+ this.currentClass = null;
+ this.currentMember = null;
+ this.currentExecMember = null;
+
+ System.gc();
+
+ // From this point we are only operating on files, so we don't
+ // need this anymore and can free up some memory
+
+ for (Iterator it = targets.iterator(); it.hasNext(); ) {
+
+ TargetContext target = (TargetContext)it.next();
+
+ // We have XSLT postprocessing, run DocTranslet.
+
+ //DocTranslet docTranslet = DocTranslet.fromClasspath("/doctranslets/html/gjdoc.xsl");
+
+ //docTranslet.setOptions(docTransletOptions);
+
+ target.getDocTranslet().setOptions(docTransletOptions);
+
+ target.getDocTranslet().apply(xmlTargetDirectory,
+ target.getTargetDirectory(),
+ rootDoc);
+ }
+
+ // Done
+
+ targets = null;
+
+ System.gc();
+ Runtime.getRuntime().runFinalization();
+
+ return true;
+ }
+ catch (Exception e) {
+
+ // Something went wrong. Report to stderr and pass error to
+ // Javadoc Reporter
+
+ e.printStackTrace();
+ printError(e.toString());
+
+ Throwable rootCause = e.getCause();
+ if (null != rootCause) {
+ while (null != rootCause.getCause()) {
+ rootCause = rootCause.getCause();
+ }
+ System.err.println("Root cause:");
+ rootCause.printStackTrace();
+ }
+
+ return false;
+ }
+ finally {
+
+ // In any case, delete the working directory if we created one
+
+ if (null != workingDirectory) {
+
+ if (!deleteRecursive(workingDirectory)) {
+ printWarning("Could not delete temporary directory at "+workingDirectory);
+ }
+ }
+
+ printNotice("Done.");
+ }
+ }
+
+ /**
+ * Recursively delete the specified directory and its contents,
+ * like <code>rm -Rf directory</code>
+ *
+ * @return <code>true</code> on success
+ */
+ private static boolean deleteRecursive(File directory) {
+
+ boolean success = true;
+
+ File[] files = directory.listFiles();
+
+ for (int i=0, ilim=files.length; i<ilim; ++i) {
+
+ File file = files[i];
+
+ if (file.isDirectory()) {
+
+ success = deleteRecursive(file) && success;
+ }
+ else {
+
+ success = file.delete() && success;
+ }
+ }
+
+ return directory.delete() && success;
+ }
+
+ /**
+ * Prints a string to stdout and appends a newline. Convenience
+ * method.
+ */
+ protected void println(String str) {
+ out.println(str);
+ }
+
+ /**
+ * Prints a string to stdout without appending a newline.
+ * Convenience method.
+ */
+ protected void print(String str) {
+ out.print(str);
+ }
+
+ /**
+ * In standard mode, prints an empty line to stdout.
+ * In thight mode, nothing happens.
+ * Convenience method.
+ */
+ protected void println() {
+ if (!compress) {
+ out.println();
+ }
+ }
+
+ /**
+ * In standard mode, prints the given text indented to stdout and appends newline.
+ * In tight mode, doesn't print indentation or newlines.
+ */
+ protected void print(int indentLevel, String msg) {
+ if (compress) {
+ out.print(msg);
+ }
+ else {
+ StringBuffer indentation = new StringBuffer();
+ for (int i=0; i<indentLevel*indentStep; ++i) {
+ indentation.append(' ');
+ }
+ out.print(indentation+msg);
+ }
+ }
+
+ /**
+ * In tight mode, prints a message at a given indentation level.
+ * In standard mode, appends a newline in addition.
+ */
+ protected void println(int indentLevel, String msg) {
+ print(indentLevel, msg);
+ if (!compress) out.println();
+ }
+
+ /**
+ * Prints an atom tag at the given indentation level.
+ */
+ protected void printAtomTag(int level, String tag) {
+ println(level, "<"+tagPrefix+":"+replaceCharsInTag(tag)+"/>");
+ }
+
+ /**
+ * Prints an open tag at the given indentation level.
+ */
+ protected void printOpenTag(int level, String tag) {
+ printOpenTag(level, replaceCharsInTag(tag), true);
+ }
+
+ /**
+ * Prints an open tag at the given indentation level and
+ * conditionally appends a newline (if not in tight mode).
+ */
+ protected void printOpenTag(int level, String tag, boolean appendNewline) {
+ if (appendNewline && !compress) {
+ println(level, "<"+tagPrefix+":"+replaceCharsInTag(tag)+">");
+ }
+ else {
+ print(level, "<"+tagPrefix+":"+replaceCharsInTag(tag)+">");
+ }
+ }
+
+ /**
+ * Prints a close tag at the given indentation level.
+ */
+ protected void printCloseTag(int level, String tag) {
+ printCloseTag(level, tag, true);
+ }
+
+ /**
+ * Prints a close tag at the given indentation level and
+ * conditionally appends a newline (if not in tight mode).
+ */
+ protected void printCloseTag(int level, String tag, boolean appendNewline) {
+ if (appendNewline && !compress) {
+ println(level, "</"+tagPrefix+":"+replaceCharsInTag(tag)+">");
+ }
+ else {
+ print(level, "</"+tagPrefix+":"+replaceCharsInTag(tag)+">");
+ }
+ }
+
+ public static int optionLength(String option) {
+ if ("-d".equals(option)) return 2;
+ else if ("-fixhtml".equals(option)) return 1;
+ else if ("-compress".equals(option)) return 1;
+ else if ("-nohtmlwarn".equals(option)) return 1;
+ else if ("-noemailwarn".equals(option)) return 1;
+ else if ("-indentstep".equals(option)) return 2;
+ else if ("-xslsheet".equals(option)) return 2;
+ else if ("-xsltdriver".equals(option)) return 2;
+ else if ("-postprocess".equals(option)) return 2;
+ else if ("-genhtml".equals(option)) return 1;
+ else if ("-geninfo".equals(option)) return 1;
+ else if ("-gendocbook".equals(option)) return 1;
+ else if ("-xmlonly".equals(option)) return 1;
+ else if ("-bottomnote".equals(option)) return 2;
+ else if ("-workpath".equals(option)) return 2;
+ else if ("-title".equals(option)) return 2;
+ else if ("-tagletpath".equals(option)) return 2;
+ else if ("-taglet".equals(option)) return 2;
+ else if ("-authormail".equals(option)) return 2;
+ else if ("-mailmangledot".equals(option)) return 2;
+ else if ("-mailmangleat".equals(option)) return 2;
+ else if ("-noindex".equals(option)) return 1;
+ else if ("-nocomment".equals(option)) return 1;
+ else if ("-notree".equals(option)) return 1;
+ else if ("-nohelp".equals(option)) return 1;
+ else if ("-nonavbar".equals(option)) return 1;
+ else if ("-splitindex".equals(option)) return 1;
+ else if ("-author".equals(option)) return 1;
+ else if ("-version".equals(option)) return 1;
+ else if ("-nosince".equals(option)) return 1;
+ else if ("-nodeprecated".equals(option)) return 1;
+ else if ("-linksource".equals(option)) return 1;
+ else if ("-windowtitle".equals(option)) return 2;
+ else if ("-helpfile".equals(option)) return 2;
+ else if ("-stylesheetfile".equals(option)) return 2;
+ else if ("-tag".equals(option)) return 2;
+ else if ("-header".equals(option)) return 2;
+ else if ("-footer".equals(option)) return 2;
+ else if ("-bottom".equals(option)) return 2;
+ else if ("-doctitle".equals(option)) return 2;
+ else if ("-nodeprecatedlist".equals(option)) return 1;
+ else if ("-uses".equals(option)) return 1;
+ else if ("-group".equals(option)) return 3;
+
+ else return -1;
+ }
+
+ public static boolean validOptions(String[][] options) {
+ return true;
+ }
+
+
+ /**
+ * Workaround for non well-formed comments: fix tag contents
+ * by replacing <code>&lt;</code> with <code>&amp;lt;</code>,
+ * <code>&gt;</code> with <code>&amp;gt;</code> and
+ * <code>&amp;</code> with <code>&amp;amp;</code>.
+ *
+ * @param tagContent String to process
+ *
+ * @return given String with all special characters replaced by
+ * HTML entities.
+ */
+ private static String replaceCharsInTag(String tagContent) {
+ return
+ replaceString(
+ replaceString(
+ replaceString(
+ tagContent,
+ "<", "&lt;"
+ ),
+ ">", "&gt;"
+ ),
+ "&", "&amp;"
+ );
+ }
+
+ /**
+ * Replaces all occurences of string <code>needle</code> within string
+ * <code>haystack</code> by string <code>replacement</code>.
+ *
+ * @param haystack The string to search and replace in.
+ * @param needle The string which is searched for.
+ * @param replacement The string by which every occurence of <code>needle</code> is replaced.
+ */
+ private static String replaceString(String haystack, String needle, String replacement) {
+ int ndx = haystack.indexOf(needle);
+ if (ndx<0)
+ return haystack;
+ else
+ return haystack.substring(0, ndx) + replacement
+ + replaceString(haystack.substring(ndx+needle.length()), needle, replacement);
+ }
+
+ protected void setTargetFile(String filename) throws IOException {
+
+ OutputStream fileOut = new FileOutputStream(new File(xmlTargetDirectory, filename));
+ out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(fileOut, "UTF8")));;
+ }
+
+ protected void closeTargetFile() {
+
+ out.flush();
+ out.close();
+ }
+
+ private String cdata(String str) {
+
+ if (null==str) {
+ return str;
+ } // end of if ((null==str)
+
+ StringBuffer rc = new StringBuffer();
+ for (int i=0; i<str.length(); ++i) {
+ char c = str.charAt(i);
+ if (c==0x09 || c==0x0a || c==0x0d || (c>=0x20 && c<=0xd7ff) || (c>=0xe000 && c<=0xfffd) || (c>=0x10000 && c<=0x10ffff)) {
+ rc.append(c);
+ }
+ else {
+ printWarning("Invalid Unicode character 0x"+Integer.toString(c, 16)+" in javadoc markup has been stripped.");
+ } // end of else
+
+ }
+ return rc.toString();
+ }
+
+ static void copyResourceToFile(String resourceName, File target) throws IOException {
+
+ InputStream in = Driver.class.getResourceAsStream(resourceName);
+
+ if (null != in) {
+
+ FileOutputStream out = new FileOutputStream(target);
+ int size;
+ byte[] buffer = new byte[512];
+ while ((size = in.read(buffer)) >= 0) {
+ out.write(buffer, 0, size);
+ }
+ out.close();
+ }
+ else {
+
+ throw new IOException("Can't find resource named "+resourceName);
+ }
+ }
+
+ private void printError(String error) {
+ if (null != rootDoc) {
+ rootDoc.printError(error);
+ }
+ else {
+ System.err.println("ERROR: "+error);
+ }
+ }
+
+ private void printWarning(String warning) {
+ if (null != rootDoc) {
+ rootDoc.printWarning(warning);
+ }
+ else {
+ System.err.println("WARNING: "+warning);
+ }
+ }
+
+ private void printNotice(String notice) {
+ if (null != rootDoc) {
+ rootDoc.printNotice(notice);
+ }
+ else {
+ System.err.println(notice);
+ }
+ }
+
+ /**
+ * Copy the contents of the input directory to the output
+ * directory. The output directory must exist.
+ */
+ private void copyPackageDataDir(GjdocPackageDoc packageDoc) throws IOException {
+ File docFilesSourceDirectory
+ = new File(packageDoc.packageDirectory(), "doc-files");
+ File docFilesTargetDirectory
+ = new File(this.targetDirectory,
+ packageDoc.name().replace('.', File.separatorChar));
+ if (docFilesSourceDirectory.exists()) {
+ printNotice("Copying files from " + docFilesSourceDirectory);
+ copyDirectory(docFilesSourceDirectory, docFilesTargetDirectory,
+ docFilesSubdirsEnabled,
+ excludeDocFilesSubDirs);
+ }
+ }
+
+ /**
+ * Recursively copy the contents of the input directory to the
+ * output directory. The output directory must exist.
+ */
+ private static void copyDirectory(File sourceDir, File targetDir,
+ boolean recursive,
+ Set excludeDirs) throws IOException {
+ if (!targetDir.exists() && !targetDir.mkdirs()) {
+ throw new IOException("Cannot create directory " + targetDir);
+ }
+
+ File[] sourceFiles = sourceDir.listFiles();
+ for (int i=0; i<sourceFiles.length; ++i) {
+ if (sourceFiles[i].isDirectory()) {
+ if (recursive && (null == excludeDirs
+ || !excludeDirs.contains(sourceFiles[i].getName()))) {
+ File targetSubDir = new File(targetDir,
+ sourceFiles[i].getName());
+ if (targetSubDir.exists() || targetSubDir.mkdir()) {
+ copyDirectory(sourceFiles[i], targetSubDir, recursive, null);
+ }
+ else {
+ throw new IOException("Cannot create directory " + targetSubDir);
+ }
+ }
+ }
+ else {
+ copyFile(sourceFiles[i], new File(targetDir, sourceFiles[i].getName()));
+ }
+ }
+ }
+
+ /**
+ * Copy the contents of the input file to the output file. The
+ * output file's parent directory must exist.
+ */
+ private static void copyFile(File sourceFile, File targetFile) throws IOException {
+
+ InputStream in = new FileInputStream(sourceFile);
+ OutputStream out = new FileOutputStream(targetFile);
+ int nread;
+ byte[] buf = new byte[512];
+ while ((nread = in.read(buf)) >= 0) {
+ out.write(buf, 0, nread);
+ }
+ in.close();
+ out.close();
+ }
+
+ private void createIndexByName() throws IOException {
+ // Create index
+
+ // Collect index
+
+ Map indexMap = new TreeMap(new Comparator() {
+ public int compare(Object o1, Object o2) {
+ return o1.toString().toLowerCase().compareTo(o2.toString().toLowerCase());
+ }
+ });
+
+ // Add packages to index
+
+ PackageDoc[] packages = rootDoc.specifiedPackages();
+ for (int i=0, ilim=packages.length; i<ilim; ++i) {
+ PackageDoc c = packages[i];
+ indexMap.put(c.name(), c);
+ }
+
+ // Add classes, fields and methods to index
+
+ ClassDoc[] sumclasses = rootDoc.classes();
+ for (int i=0, ilim=sumclasses.length; i<ilim; ++i) {
+ ClassDoc c = sumclasses[i];
+ if (null == c.containingClass()) {
+ indexMap.put(c.name(), c);
+ }
+ else {
+ indexMap.put(c.name().substring(c.containingClass().name().length() + 1), c);
+ }
+ FieldDoc[] fields = c.fields();
+ for (int j=0, jlim=fields.length; j<jlim; ++j) {
+ indexMap.put(fields[j].name(), fields[j]);
+ }
+ MethodDoc[] methods = c.methods();
+ for (int j=0, jlim=methods.length; j<jlim; ++j) {
+ MethodDoc method = methods[j];
+ StringBuffer signature = new StringBuffer();
+ signature.append(method.name());
+ signature.append('(');
+ Parameter[] parameters = method.parameters();
+ for (int k=0, klim=parameters.length; k<klim; ++k) {
+ if (k > 0) {
+ signature.append(", ");
+ }
+ signature.append(parameters[k].typeName());
+ }
+ signature.append(')');
+ indexMap.put(signature.toString(), method);
+ }
+ }
+
+ // Assign output stream
+
+ setTargetFile("alphaindex.xml");
+
+ // Output XML document header
+
+ println(0, "<?xml version=\"1.0\"?>");
+ println("<!DOCTYPE gjdoc SYSTEM \"dtd/gjdoc-alphaindex.dtd\">");
+ println();
+ printOpenTag(0, "alphaindex xmlns=\"http://www.w3.org/TR/REC-html40\" xmlns:gjdoc=\"http://www.gnu.org/software/cp-tools/gjdocxml\"");
+
+ Iterator it = indexMap.keySet().iterator();
+
+ char previousCategoryLetter = '\0';
+ boolean categoryOpen = false;
+
+ while (it.hasNext()) {
+ String key = (String)it.next();
+ Doc entry = (Doc)indexMap.get(key);
+
+ char firstChar = Character.toUpperCase(key.charAt(0));
+ if (firstChar != previousCategoryLetter) {
+ if (categoryOpen) {
+ printCloseTag(1, "category");
+ }
+ printOpenTag(1, "category letter=\"" + firstChar + "\"");
+ categoryOpen = true;
+ previousCategoryLetter = firstChar;
+ }
+
+ printOpenTag(2, "entry name=\"" + key + "\"");
+ if (entry instanceof PackageDoc) {
+ printAtomTag(3, "isPackage");
+ }
+ else if (entry instanceof ClassDoc) {
+ printAtomTag(3, "isClass");
+ ClassDoc centry = (ClassDoc)entry;
+ currentClass = centry;
+ printAtomTag(3, "containingPackage name=\"" + centry.containingPackage().name() + "\"");
+ if (null != centry.containingClass()) {
+ printAtomTag(3, "containingClass name=\"" + centry.containingClass().name() + "\"");
+ }
+ if (centry.isInterface()) {
+ printAtomTag(3, "isInterface");
+ }
+ if (centry.isException()) {
+ printAtomTag(3, "isException");
+ }
+ if (centry.isError()) {
+ printAtomTag(3, "isError");
+ }
+ if (centry.isOrdinaryClass()) {
+ printAtomTag(3, "isOrdinaryClass");
+ }
+ }
+ else if (entry instanceof ProgramElementDoc) {
+ ProgramElementDoc pentry = (ProgramElementDoc)entry;
+ currentClass = pentry.containingClass();
+ printAtomTag(3, "containingPackage name=\"" + pentry.containingPackage().name() + "\"");
+ printAtomTag(3, "containingClass name=\"" + pentry.containingClass().name() + "\"");
+ if (pentry.isMethod()) {
+ printAtomTag(3, "isMethod");
+ ExecutableMemberDoc mentry = (ExecutableMemberDoc)pentry;
+ printAtomTag(3, "signature full=\""+mentry.signature()+"\" flat=\""+mentry.flatSignature()+"\"");
+ printAtomTag(3, "method name=\"" + mentry.name() + "\"");
+ }
+ if (pentry.isField()) {
+ printAtomTag(3, "isField");
+ }
+ }
+
+ Tag[] tags = entry.firstSentenceTags();
+ for (int i=0, ilim=tags.length; i<ilim; ++i) {
+ Tag tag = tags[i];
+ if (tag.firstSentenceTags().length>0) {
+ printOpenTag(3, "firstSentenceTags", false);
+ outputTags(4, tag.firstSentenceTags(), false, CONTEXT_TYPE);
+ printCloseTag(3, "firstSentenceTags");
+ }
+ }
+
+
+ printCloseTag(2, "entry");
+ }
+
+ if (categoryOpen) {
+ printCloseTag(1, "category");
+ }
+
+ printCloseTag(0, "alphaindex");
+
+ closeTargetFile();
+ }
+
+ private static class UsageType
+ {
+ public static final UsageType CLASS_DERIVED_FROM = new UsageType("class-derived-from");
+ public static final UsageType FIELD_OF_TYPE = new UsageType("field-of-type");
+ public static final UsageType METHOD_WITH_RETURN_TYPE = new UsageType("method-with-return-type");
+ public static final UsageType METHOD_WITH_PARAMETER_TYPE = new UsageType("method-with-parameter-type");
+ public static final UsageType METHOD_WITH_THROWN_TYPE = new UsageType("method-with-thrown-type");
+ public static final UsageType CONSTRUCTOR_WITH_PARAMETER_TYPE = new UsageType("constructor-with-parameter-type");
+ public static final UsageType CONSTRUCTOR_WITH_THROWN_TYPE = new UsageType("constructor-with-thrown-type");
+ private String id;
+
+ private UsageType(String id)
+ {
+ this.id = id;
+ }
+
+ public String toString() {
+ return "UsageType{id=" + id + "}";
+ }
+
+ public String getId() {
+ return id;
+ }
+ }
+
+ /**
+ * ClassDoc -> (PackageDoc -> (UsageType -> (Set of Doc)))
+ */
+ private Map usedClassToPackagesMap = new HashMap();
+
+ private void addUsedBy(ClassDoc usedClass, UsageType usageType, Doc user, PackageDoc userPackage)
+ {
+ Map packageToUsageTypeMap = (Map)usedClassToPackagesMap.get(usedClass);
+ if (null == packageToUsageTypeMap) {
+ packageToUsageTypeMap = new HashMap();
+ usedClassToPackagesMap.put(usedClass, packageToUsageTypeMap);
+ }
+
+ Map usageTypeToUsersMap = (Map)packageToUsageTypeMap.get(userPackage);
+ if (null == usageTypeToUsersMap) {
+ usageTypeToUsersMap = new HashMap();
+ packageToUsageTypeMap.put(userPackage, usageTypeToUsersMap);
+ }
+
+ Set userSet = (Set)usageTypeToUsersMap.get(usageType);
+ if (null == userSet) {
+ userSet = new TreeSet(); // FIXME: we need the collator from Main here
+ usageTypeToUsersMap.put(usageType, userSet);
+ }
+ userSet.add(user);
+ }
+
+ /**
+ * Create the cross reference database.
+ */
+ private void collectUsage() {
+
+ ClassDoc[] classes = rootDoc.classes();
+ for (int i = 0, ilim = classes.length; i < ilim; ++ i) {
+ ClassDoc clazz = classes[i];
+
+ // classes derived from
+ for (ClassDoc superclass = clazz.superclass(); superclass != null;
+ superclass = superclass.superclass()) {
+ addUsedBy(superclass, UsageType.CLASS_DERIVED_FROM, clazz, clazz.containingPackage());
+ }
+
+ FieldDoc[] fields = clazz.fields();
+ for (int j = 0, jlim = fields.length; j < jlim; ++ j) {
+ FieldDoc field = fields[j];
+
+ // fields of type
+ ClassDoc fieldType = field.type().asClassDoc();
+ if (null != fieldType) {
+ addUsedBy(fieldType, UsageType.FIELD_OF_TYPE,
+ field, clazz.containingPackage());
+ }
+ }
+
+ MethodDoc[] methods = clazz.methods();
+ for (int j = 0, jlim = methods.length; j < jlim; ++ j) {
+ MethodDoc method = methods[j];
+
+ // methods with return type
+
+ ClassDoc returnType = method.returnType().asClassDoc();
+ if (null != returnType) {
+ addUsedBy(returnType, UsageType.METHOD_WITH_RETURN_TYPE,
+ method, clazz.containingPackage());
+ }
+ Parameter[] parameters = method.parameters();
+ for (int k=0; k<parameters.length; ++k) {
+
+ // methods with parameter type
+
+ Parameter parameter = parameters[k];
+ ClassDoc parameterType = parameter.type().asClassDoc();
+ if (null != parameterType) {
+ addUsedBy(parameterType, UsageType.METHOD_WITH_PARAMETER_TYPE,
+ method, clazz.containingPackage());
+ }
+ }
+
+ // methods which throw
+
+ ClassDoc[] thrownExceptions = method.thrownExceptions();
+ for (int k = 0, klim = thrownExceptions.length; k < klim; ++ k) {
+ ClassDoc thrownException = thrownExceptions[k];
+ addUsedBy(thrownException, UsageType.METHOD_WITH_THROWN_TYPE,
+ method, clazz.containingPackage());
+ }
+ }
+
+ ConstructorDoc[] constructors = clazz.constructors();
+ for (int j = 0, jlim = constructors.length; j < jlim; ++ j) {
+
+ ConstructorDoc constructor = constructors[j];
+
+ Parameter[] parameters = constructor.parameters();
+ for (int k = 0, klim = parameters.length; k < klim; ++ k) {
+
+ // constructors with parameter type
+
+ Parameter parameter = parameters[k];
+ ClassDoc parameterType = parameter.type().asClassDoc();
+ if (null != parameterType) {
+ addUsedBy(parameterType, UsageType.CONSTRUCTOR_WITH_PARAMETER_TYPE,
+ constructor, clazz.containingPackage());
+ }
+ }
+
+ // constructors which throw
+
+ ClassDoc[] thrownExceptions = constructor.thrownExceptions();
+ for (int k = 0, klim = thrownExceptions.length; k < klim; ++ k) {
+ ClassDoc thrownException = thrownExceptions[k];
+ addUsedBy(thrownException, UsageType.CONSTRUCTOR_WITH_THROWN_TYPE,
+ constructor, clazz.containingPackage());
+ }
+ }
+ }
+ }
+
+ private void outputUsage(ClassDoc clazz, int level) {
+
+ Map packageToUsageTypeMap = (Map)usedClassToPackagesMap.get(clazz);
+ if (null != packageToUsageTypeMap) {
+ printOpenTag(level, "references");
+
+ Iterator packagesIterator = packageToUsageTypeMap.keySet().iterator();
+
+ while (packagesIterator.hasNext()) {
+ PackageDoc packageDoc = (PackageDoc)packagesIterator.next();
+ printOpenTag(level + 1, "referencing-package name=\"" + packageDoc.name() + "\"");
+ Map usageTypeToUsersMap = (Map)packageToUsageTypeMap.get(packageDoc);
+ Iterator usageTypeIterator = usageTypeToUsersMap.keySet().iterator();
+ while (usageTypeIterator.hasNext()) {
+ UsageType usageType = (UsageType)usageTypeIterator.next();
+ printOpenTag(level + 2, "usage-type id=\"" + usageType.getId() + "\"");
+ Set users = (Set)usageTypeToUsersMap.get(usageType);
+ Iterator userIterator = users.iterator();
+ while (userIterator.hasNext()) {
+ Doc user = (Doc)userIterator.next();
+ if (user instanceof ClassDoc) {
+ printAtomTag(level + 3, "user"
+ + " class=\"" + ((ClassDoc)user).name() + "\"");
+ }
+ else if (user instanceof FieldDoc) {
+ FieldDoc fieldDoc = (FieldDoc)user;
+ printAtomTag(level + 3, "user"
+ + " class=\"" + fieldDoc.containingClass().name() + "\""
+ + " field=\"" + fieldDoc.name() + "\"");
+ }
+ else if (user instanceof MethodDoc) {
+ MethodDoc methodDoc = (MethodDoc)user;
+ printAtomTag(level + 3, "user"
+ + " class=\"" + methodDoc.containingClass().name() + "\""
+ + " method=\"" + methodDoc.name() + "\""
+ + " signature=\"" + methodDoc.signature() + "\""
+ + " flatSignature=\"" + methodDoc.flatSignature() + "\"");
+ }
+ else if (user instanceof ConstructorDoc) {
+ ConstructorDoc constructorDoc = (ConstructorDoc)user;
+ printAtomTag(level + 3, "user"
+ + " class=\"" + constructorDoc.containingClass().name() + "\""
+ + " signature=\"" + constructorDoc.signature() + "\""
+ + " flatSignature=\"" + constructorDoc.flatSignature() + "\"");
+ }
+ }
+ printCloseTag(level +2, "usage-type");
+ }
+ printCloseTag(level + 1, "referencing-package");
+ }
+
+ printCloseTag(level, "references");
+ }
+ }
+
+ private boolean processGroupOption(String groupName, String colonSeparatedPackageList)
+ {
+ try {
+ PackageMatcher packageMatcher = new PackageMatcher();
+
+ StringTokenizer tokenizer = new StringTokenizer(colonSeparatedPackageList, ":");
+ while (tokenizer.hasMoreTokens()) {
+ String packageWildcard = tokenizer.nextToken();
+ packageMatcher.addWildcard(packageWildcard);
+ }
+
+ SortedSet groupPackages = packageMatcher.filter(rootDoc.specifiedPackages());
+
+ packageGroups.add(new PackageGroup(groupName, groupPackages));
+
+ return true;
+ }
+ catch (InvalidPackageWildcardException e) {
+ return false;
+ }
+ }
+
+ private void registerTaglet(Taglet taglet)
+ {
+ tagletMap.put(taglet.getName(), taglet);
+ }
+
+ private boolean isVerbose()
+ {
+ return false;
+ }
+}
diff --git a/tools/gnu/classpath/tools/doclets/xmldoclet/Driver1_4.java b/tools/gnu/classpath/tools/doclets/xmldoclet/Driver1_4.java
index 95dcb9795..e2297d8e9 100644
--- a/tools/gnu/classpath/tools/doclets/xmldoclet/Driver1_4.java
+++ b/tools/gnu/classpath/tools/doclets/xmldoclet/Driver1_4.java
@@ -1,84 +1,84 @@
-/* gnu.classpath.tools.doclets.xmldoclet.Driver1_4
- Copyright (C) 2001 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
-
-package gnu.classpath.tools.doclets.xmldoclet;
-
-import com.sun.javadoc.*;
-import java.io.IOException;
-
-/**
- * A Doclet which retrieves all information presented by the Doclet
- * API, dumping it to stdout in XML format.
- *
- * Supports Doclet API Version 1.4.
- *
- * @author Julian Scheid
- */
-public class Driver1_4 extends Driver {
-
- /**
- * Official Doclet entry point.
- */
- public static boolean start(RootDoc root) {
-
- // Create a new XmlDoclet instance and delegate control.
- return new Driver1_4().instanceStart(root);
- }
-
- /* since 1.4
- private void outputSourcePosition(int level, SourcePosition sourcePosition) {
- println(level, "<sourceposition"
- + " file=\""+sourcePosition.file().toString()+"\""
- + " line=\""+sourcePosition.line()+"\""
- + " column=\""+sourceposition.column()+"\""
- + "/>");
- }
- */
-
- protected void outputClassDoc(ClassDoc classDoc)
- throws IOException
- {
- super.outputClassDoc(classDoc);
- //outputSourcePosition(level, doc.position());
- }
-
- protected void outputFieldDocBody(int level, FieldDoc fieldDoc) {
- super.outputFieldDocBody(level, fieldDoc);
- //println(level, "<constantValueExpression>"+fieldDoc.constantValueExpression()+"</constantValueExpression>");
- }
-
-}
+/* gnu.classpath.tools.doclets.xmldoclet.Driver1_4
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.doclets.xmldoclet;
+
+import com.sun.javadoc.*;
+import java.io.IOException;
+
+/**
+ * A Doclet which retrieves all information presented by the Doclet
+ * API, dumping it to stdout in XML format.
+ *
+ * Supports Doclet API Version 1.4.
+ *
+ * @author Julian Scheid
+ */
+public class Driver1_4 extends Driver {
+
+ /**
+ * Official Doclet entry point.
+ */
+ public static boolean start(RootDoc root) {
+
+ // Create a new XmlDoclet instance and delegate control.
+ return new Driver1_4().instanceStart(root);
+ }
+
+ /* since 1.4
+ private void outputSourcePosition(int level, SourcePosition sourcePosition) {
+ println(level, "<sourceposition"
+ + " file=\""+sourcePosition.file().toString()+"\""
+ + " line=\""+sourcePosition.line()+"\""
+ + " column=\""+sourceposition.column()+"\""
+ + "/>");
+ }
+ */
+
+ protected void outputClassDoc(ClassDoc classDoc)
+ throws IOException
+ {
+ super.outputClassDoc(classDoc);
+ //outputSourcePosition(level, doc.position());
+ }
+
+ protected void outputFieldDocBody(int level, FieldDoc fieldDoc) {
+ super.outputFieldDocBody(level, fieldDoc);
+ //println(level, "<constantValueExpression>"+fieldDoc.constantValueExpression()+"</constantValueExpression>");
+ }
+
+}
diff --git a/tools/gnu/classpath/tools/doclets/xmldoclet/HtmlRepairer.java b/tools/gnu/classpath/tools/doclets/xmldoclet/HtmlRepairer.java
index f54964447..175d4e864 100644
--- a/tools/gnu/classpath/tools/doclets/xmldoclet/HtmlRepairer.java
+++ b/tools/gnu/classpath/tools/doclets/xmldoclet/HtmlRepairer.java
@@ -1,691 +1,691 @@
-/* gnu.classpath.tools.doclets.xmldoclet.HtmlRepairer.java
- Copyright (C) 2003 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
-
-package gnu.classpath.tools.doclets.xmldoclet;
-
-import java.io.*;
-import java.util.*;
-import com.sun.javadoc.DocErrorReporter;
-import com.sun.javadoc.ClassDoc;
-import com.sun.javadoc.MemberDoc;
-
-/**
- * Provides methods for tidying up HTML source.
- *
- * @author Julian Scheid
- */
-public final class HtmlRepairer {
-
- private static class TagInfo {
-
- private Set parentTags = new HashSet();
-
- public TagInfo(String parentTag) {
- this.parentTags.add(parentTag);
- }
-
- public TagInfo(String[] parentTagArr) {
- for (int i=0; i<parentTagArr.length; ++i) {
- this.parentTags.add(parentTagArr[i]);
- }
- }
-
- public boolean isLegalParentTag(String tag) {
- return this.parentTags.contains(tag);
- }
- }
-
- private DocErrorReporter warningReporter;
- private boolean noWarn;
- private boolean noEmailWarn;
- private ClassDoc contextClass;
- private MemberDoc contextMember;
- private StringBuffer output = new StringBuffer();
- private Stack tagStack = new Stack();
- private boolean isLeadingTag = true;
- private boolean throwAwayLeadingPara = false;
-
- private static Map tagInfoMap;
-
- private static Set noTextParentTags;
-
- static {
- tagInfoMap = new HashMap();
- tagInfoMap.put("li", new TagInfo(new String[] { "ul", "ol", "nl", "menu", "dir" }));
- tagInfoMap.put("td", new TagInfo(new String[] { "tr" }));
- tagInfoMap.put("th", new TagInfo(new String[] { "tr" }));
- tagInfoMap.put("tr", new TagInfo(new String[] { "table" }));
- tagInfoMap.put("dt", new TagInfo(new String[] { "dl" }));
- tagInfoMap.put("dd", new TagInfo(new String[] { "dl" }));
- tagInfoMap.put("param", new TagInfo(new String[] { "applet" }));
-
- String[] noTextParentTagArr = {
- "area", "base", "body", "br", "dd", "dt", "head", "hr", "html",
- "img", "input", "link", "map", "meta", "ol", "optgroup", "param",
- "select", "table", "tbody", "tfoot", "thead", "tr", "ul",
- };
-
- noTextParentTags = new HashSet();
- for (int i=0; i<noTextParentTagArr.length; ++i) {
- noTextParentTags.add(noTextParentTagArr[i]);
- }
- }
-
- public HtmlRepairer(DocErrorReporter warningReporter,
- boolean noWarn, boolean noEmailWarn,
- ClassDoc contextClass, MemberDoc contextMember,
- boolean throwAwayLeadingPara) {
- this.warningReporter = warningReporter;
- this.noWarn = noWarn;
- this.noEmailWarn = noEmailWarn;
- this.contextClass = contextClass;
- this.contextMember = contextMember;
- this.throwAwayLeadingPara = throwAwayLeadingPara;
- }
-
- private static String replaceStr(String haystack, String needle, String replacement) {
- int ndx=haystack.indexOf(needle);
- if (ndx<0)
- return haystack;
- else
- return haystack.substring(0, ndx)+replacement
- + replaceStr(haystack.substring(ndx+needle.length()), needle, replacement);
- }
-
- private void haveText(String text) {
-
- if (isLeadingTag && throwAwayLeadingPara) {
- if (0 != text.trim().length()) {
- isLeadingTag = false;
- }
- }
-
- if (tagStack.isEmpty() || !noTextParentTags.contains(tagStack.peek())) {
-
- text = replaceStr(text, "&lt1", "&lt;1");
- text = replaceStr(text, "&&", "&amp;&amp;");
- text = replaceStr(text, "& ", "&amp; ");
- text = replaceStr(text, "&\t", "&amp;\t");
- text = replaceStr(text, "&\r", "&amp;\r");
- text = replaceStr(text, "&\n", "&amp;\n");
- for (char c='0'; c<='9'; ++c)
- text = replaceStr(text, "&"+c, "&amp;"+c);
- text = replaceStr(text, "\u00a7", "&sect;");
- output.append(text);
- }
- else {
- printWarning("Discarded text in <" + tagStack.peek() + "> element");
- }
- }
-
- private void haveStartOrEndTag(String tag) {
-
- boolean _isLeadingTag = isLeadingTag;
- isLeadingTag = false;
-
- tag = tag.trim();
-
- boolean isEndTag = tag.startsWith("/");
- boolean isAtomTag = tag.endsWith("/");
-
- if (isEndTag && isAtomTag) {
- // got something like '</a/>' which is invalid.
- // suppose a close tag was intended.
- tag = tag.substring(0, tag.length()-1);
- }
-
- if (tag.length() < 1) {
- printWarning("Deleting broken tag");
- return;
- }
-
- String tagName = tag.substring(isEndTag?1:0, isAtomTag?tag.length()-1:tag.length());
- String tagAttributes = "";
-
- for (int i=0; i<tagName.length(); ++i) {
- if (" \t\r\n".indexOf(tagName.charAt(i))>=0) {
- tagAttributes = tagName.substring(i).trim();
- tagName = tagName.substring(0, i);
- break;
- }
- }
-
- if (!isEndTag && tagName.indexOf('@')>0) {
- if (!noEmailWarn) {
- printWarning("Tag looks like email address: <"+tagName+">");
- }
- output.append("&lt;"+tag+"&gt;");
- return;
- }
-
- tagName = tagName.toLowerCase();
-
- if (_isLeadingTag && "p".equals(tagName) && !isEndTag && throwAwayLeadingPara) {
- return;
- }
-
- if ("p".equals(tagName) || "br".equals(tagName) || "hr".equals(tagName)) {
- // throw away </p> and </br>
- if (isEndTag) {
- return;
- }
- // make sure every <p> is a <p/> and every <br> is a <br/>
- else if (!isAtomTag) {
- tag += "/";
- isAtomTag = true;
- }
- }
-
- if (isEndTag) {
-
- // check whether this close tag is on the stack
- // if yes, close all tags up to this tag
- if (tagStack.contains(tagName)) {
- String popped;
- do {
- popped = (String)tagStack.pop();
- if (!popped.equals(tagName))
- printWarning("Inserting '</"+popped+">");
- output.append("</"+popped+">");
- }
- while (!popped.equals(tagName));
- }
- // if not, just throw it away
- else {
- printWarning("Deleting <"+tag+">");
- }
- }
- else {
-
- final int STATE_INITIAL = 1;
- final int STATE_EXPECT_ATTRIBUTENAME = 2;
- final int STATE_UNQUOTED_ATTRIBUTEVALUE = 3;
- final int STATE_SINGLEQUOTE_ATTRIBUTEVALUE = 4;
- final int STATE_DOUBLEQUOTE_ATTRIBUTEVALUE = 5;
- final int STATE_EXPECT_ATTRIBUTEVALUE = 6;
- final int STATE_EXPECT_EQUALSIGN = 7;
-
- int state = STATE_INITIAL;
-
- String newAttributes = "";
- String attributeName = null;
- StringBuffer buf = new StringBuffer();
-
- char[] attrsAsChars = tagAttributes.toCharArray();
- for (int i=0, ilim=attrsAsChars.length+1; i<ilim; ++i) {
- int c;
- if (i<attrsAsChars.length)
- c = (int)attrsAsChars[i];
- else
- c = -1;
-
- switch (state) {
-
- case STATE_INITIAL:
- if (" \t\r\n".indexOf(c)>=0){
- continue;
- }
- else if (-1==c) {
- continue;
- }
- else {
- state = STATE_EXPECT_ATTRIBUTENAME;
- buf.append((char)c);
- }
- break;
-
- case STATE_EXPECT_ATTRIBUTENAME:
- if ('='==c) {
- attributeName = buf.toString();
- buf.setLength(0);
- state = STATE_EXPECT_ATTRIBUTEVALUE;
- }
- else if (-1==c) {
- attributeName = buf.toString();
- buf.setLength(0);
- printWarning("In Tag '"+tag+"':\nAttribute name without a value, inserting value =\""+attributeName+"\"");
- }
- else if (" \t\r\n".indexOf(c)>=0) {
- state = STATE_EXPECT_EQUALSIGN;
- }
- else {
- buf.append((char)c);
- }
- break;
-
- case STATE_EXPECT_EQUALSIGN:
- if (" \t\r\n".indexOf(c)>=0){
- continue;
- }
- else if ('='==c) {
- state = STATE_EXPECT_ATTRIBUTEVALUE;
- attributeName = buf.toString();
- buf.setLength(0);
- }
- else {
- attributeName = buf.toString();
- buf.setLength(0);
- printWarning("In Tag '"+tag+"':\nAttribute name without a value, inserting value =\""+attributeName+"\"");
- newAttributes += " "+attributeName+"=\""+attributeName+"\"";
- buf.append((char)c);
- state = STATE_EXPECT_ATTRIBUTENAME;
- }
- break;
-
- case STATE_EXPECT_ATTRIBUTEVALUE:
- if (" \t\r\n".indexOf(c)>=0){
- continue;
- }
- else if ('\"'==c) {
- state = STATE_DOUBLEQUOTE_ATTRIBUTEVALUE;
- }
- else if ('\''==c) {
- state = STATE_SINGLEQUOTE_ATTRIBUTEVALUE;
- }
- else {
- state = STATE_UNQUOTED_ATTRIBUTEVALUE;
- buf.append((char)c);
- }
- break;
-
- case STATE_UNQUOTED_ATTRIBUTEVALUE:
- if (-1==c || " \t\r\n".indexOf(c)>=0){
- state = STATE_INITIAL;
- newAttributes += " "+attributeName + "=\"" + buf.toString() + "\"";
- buf.setLength(0);
- }
- else {
- buf.append((char)c);
- }
- break;
-
- case STATE_SINGLEQUOTE_ATTRIBUTEVALUE:
- if ('\''==c) {
- state = STATE_INITIAL;
- newAttributes += " "+attributeName + "=\"" + buf.toString() + "\"";
- buf.setLength(0);
- }
- else {
- buf.append((char)c);
- }
- break;
-
- case STATE_DOUBLEQUOTE_ATTRIBUTEVALUE:
- if ('\"'==c) {
- state = STATE_INITIAL;
- newAttributes += " "+attributeName + "=\"" + buf.toString() + "\"";
- buf.setLength(0);
- }
- else {
- buf.append((char)c);
- }
- break;
- }
- }
-
-
- if (!isAtomTag) {
-
- // check whether this open tag is equal to the topmost
- // entry on the stack; if yes, emit a close tag first
-
- // corrects stuff like '<tr><td>...<td>...');
- if (!tagStack.isEmpty() && tagStack.peek().equals(tagName)) {
- printWarning("Inserting </"+tagName+">");
- output.append("</"+tagName+">");
- tagStack.pop();
- }
- else {
- processKnownChildTags(tagName, tagStack, output);
- }
-
- // otherwise, we assume there are no close tags required
- // before this open tag.
- tagStack.push(tagName);
-
- output.append("<"+tagName+newAttributes+">");
- }
- else {
- output.append("<"+tagName+newAttributes+"/>");
- }
- }
- }
-
- private boolean processKnownChildTags(String tagName, Stack tagStack, StringBuffer output) {
-
- TagInfo tagInfo = (TagInfo)tagInfoMap.get(tagName);
- if (null != tagInfo) {
-
- String parentTag = null;
- for (Enumeration en = tagStack.elements(); en.hasMoreElements(); ) {
- String tag = (String)en.nextElement();
- if (tagInfo.isLegalParentTag(tag)) {
- parentTag = tag;
- break;
- }
- }
- if (parentTag != null) {
- while (((String)tagStack.peek()) != parentTag) {
- String poppedTagName = (String)tagStack.pop();
- output.append("</"+poppedTagName+">");
- printWarning("Inserting </"+poppedTagName+">");
- }
- return true;
- }
- }
- return false;
- }
-
- private void flush() {
-
- // close all pending tags
- while (!tagStack.isEmpty()) {
- String tagName = (String)tagStack.pop();
- printWarning("Inserting </"+tagName+">");
- output.append("</"+tagName+">");
- }
- }
-
- /**
- * Takes HTML fragment and returns a well-formed XHTML
- * equivalent.
- *
- * In the returned String, all tags are properly closed and
- * nested.
- *
- * Currently, the returned String is not guaranteed to be
- * well-formed. In particular there are no checks on the tag
- * names, attribute names and entity names.
- */
- public String getWellformedHTML(String text) {
-
- final int STATE_INITIAL = 1;
- final int STATE_TAG_START = 2;
- final int STATE_TAG = 3;
- final int STATE_TAG_DOUBLEQUOTE = 4;
- final int STATE_TAG_SINGLEQUOTE = 5;
- final int STATE_AMP = 6;
-
- int state = STATE_INITIAL;
- output.setLength(0);
-
-
- StringBuffer buf = new StringBuffer();
- char[] textAsChars = text.toCharArray();
-
- outer_loop:
- for (int i=0, ilim=textAsChars.length+1; i<ilim; ++i) {
- int c;
-
- if (i<textAsChars.length) {
- c = textAsChars[i];
- }
- else {
- c = -1;
- }
-
- switch (state) {
-
- case STATE_INITIAL:
- if ('<'==c) {
- state = STATE_TAG_START;
- if (buf.length()>0) {
- haveText(buf.toString());
- buf.setLength(0);
- }
- }
- else if ('>'==c) {
- // assume this is a greater-than sign
- buf.append("&gt;");
- }
- else if ('&'==c) {
- state = STATE_AMP;
- }
- else if (-1==c) {
- if (buf.length()>0) {
- haveText(buf.toString());
- buf.setLength(0);
- }
- continue;
- }
- else {
- buf.append((char)c);
- }
- break;
-
- case STATE_AMP:
- if ('<'==c) {
- buf.append("&amp;");
- state = STATE_TAG_START;
- if (buf.length()>0) {
- haveText(buf.toString());
- buf.setLength(0);
- }
- }
- else if ('>'==c) {
- // assume this is a greater-than sign
- buf.append("&amp;");
- buf.append("&gt;");
- state = STATE_INITIAL;
- }
- else if ('&'==c) {
- buf.append("&amp;");
- buf.append("&amp;");
- state = STATE_INITIAL;
- }
- else if (-1==c) {
- buf.append("&amp;");
- haveText(buf.toString());
- buf.setLength(0);
- state = STATE_INITIAL;
- continue;
- }
- else {
- // peek forward and see whether this is a valid entity.
- if ('#'==c) {
- buf.append("&");
- buf.append((char)c);
- state = STATE_INITIAL;
- continue outer_loop;
- }
- else if (Character.isLetter((char)c)) {
- for (int i2=i+1; i2<ilim-1; i2++) {
- if (';' == textAsChars[i2]) {
- buf.append("&");
- buf.append((char)c);
- state = STATE_INITIAL;
- continue outer_loop;
- }
- else if (!Character.isLetter((char)c)
- && !Character.isDigit((char)c)
- && ".-_:".indexOf((char)c) < 0
- //&& !isCombiningChar(c) // FIXME
- //&& !isExtender(c) // FIXME
- ) {
- break;
- }
- }
- // not a valid entity declaration; assume &amp;
- }
- buf.append("&amp;");
- buf.append((char)c);
- state = STATE_INITIAL;
- }
-
- /*
- else if ('#'==c || Character.isLetter((char)c)) {
- buf.append("&");
- buf.append((char)c);
- state = STATE_INITIAL;
- }
- else {
- buf.append("&amp;");
- buf.append((char)c);
- state = STATE_INITIAL;
- }
- */
- break;
-
- case STATE_TAG_START:
- if (" \t\r\n".indexOf(c)>=0) {
- //continue;
-
- // new: assume this is a less-sign
- haveText("&lt;"+c);
- state = STATE_INITIAL;
- }
- else if ('/'==c) {
- buf.append((char)c);
- state = STATE_TAG;
- }
- else if ('<'==c) {
- // assume this is a less-sign
- haveText("&lt;&lt;");
- state = STATE_INITIAL;
- }
- else if ('>'==c) {
- // assume this is a less-sign
- haveText("&lt;&gt;");
- state = STATE_INITIAL;
- }
- //else if ('-'==c || '+'==c || '='==c || '\''==c || "0123456789".indexOf(c)>=0) {
- else if (!Character.isLetter((char)c)) {
- // assume this is a less-sign
- haveText("&lt;"+(char)c);
- state = STATE_INITIAL;
- }
- else {
- buf.append((char)c);
- state = STATE_TAG;
- }
- break;
-
- case STATE_TAG:
- if ('\"'==c) {
- buf.append((char)c);
- state = STATE_TAG_DOUBLEQUOTE;
- }
- else if ('\''==c) {
- buf.append((char)c);
- state = STATE_TAG_SINGLEQUOTE;
- }
- else if ('>'==c) {
- state = STATE_INITIAL;
- haveStartOrEndTag(buf.toString());
- buf.setLength(0);
- }
- else if ('<'==c) {
- // notify user, missing greater-than sign
- haveStartOrEndTag(buf.toString());
- buf.setLength(0);
- }
- else if (-1==c) {
- printWarning("Unclosed tag at end-of-comment: <"+buf);
- haveStartOrEndTag(buf.toString());
- buf.setLength(0);
- }
- else {
- buf.append((char)c);
- }
- break;
-
- case STATE_TAG_DOUBLEQUOTE:
- if ('\"'==c) {
- buf.append((char)c);
- state = STATE_TAG;
- }
- else if (-1==c) {
- printWarning("Unclosed attribute value at end-of-comment.");
- haveStartOrEndTag(buf.toString()+"\"");
- }
- else {
- buf.append((char)c);
- }
- break;
-
- case STATE_TAG_SINGLEQUOTE:
- if ('\''==c) {
- buf.append((char)c);
- state = STATE_TAG;
- }
- else if (-1==c) {
- printWarning("Unclosed attribute value at end-of-comment.");
- haveStartOrEndTag(buf.toString()+"'");
- }
- else {
- buf.append((char)c);
- }
- break;
- }
- }
-
- return output.toString();
- }
-
- private String getContext() {
- if (null != contextClass) {
- StringBuffer rc = new StringBuffer();
- rc.append(contextClass.qualifiedTypeName());
- if (null != contextMember) {
- rc.append("."+contextMember.toString());
- }
- return rc.toString();
- }
- else {
- return null;
- }
- }
-
- private void printWarning(String msg) {
- if (null != warningReporter && !noWarn) {
- String context = getContext();
- if (null != context) {
- warningReporter.printWarning("In "+getContext()+": "+msg);
- }
- else {
- warningReporter.printWarning("In overview page: "+msg);
- }
- }
- }
-
- public String terminateText() {
- output.setLength(0);
- flush();
- return output.toString();
- }
-}
-
+/* gnu.classpath.tools.doclets.xmldoclet.HtmlRepairer.java
+ Copyright (C) 2003 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.doclets.xmldoclet;
+
+import java.io.*;
+import java.util.*;
+import com.sun.javadoc.DocErrorReporter;
+import com.sun.javadoc.ClassDoc;
+import com.sun.javadoc.MemberDoc;
+
+/**
+ * Provides methods for tidying up HTML source.
+ *
+ * @author Julian Scheid
+ */
+public final class HtmlRepairer {
+
+ private static class TagInfo {
+
+ private Set parentTags = new HashSet();
+
+ public TagInfo(String parentTag) {
+ this.parentTags.add(parentTag);
+ }
+
+ public TagInfo(String[] parentTagArr) {
+ for (int i=0; i<parentTagArr.length; ++i) {
+ this.parentTags.add(parentTagArr[i]);
+ }
+ }
+
+ public boolean isLegalParentTag(String tag) {
+ return this.parentTags.contains(tag);
+ }
+ }
+
+ private DocErrorReporter warningReporter;
+ private boolean noWarn;
+ private boolean noEmailWarn;
+ private ClassDoc contextClass;
+ private MemberDoc contextMember;
+ private StringBuffer output = new StringBuffer();
+ private Stack tagStack = new Stack();
+ private boolean isLeadingTag = true;
+ private boolean throwAwayLeadingPara = false;
+
+ private static Map tagInfoMap;
+
+ private static Set noTextParentTags;
+
+ static {
+ tagInfoMap = new HashMap();
+ tagInfoMap.put("li", new TagInfo(new String[] { "ul", "ol", "nl", "menu", "dir" }));
+ tagInfoMap.put("td", new TagInfo(new String[] { "tr" }));
+ tagInfoMap.put("th", new TagInfo(new String[] { "tr" }));
+ tagInfoMap.put("tr", new TagInfo(new String[] { "table" }));
+ tagInfoMap.put("dt", new TagInfo(new String[] { "dl" }));
+ tagInfoMap.put("dd", new TagInfo(new String[] { "dl" }));
+ tagInfoMap.put("param", new TagInfo(new String[] { "applet" }));
+
+ String[] noTextParentTagArr = {
+ "area", "base", "body", "br", "dd", "dt", "head", "hr", "html",
+ "img", "input", "link", "map", "meta", "ol", "optgroup", "param",
+ "select", "table", "tbody", "tfoot", "thead", "tr", "ul",
+ };
+
+ noTextParentTags = new HashSet();
+ for (int i=0; i<noTextParentTagArr.length; ++i) {
+ noTextParentTags.add(noTextParentTagArr[i]);
+ }
+ }
+
+ public HtmlRepairer(DocErrorReporter warningReporter,
+ boolean noWarn, boolean noEmailWarn,
+ ClassDoc contextClass, MemberDoc contextMember,
+ boolean throwAwayLeadingPara) {
+ this.warningReporter = warningReporter;
+ this.noWarn = noWarn;
+ this.noEmailWarn = noEmailWarn;
+ this.contextClass = contextClass;
+ this.contextMember = contextMember;
+ this.throwAwayLeadingPara = throwAwayLeadingPara;
+ }
+
+ private static String replaceStr(String haystack, String needle, String replacement) {
+ int ndx=haystack.indexOf(needle);
+ if (ndx<0)
+ return haystack;
+ else
+ return haystack.substring(0, ndx)+replacement
+ + replaceStr(haystack.substring(ndx+needle.length()), needle, replacement);
+ }
+
+ private void haveText(String text) {
+
+ if (isLeadingTag && throwAwayLeadingPara) {
+ if (0 != text.trim().length()) {
+ isLeadingTag = false;
+ }
+ }
+
+ if (tagStack.isEmpty() || !noTextParentTags.contains(tagStack.peek())) {
+
+ text = replaceStr(text, "&lt1", "&lt;1");
+ text = replaceStr(text, "&&", "&amp;&amp;");
+ text = replaceStr(text, "& ", "&amp; ");
+ text = replaceStr(text, "&\t", "&amp;\t");
+ text = replaceStr(text, "&\r", "&amp;\r");
+ text = replaceStr(text, "&\n", "&amp;\n");
+ for (char c='0'; c<='9'; ++c)
+ text = replaceStr(text, "&"+c, "&amp;"+c);
+ text = replaceStr(text, "\u00a7", "&sect;");
+ output.append(text);
+ }
+ else {
+ printWarning("Discarded text in <" + tagStack.peek() + "> element");
+ }
+ }
+
+ private void haveStartOrEndTag(String tag) {
+
+ boolean _isLeadingTag = isLeadingTag;
+ isLeadingTag = false;
+
+ tag = tag.trim();
+
+ boolean isEndTag = tag.startsWith("/");
+ boolean isAtomTag = tag.endsWith("/");
+
+ if (isEndTag && isAtomTag) {
+ // got something like '</a/>' which is invalid.
+ // suppose a close tag was intended.
+ tag = tag.substring(0, tag.length()-1);
+ }
+
+ if (tag.length() < 1) {
+ printWarning("Deleting broken tag");
+ return;
+ }
+
+ String tagName = tag.substring(isEndTag?1:0, isAtomTag?tag.length()-1:tag.length());
+ String tagAttributes = "";
+
+ for (int i=0; i<tagName.length(); ++i) {
+ if (" \t\r\n".indexOf(tagName.charAt(i))>=0) {
+ tagAttributes = tagName.substring(i).trim();
+ tagName = tagName.substring(0, i);
+ break;
+ }
+ }
+
+ if (!isEndTag && tagName.indexOf('@')>0) {
+ if (!noEmailWarn) {
+ printWarning("Tag looks like email address: <"+tagName+">");
+ }
+ output.append("&lt;"+tag+"&gt;");
+ return;
+ }
+
+ tagName = tagName.toLowerCase();
+
+ if (_isLeadingTag && "p".equals(tagName) && !isEndTag && throwAwayLeadingPara) {
+ return;
+ }
+
+ if ("p".equals(tagName) || "br".equals(tagName) || "hr".equals(tagName)) {
+ // throw away </p> and </br>
+ if (isEndTag) {
+ return;
+ }
+ // make sure every <p> is a <p/> and every <br> is a <br/>
+ else if (!isAtomTag) {
+ tag += "/";
+ isAtomTag = true;
+ }
+ }
+
+ if (isEndTag) {
+
+ // check whether this close tag is on the stack
+ // if yes, close all tags up to this tag
+ if (tagStack.contains(tagName)) {
+ String popped;
+ do {
+ popped = (String)tagStack.pop();
+ if (!popped.equals(tagName))
+ printWarning("Inserting '</"+popped+">");
+ output.append("</"+popped+">");
+ }
+ while (!popped.equals(tagName));
+ }
+ // if not, just throw it away
+ else {
+ printWarning("Deleting <"+tag+">");
+ }
+ }
+ else {
+
+ final int STATE_INITIAL = 1;
+ final int STATE_EXPECT_ATTRIBUTENAME = 2;
+ final int STATE_UNQUOTED_ATTRIBUTEVALUE = 3;
+ final int STATE_SINGLEQUOTE_ATTRIBUTEVALUE = 4;
+ final int STATE_DOUBLEQUOTE_ATTRIBUTEVALUE = 5;
+ final int STATE_EXPECT_ATTRIBUTEVALUE = 6;
+ final int STATE_EXPECT_EQUALSIGN = 7;
+
+ int state = STATE_INITIAL;
+
+ String newAttributes = "";
+ String attributeName = null;
+ StringBuffer buf = new StringBuffer();
+
+ char[] attrsAsChars = tagAttributes.toCharArray();
+ for (int i=0, ilim=attrsAsChars.length+1; i<ilim; ++i) {
+ int c;
+ if (i<attrsAsChars.length)
+ c = (int)attrsAsChars[i];
+ else
+ c = -1;
+
+ switch (state) {
+
+ case STATE_INITIAL:
+ if (" \t\r\n".indexOf(c)>=0){
+ continue;
+ }
+ else if (-1==c) {
+ continue;
+ }
+ else {
+ state = STATE_EXPECT_ATTRIBUTENAME;
+ buf.append((char)c);
+ }
+ break;
+
+ case STATE_EXPECT_ATTRIBUTENAME:
+ if ('='==c) {
+ attributeName = buf.toString();
+ buf.setLength(0);
+ state = STATE_EXPECT_ATTRIBUTEVALUE;
+ }
+ else if (-1==c) {
+ attributeName = buf.toString();
+ buf.setLength(0);
+ printWarning("In Tag '"+tag+"':\nAttribute name without a value, inserting value =\""+attributeName+"\"");
+ }
+ else if (" \t\r\n".indexOf(c)>=0) {
+ state = STATE_EXPECT_EQUALSIGN;
+ }
+ else {
+ buf.append((char)c);
+ }
+ break;
+
+ case STATE_EXPECT_EQUALSIGN:
+ if (" \t\r\n".indexOf(c)>=0){
+ continue;
+ }
+ else if ('='==c) {
+ state = STATE_EXPECT_ATTRIBUTEVALUE;
+ attributeName = buf.toString();
+ buf.setLength(0);
+ }
+ else {
+ attributeName = buf.toString();
+ buf.setLength(0);
+ printWarning("In Tag '"+tag+"':\nAttribute name without a value, inserting value =\""+attributeName+"\"");
+ newAttributes += " "+attributeName+"=\""+attributeName+"\"";
+ buf.append((char)c);
+ state = STATE_EXPECT_ATTRIBUTENAME;
+ }
+ break;
+
+ case STATE_EXPECT_ATTRIBUTEVALUE:
+ if (" \t\r\n".indexOf(c)>=0){
+ continue;
+ }
+ else if ('\"'==c) {
+ state = STATE_DOUBLEQUOTE_ATTRIBUTEVALUE;
+ }
+ else if ('\''==c) {
+ state = STATE_SINGLEQUOTE_ATTRIBUTEVALUE;
+ }
+ else {
+ state = STATE_UNQUOTED_ATTRIBUTEVALUE;
+ buf.append((char)c);
+ }
+ break;
+
+ case STATE_UNQUOTED_ATTRIBUTEVALUE:
+ if (-1==c || " \t\r\n".indexOf(c)>=0){
+ state = STATE_INITIAL;
+ newAttributes += " "+attributeName + "=\"" + buf.toString() + "\"";
+ buf.setLength(0);
+ }
+ else {
+ buf.append((char)c);
+ }
+ break;
+
+ case STATE_SINGLEQUOTE_ATTRIBUTEVALUE:
+ if ('\''==c) {
+ state = STATE_INITIAL;
+ newAttributes += " "+attributeName + "=\"" + buf.toString() + "\"";
+ buf.setLength(0);
+ }
+ else {
+ buf.append((char)c);
+ }
+ break;
+
+ case STATE_DOUBLEQUOTE_ATTRIBUTEVALUE:
+ if ('\"'==c) {
+ state = STATE_INITIAL;
+ newAttributes += " "+attributeName + "=\"" + buf.toString() + "\"";
+ buf.setLength(0);
+ }
+ else {
+ buf.append((char)c);
+ }
+ break;
+ }
+ }
+
+
+ if (!isAtomTag) {
+
+ // check whether this open tag is equal to the topmost
+ // entry on the stack; if yes, emit a close tag first
+
+ // corrects stuff like '<tr><td>...<td>...');
+ if (!tagStack.isEmpty() && tagStack.peek().equals(tagName)) {
+ printWarning("Inserting </"+tagName+">");
+ output.append("</"+tagName+">");
+ tagStack.pop();
+ }
+ else {
+ processKnownChildTags(tagName, tagStack, output);
+ }
+
+ // otherwise, we assume there are no close tags required
+ // before this open tag.
+ tagStack.push(tagName);
+
+ output.append("<"+tagName+newAttributes+">");
+ }
+ else {
+ output.append("<"+tagName+newAttributes+"/>");
+ }
+ }
+ }
+
+ private boolean processKnownChildTags(String tagName, Stack tagStack, StringBuffer output) {
+
+ TagInfo tagInfo = (TagInfo)tagInfoMap.get(tagName);
+ if (null != tagInfo) {
+
+ String parentTag = null;
+ for (Enumeration en = tagStack.elements(); en.hasMoreElements(); ) {
+ String tag = (String)en.nextElement();
+ if (tagInfo.isLegalParentTag(tag)) {
+ parentTag = tag;
+ break;
+ }
+ }
+ if (parentTag != null) {
+ while (((String)tagStack.peek()) != parentTag) {
+ String poppedTagName = (String)tagStack.pop();
+ output.append("</"+poppedTagName+">");
+ printWarning("Inserting </"+poppedTagName+">");
+ }
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private void flush() {
+
+ // close all pending tags
+ while (!tagStack.isEmpty()) {
+ String tagName = (String)tagStack.pop();
+ printWarning("Inserting </"+tagName+">");
+ output.append("</"+tagName+">");
+ }
+ }
+
+ /**
+ * Takes HTML fragment and returns a well-formed XHTML
+ * equivalent.
+ *
+ * In the returned String, all tags are properly closed and
+ * nested.
+ *
+ * Currently, the returned String is not guaranteed to be
+ * well-formed. In particular there are no checks on the tag
+ * names, attribute names and entity names.
+ */
+ public String getWellformedHTML(String text) {
+
+ final int STATE_INITIAL = 1;
+ final int STATE_TAG_START = 2;
+ final int STATE_TAG = 3;
+ final int STATE_TAG_DOUBLEQUOTE = 4;
+ final int STATE_TAG_SINGLEQUOTE = 5;
+ final int STATE_AMP = 6;
+
+ int state = STATE_INITIAL;
+ output.setLength(0);
+
+
+ StringBuffer buf = new StringBuffer();
+ char[] textAsChars = text.toCharArray();
+
+ outer_loop:
+ for (int i=0, ilim=textAsChars.length+1; i<ilim; ++i) {
+ int c;
+
+ if (i<textAsChars.length) {
+ c = textAsChars[i];
+ }
+ else {
+ c = -1;
+ }
+
+ switch (state) {
+
+ case STATE_INITIAL:
+ if ('<'==c) {
+ state = STATE_TAG_START;
+ if (buf.length()>0) {
+ haveText(buf.toString());
+ buf.setLength(0);
+ }
+ }
+ else if ('>'==c) {
+ // assume this is a greater-than sign
+ buf.append("&gt;");
+ }
+ else if ('&'==c) {
+ state = STATE_AMP;
+ }
+ else if (-1==c) {
+ if (buf.length()>0) {
+ haveText(buf.toString());
+ buf.setLength(0);
+ }
+ continue;
+ }
+ else {
+ buf.append((char)c);
+ }
+ break;
+
+ case STATE_AMP:
+ if ('<'==c) {
+ buf.append("&amp;");
+ state = STATE_TAG_START;
+ if (buf.length()>0) {
+ haveText(buf.toString());
+ buf.setLength(0);
+ }
+ }
+ else if ('>'==c) {
+ // assume this is a greater-than sign
+ buf.append("&amp;");
+ buf.append("&gt;");
+ state = STATE_INITIAL;
+ }
+ else if ('&'==c) {
+ buf.append("&amp;");
+ buf.append("&amp;");
+ state = STATE_INITIAL;
+ }
+ else if (-1==c) {
+ buf.append("&amp;");
+ haveText(buf.toString());
+ buf.setLength(0);
+ state = STATE_INITIAL;
+ continue;
+ }
+ else {
+ // peek forward and see whether this is a valid entity.
+ if ('#'==c) {
+ buf.append("&");
+ buf.append((char)c);
+ state = STATE_INITIAL;
+ continue outer_loop;
+ }
+ else if (Character.isLetter((char)c)) {
+ for (int i2=i+1; i2<ilim-1; i2++) {
+ if (';' == textAsChars[i2]) {
+ buf.append("&");
+ buf.append((char)c);
+ state = STATE_INITIAL;
+ continue outer_loop;
+ }
+ else if (!Character.isLetter((char)c)
+ && !Character.isDigit((char)c)
+ && ".-_:".indexOf((char)c) < 0
+ //&& !isCombiningChar(c) // FIXME
+ //&& !isExtender(c) // FIXME
+ ) {
+ break;
+ }
+ }
+ // not a valid entity declaration; assume &amp;
+ }
+ buf.append("&amp;");
+ buf.append((char)c);
+ state = STATE_INITIAL;
+ }
+
+ /*
+ else if ('#'==c || Character.isLetter((char)c)) {
+ buf.append("&");
+ buf.append((char)c);
+ state = STATE_INITIAL;
+ }
+ else {
+ buf.append("&amp;");
+ buf.append((char)c);
+ state = STATE_INITIAL;
+ }
+ */
+ break;
+
+ case STATE_TAG_START:
+ if (" \t\r\n".indexOf(c)>=0) {
+ //continue;
+
+ // new: assume this is a less-sign
+ haveText("&lt;"+c);
+ state = STATE_INITIAL;
+ }
+ else if ('/'==c) {
+ buf.append((char)c);
+ state = STATE_TAG;
+ }
+ else if ('<'==c) {
+ // assume this is a less-sign
+ haveText("&lt;&lt;");
+ state = STATE_INITIAL;
+ }
+ else if ('>'==c) {
+ // assume this is a less-sign
+ haveText("&lt;&gt;");
+ state = STATE_INITIAL;
+ }
+ //else if ('-'==c || '+'==c || '='==c || '\''==c || "0123456789".indexOf(c)>=0) {
+ else if (!Character.isLetter((char)c)) {
+ // assume this is a less-sign
+ haveText("&lt;"+(char)c);
+ state = STATE_INITIAL;
+ }
+ else {
+ buf.append((char)c);
+ state = STATE_TAG;
+ }
+ break;
+
+ case STATE_TAG:
+ if ('\"'==c) {
+ buf.append((char)c);
+ state = STATE_TAG_DOUBLEQUOTE;
+ }
+ else if ('\''==c) {
+ buf.append((char)c);
+ state = STATE_TAG_SINGLEQUOTE;
+ }
+ else if ('>'==c) {
+ state = STATE_INITIAL;
+ haveStartOrEndTag(buf.toString());
+ buf.setLength(0);
+ }
+ else if ('<'==c) {
+ // notify user, missing greater-than sign
+ haveStartOrEndTag(buf.toString());
+ buf.setLength(0);
+ }
+ else if (-1==c) {
+ printWarning("Unclosed tag at end-of-comment: <"+buf);
+ haveStartOrEndTag(buf.toString());
+ buf.setLength(0);
+ }
+ else {
+ buf.append((char)c);
+ }
+ break;
+
+ case STATE_TAG_DOUBLEQUOTE:
+ if ('\"'==c) {
+ buf.append((char)c);
+ state = STATE_TAG;
+ }
+ else if (-1==c) {
+ printWarning("Unclosed attribute value at end-of-comment.");
+ haveStartOrEndTag(buf.toString()+"\"");
+ }
+ else {
+ buf.append((char)c);
+ }
+ break;
+
+ case STATE_TAG_SINGLEQUOTE:
+ if ('\''==c) {
+ buf.append((char)c);
+ state = STATE_TAG;
+ }
+ else if (-1==c) {
+ printWarning("Unclosed attribute value at end-of-comment.");
+ haveStartOrEndTag(buf.toString()+"'");
+ }
+ else {
+ buf.append((char)c);
+ }
+ break;
+ }
+ }
+
+ return output.toString();
+ }
+
+ private String getContext() {
+ if (null != contextClass) {
+ StringBuffer rc = new StringBuffer();
+ rc.append(contextClass.qualifiedTypeName());
+ if (null != contextMember) {
+ rc.append("."+contextMember.toString());
+ }
+ return rc.toString();
+ }
+ else {
+ return null;
+ }
+ }
+
+ private void printWarning(String msg) {
+ if (null != warningReporter && !noWarn) {
+ String context = getContext();
+ if (null != context) {
+ warningReporter.printWarning("In "+getContext()+": "+msg);
+ }
+ else {
+ warningReporter.printWarning("In overview page: "+msg);
+ }
+ }
+ }
+
+ public String terminateText() {
+ output.setLength(0);
+ flush();
+ return output.toString();
+ }
+}
+
diff --git a/tools/gnu/classpath/tools/doclets/xmldoclet/TargetContext.java b/tools/gnu/classpath/tools/doclets/xmldoclet/TargetContext.java
index f1e959d70..6fdb8cb48 100644
--- a/tools/gnu/classpath/tools/doclets/xmldoclet/TargetContext.java
+++ b/tools/gnu/classpath/tools/doclets/xmldoclet/TargetContext.java
@@ -1,103 +1,103 @@
-/* gnu.classpath.tools.doclets.xmldoclet.TargetContext
- Copyright (C) 2001 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
-
-package gnu.classpath.tools.doclets.xmldoclet;
-
-import java.io.File;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-
-import java.net.URL;
-
-import java.util.List;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.HashMap;
-
-import gnu.classpath.tools.doclets.xmldoclet.doctranslet.DocTranslet;
-
-/**
- * Stores any XSL transformation and postprocessing-specific
- * information given by the user on the doclet command line.
- *
- * @author Julian Scheid
- */
-public class TargetContext {
-
- /**
- * The DocTranslet to use for processing doclet output.
- */
- private DocTranslet docTranslet;
-
- /**
- * Directory to write final output to.
- */
- private File targetDirectory;
-
- /**
- * Directory where XSLT output will be written to. If an XSLT
- * sheet was specified, but no postprocessing driver was given,
- * this is the target directory specified by the user. Otherwise,
- * this is a temporary directory.
- */
- private File xsltTargetDirectory;
-
-
- public TargetContext(DocTranslet docTranslet, File targetDirectory) {
- this.docTranslet = docTranslet;
- this.targetDirectory = targetDirectory;
- }
-
- public File getTargetDirectory() {
- return targetDirectory;
- }
-
- public void setTargetDirectory(File targetDirectory) {
- this.targetDirectory = targetDirectory;
- }
-
- public DocTranslet getDocTranslet() {
- return docTranslet;
- }
-
- public void setDocTranslet(DocTranslet docTranslet) {
- this.docTranslet = docTranslet;
- }
-}
+/* gnu.classpath.tools.doclets.xmldoclet.TargetContext
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.doclets.xmldoclet;
+
+import java.io.File;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+import java.net.URL;
+
+import java.util.List;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.HashMap;
+
+import gnu.classpath.tools.doclets.xmldoclet.doctranslet.DocTranslet;
+
+/**
+ * Stores any XSL transformation and postprocessing-specific
+ * information given by the user on the doclet command line.
+ *
+ * @author Julian Scheid
+ */
+public class TargetContext {
+
+ /**
+ * The DocTranslet to use for processing doclet output.
+ */
+ private DocTranslet docTranslet;
+
+ /**
+ * Directory to write final output to.
+ */
+ private File targetDirectory;
+
+ /**
+ * Directory where XSLT output will be written to. If an XSLT
+ * sheet was specified, but no postprocessing driver was given,
+ * this is the target directory specified by the user. Otherwise,
+ * this is a temporary directory.
+ */
+ private File xsltTargetDirectory;
+
+
+ public TargetContext(DocTranslet docTranslet, File targetDirectory) {
+ this.docTranslet = docTranslet;
+ this.targetDirectory = targetDirectory;
+ }
+
+ public File getTargetDirectory() {
+ return targetDirectory;
+ }
+
+ public void setTargetDirectory(File targetDirectory) {
+ this.targetDirectory = targetDirectory;
+ }
+
+ public DocTranslet getDocTranslet() {
+ return docTranslet;
+ }
+
+ public void setDocTranslet(DocTranslet docTranslet) {
+ this.docTranslet = docTranslet;
+ }
+}
diff --git a/tools/gnu/classpath/tools/doclets/xmldoclet/doctranslet/OutputFileInfo.java b/tools/gnu/classpath/tools/doclets/xmldoclet/doctranslet/OutputFileInfo.java
index b1fc2e011..b4e394cec 100644
--- a/tools/gnu/classpath/tools/doclets/xmldoclet/doctranslet/OutputFileInfo.java
+++ b/tools/gnu/classpath/tools/doclets/xmldoclet/doctranslet/OutputFileInfo.java
@@ -1,66 +1,66 @@
-/* gnu.classpath.tools.doclets.xmldoclet.doctranslet.OutputFileInfo
- Copyright (C) 2003 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
-
-package gnu.classpath.tools.doclets.xmldoclet.doctranslet;
-
-/**
- * Holds information about a file to be generated by the DocTranslet.
- */
-public class OutputFileInfo {
-
- private String name;
- private String source;
- private String sheet;
- private String comment;
- private String info;
-
- public OutputFileInfo(String name, String source, String sheet, String comment, String info) {
- this.name = name;
- this.source = source;
- this.sheet = sheet;
- this.comment = comment;
- this.info = info;
- }
-
- public String getName() { return name; }
- public String getSource() { return source; }
- public String getSheet() { return sheet; }
- public String getComment() { return comment; }
- public String getInfo() { return info; }
-
- public String toString() { return "OutputFileInfo{name="+name+",source="+source+",sheet="+sheet+",comment="+comment+",info="+info+"}"; }
-}
+/* gnu.classpath.tools.doclets.xmldoclet.doctranslet.OutputFileInfo
+ Copyright (C) 2003 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.doclets.xmldoclet.doctranslet;
+
+/**
+ * Holds information about a file to be generated by the DocTranslet.
+ */
+public class OutputFileInfo {
+
+ private String name;
+ private String source;
+ private String sheet;
+ private String comment;
+ private String info;
+
+ public OutputFileInfo(String name, String source, String sheet, String comment, String info) {
+ this.name = name;
+ this.source = source;
+ this.sheet = sheet;
+ this.comment = comment;
+ this.info = info;
+ }
+
+ public String getName() { return name; }
+ public String getSource() { return source; }
+ public String getSheet() { return sheet; }
+ public String getComment() { return comment; }
+ public String getInfo() { return info; }
+
+ public String toString() { return "OutputFileInfo{name="+name+",source="+source+",sheet="+sheet+",comment="+comment+",info="+info+"}"; }
+}
diff --git a/tools/gnu/classpath/tools/gjdoc/ErrorReporter.java b/tools/gnu/classpath/tools/gjdoc/ErrorReporter.java
index 162547139..129689bc9 100644
--- a/tools/gnu/classpath/tools/gjdoc/ErrorReporter.java
+++ b/tools/gnu/classpath/tools/gjdoc/ErrorReporter.java
@@ -1,121 +1,121 @@
-/* gnu.classpath.tools.gjdoc.ErrorReporter
- Copyright (C) 2001 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
-
-package gnu.classpath.tools.gjdoc;
-
-import com.sun.javadoc.*;
-import java.io.*;
-import java.util.*;
-import java.lang.reflect.*;
-
-/**
- * Simple implementation of a <code>DocErrorReporter</code>: writes
- * to <code>System.err</code>.
- */
-public class ErrorReporter implements DocErrorReporter {
-
- private PrintStream out;
-
- /**
- * Keeps track of the number of errors occured
- * during generation.
- */
- private int errorCount=0;
-
- /**
- * Keeps track of the number of warnings occured
- * during generation.
- */
- private int warningCount=0;
-
- /*
- * When <code>true</code>, no notices will be emitted.
- */
- private boolean quiet = false;
-
- /*
- * When <code>true</code>, no warnings will be emitted.
- */
- private boolean noWarn = false;
-
- public ErrorReporter()
- {
- this.out = System.err;
- }
-
- // Print error message, increment error count.
- public void printError(java.lang.String msg) {
- out.println("ERROR: "+msg);
- ++errorCount;
- }
-
- // Print error message, increment error count.
- public void printFatal(java.lang.String msg) {
- out.println("FATAL: "+msg);
- System.exit(10);
- }
-
- // Print a message.
- public void printNotice(java.lang.String msg) {
- if (!quiet) {
- out.println(msg);
- }
- }
-
- // Print warning message, increment warning count.
- public void printWarning(java.lang.String msg) {
- if (!noWarn) {
- out.println("WARNING: "+msg);
- ++warningCount;;
- }
- }
-
- public int getErrorCount() {
- return errorCount;
- }
-
- public int getWarningCount() {
- return warningCount;
- }
-
- /**
- * Specify whether notices should be printed.
- */
- public void setQuiet(boolean quiet) {
- this.quiet = quiet;
- }
-}
+/* gnu.classpath.tools.gjdoc.ErrorReporter
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc;
+
+import com.sun.javadoc.*;
+import java.io.*;
+import java.util.*;
+import java.lang.reflect.*;
+
+/**
+ * Simple implementation of a <code>DocErrorReporter</code>: writes
+ * to <code>System.err</code>.
+ */
+public class ErrorReporter implements DocErrorReporter {
+
+ private PrintStream out;
+
+ /**
+ * Keeps track of the number of errors occured
+ * during generation.
+ */
+ private int errorCount=0;
+
+ /**
+ * Keeps track of the number of warnings occured
+ * during generation.
+ */
+ private int warningCount=0;
+
+ /*
+ * When <code>true</code>, no notices will be emitted.
+ */
+ private boolean quiet = false;
+
+ /*
+ * When <code>true</code>, no warnings will be emitted.
+ */
+ private boolean noWarn = false;
+
+ public ErrorReporter()
+ {
+ this.out = System.err;
+ }
+
+ // Print error message, increment error count.
+ public void printError(java.lang.String msg) {
+ out.println("ERROR: "+msg);
+ ++errorCount;
+ }
+
+ // Print error message, increment error count.
+ public void printFatal(java.lang.String msg) {
+ out.println("FATAL: "+msg);
+ System.exit(10);
+ }
+
+ // Print a message.
+ public void printNotice(java.lang.String msg) {
+ if (!quiet) {
+ out.println(msg);
+ }
+ }
+
+ // Print warning message, increment warning count.
+ public void printWarning(java.lang.String msg) {
+ if (!noWarn) {
+ out.println("WARNING: "+msg);
+ ++warningCount;;
+ }
+ }
+
+ public int getErrorCount() {
+ return errorCount;
+ }
+
+ public int getWarningCount() {
+ return warningCount;
+ }
+
+ /**
+ * Specify whether notices should be printed.
+ */
+ public void setQuiet(boolean quiet) {
+ this.quiet = quiet;
+ }
+}
diff --git a/tools/gnu/classpath/tools/gjdoc/TemporaryStore.java b/tools/gnu/classpath/tools/gjdoc/TemporaryStore.java
index 7807d49df..f062b2a8d 100644
--- a/tools/gnu/classpath/tools/gjdoc/TemporaryStore.java
+++ b/tools/gnu/classpath/tools/gjdoc/TemporaryStore.java
@@ -1,132 +1,132 @@
-/* gnu.classpath.tools.gjdoc.TemporaryStore
- Copyright (C) 2001 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
-
-package gnu.classpath.tools.gjdoc;
-
-/**
- * Useful for passing big objects that are no longer needed by the
- * calling method, reducing memory usage. <p/>
- *
- * Consider the following problem:
- * <pre>
- * public class A {
- * public static void foo() {
- * long[] hugeArray = new long[1000000]; // takes around 8 MB
- * // ... fill hugeArray with some information ...
- * bar(hugeArray);
- * // ... hugeArray is no more required at this point
- * }
- * public static void bar(long[] arr) {
- * // ... process contents of arr ...
- * arr = null;
- * System.gc(); // NOTE: will not collect arr!
- * // ... do something memory-intensive where arr is not needed
- * }
- * }
- * </pre>
- *
- * In method <code>bar()</code>, the array cannot be garbage
- * collected because the local variable <code>hugeArray</code> in
- * method <code>foo()</code> still holds a reference to the array.
- * <p/>
- *
- * When calling <code>bar(new long[1000000]);</code> in
- * <code>arr</code> the array <i>can</i> be collected in
- * <code>bar()</code>, but that way it can't be initialized in
- * <code>foo()</code>. A local variable is needed for
- * initialization, but the variable can't be cleared before it is
- * passed to <code>bar()</code>! <p/>
- *
- * <code>TemporaryStore</code> is the solution for this
- * dilemma. The modified method <code>foo()</code> which uses a
- * <code>TemporaryStore</code> object would look like this:
- *
- * <pre>
- * public static void foo() {
- * long[] hugeArray = new long[1000000]; // takes around 7 MB
- * // ... fill hugeArray with some very important information ...
- * TemporaryStore tstore = new TemporaryStore(hugeArray);
- * hugeArray = null;
- * bar((long[])tstore.getAndClear());
- * }
- * </pre>
- *
- * When control flow is transferred to <code>bar()</code>,
- * <code>foo()</code> will hold no more references to the array
- * and so it can be garbage collected in <code>bar()</code>.
- *
- */
-public class TemporaryStore {
-
- private Object storedObject;
-
- /**
- * Temporarily store the given object for passing it to a
- * different method. <p/>
- *
- * The method constructing a new TemporaryStore object should
- * clear all other references to the stored object, so that
- * this TemporaryStore is the only object referencing it.
- *
- * @param storedObject the object to store temporarily
- *
- */
- public TemporaryStore(Object storedObject) {
- this.storedObject = storedObject;
- }
-
- /**
- * Return the stored object after clearing the reference to it.
- * <p/>
- *
- * When the user of this class followed the recommendations in
- * the documentation of @link{TemporaryStore(Object)}, the
- * returned reference will be the only reference to the stored
- * object after this method returns. If the returned reference
- * is passed in a method call, the called method will hold the
- * only reference to the stored object and can release it by
- * nulling the corresponding parameter.
- *
- * @return the object which was passed to the constructor.
- *
- */
- public Object getAndClear() {
- Object rc = this.storedObject;
- this.storedObject = null;
- return rc;
- }
-}
+/* gnu.classpath.tools.gjdoc.TemporaryStore
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc;
+
+/**
+ * Useful for passing big objects that are no longer needed by the
+ * calling method, reducing memory usage. <p/>
+ *
+ * Consider the following problem:
+ * <pre>
+ * public class A {
+ * public static void foo() {
+ * long[] hugeArray = new long[1000000]; // takes around 8 MB
+ * // ... fill hugeArray with some information ...
+ * bar(hugeArray);
+ * // ... hugeArray is no more required at this point
+ * }
+ * public static void bar(long[] arr) {
+ * // ... process contents of arr ...
+ * arr = null;
+ * System.gc(); // NOTE: will not collect arr!
+ * // ... do something memory-intensive where arr is not needed
+ * }
+ * }
+ * </pre>
+ *
+ * In method <code>bar()</code>, the array cannot be garbage
+ * collected because the local variable <code>hugeArray</code> in
+ * method <code>foo()</code> still holds a reference to the array.
+ * <p/>
+ *
+ * When calling <code>bar(new long[1000000]);</code> in
+ * <code>arr</code> the array <i>can</i> be collected in
+ * <code>bar()</code>, but that way it can't be initialized in
+ * <code>foo()</code>. A local variable is needed for
+ * initialization, but the variable can't be cleared before it is
+ * passed to <code>bar()</code>! <p/>
+ *
+ * <code>TemporaryStore</code> is the solution for this
+ * dilemma. The modified method <code>foo()</code> which uses a
+ * <code>TemporaryStore</code> object would look like this:
+ *
+ * <pre>
+ * public static void foo() {
+ * long[] hugeArray = new long[1000000]; // takes around 7 MB
+ * // ... fill hugeArray with some very important information ...
+ * TemporaryStore tstore = new TemporaryStore(hugeArray);
+ * hugeArray = null;
+ * bar((long[])tstore.getAndClear());
+ * }
+ * </pre>
+ *
+ * When control flow is transferred to <code>bar()</code>,
+ * <code>foo()</code> will hold no more references to the array
+ * and so it can be garbage collected in <code>bar()</code>.
+ *
+ */
+public class TemporaryStore {
+
+ private Object storedObject;
+
+ /**
+ * Temporarily store the given object for passing it to a
+ * different method. <p/>
+ *
+ * The method constructing a new TemporaryStore object should
+ * clear all other references to the stored object, so that
+ * this TemporaryStore is the only object referencing it.
+ *
+ * @param storedObject the object to store temporarily
+ *
+ */
+ public TemporaryStore(Object storedObject) {
+ this.storedObject = storedObject;
+ }
+
+ /**
+ * Return the stored object after clearing the reference to it.
+ * <p/>
+ *
+ * When the user of this class followed the recommendations in
+ * the documentation of @link{TemporaryStore(Object)}, the
+ * returned reference will be the only reference to the stored
+ * object after this method returns. If the returned reference
+ * is passed in a method call, the called method will hold the
+ * only reference to the stored object and can release it by
+ * nulling the corresponding parameter.
+ *
+ * @return the object which was passed to the constructor.
+ *
+ */
+ public Object getAndClear() {
+ Object rc = this.storedObject;
+ this.storedObject = null;
+ return rc;
+ }
+}
diff --git a/tools/gnu/classpath/tools/gjdoc/WritableType.java b/tools/gnu/classpath/tools/gjdoc/WritableType.java
index a1fa4d591..00f599bb2 100644
--- a/tools/gnu/classpath/tools/gjdoc/WritableType.java
+++ b/tools/gnu/classpath/tools/gjdoc/WritableType.java
@@ -1,44 +1,44 @@
-/* gnu.classpath.tools.gjdoc.WritableType
- Copyright (C) 2001 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
-
-package gnu.classpath.tools.gjdoc;
-
-public interface WritableType extends Cloneable {
-
- public void setDimension(String dimension);
- public Object clone() throws CloneNotSupportedException;
-}
+/* gnu.classpath.tools.gjdoc.WritableType
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.gjdoc;
+
+public interface WritableType extends Cloneable {
+
+ public void setDimension(String dimension);
+ public Object clone() throws CloneNotSupportedException;
+}
diff --git a/tools/gnu/classpath/tools/javah/ClassWrapper.java b/tools/gnu/classpath/tools/javah/ClassWrapper.java
index 43f31a2fd..2fb73772f 100644
--- a/tools/gnu/classpath/tools/javah/ClassWrapper.java
+++ b/tools/gnu/classpath/tools/javah/ClassWrapper.java
@@ -58,21 +58,21 @@ public class ClassWrapper
ClassWrapper superClass;
- ArrayList interfaceClasses;
+ ArrayList<ClassWrapper> interfaceClasses;
// The virtual table for this class.
- ArrayList vtable;
+ ArrayList<MethodNode> vtable;
// A set of all the bridge method targets we've found.
- HashSet bridgeTargets;
+ HashSet<String> bridgeTargets;
// A set of all the method names in this class.
- HashSet methodNames = new HashSet();
+ HashSet<String> methodNames = new HashSet<String>();
// This maps a method name + descriptor, e.g. "method()V", to the
// name chosen for the method. This is used when computing the
// names of bridge method targets.
- HashMap methodNameMap = new HashMap();
+ HashMap<String,String> methodNameMap = new HashMap<String,String>();
public ClassWrapper(Main classpath)
{
@@ -81,7 +81,7 @@ public class ClassWrapper
public boolean hasNativeMethod()
{
- Iterator i = methods.iterator();
+ Iterator<?> i = methods.iterator();
while (i.hasNext())
{
MethodNode method = (MethodNode) i.next();
@@ -115,7 +115,7 @@ public class ClassWrapper
{
superClass = classpath.getClass(superName);
assert interfaceClasses == null;
- interfaceClasses = new ArrayList();
+ interfaceClasses = new ArrayList<ClassWrapper>();
for (int i = 0; i < interfaces.size(); ++i)
{
String ifname = (String) interfaces.get(i);
@@ -131,7 +131,7 @@ public class ClassWrapper
{
for (int i = vtable.size() - 1; i >= 0; --i)
{
- MethodNode base = (MethodNode) vtable.get(i);
+ MethodNode base = vtable.get(i);
if (MethodHelper.overrides(method, base))
return i;
}
@@ -140,7 +140,7 @@ public class ClassWrapper
private void addInterfaceMethods(ClassWrapper iface)
{
- Iterator i = iface.methods.iterator();
+ Iterator<?> i = iface.methods.iterator();
while (i.hasNext())
{
MethodNode im = (MethodNode) i.next();
@@ -159,7 +159,7 @@ public class ClassWrapper
{
if (base.interfaceClasses == null)
return;
- Iterator i = base.interfaceClasses.iterator();
+ Iterator<?> i = base.interfaceClasses.iterator();
while (i.hasNext())
{
ClassWrapper iface = (ClassWrapper) i.next();
@@ -169,7 +169,7 @@ public class ClassWrapper
private void addLocalMethods()
{
- Iterator i = methods.iterator();
+ Iterator<?> i = methods.iterator();
while (i.hasNext())
{
MethodNode meth = (MethodNode) i.next();
@@ -191,16 +191,16 @@ public class ClassWrapper
if (superClass != null)
{
superClass.makeVtable();
- vtable = new ArrayList(superClass.vtable);
- bridgeTargets = new HashSet(superClass.bridgeTargets);
- methodNameMap = new HashMap(superClass.methodNameMap);
+ vtable = new ArrayList<MethodNode>(superClass.vtable);
+ bridgeTargets = new HashSet<String>(superClass.bridgeTargets);
+ methodNameMap = new HashMap<String,String>(superClass.methodNameMap);
}
else
{
// Object.
- vtable = new ArrayList();
- bridgeTargets = new HashSet();
- methodNameMap = new HashMap();
+ vtable = new ArrayList<MethodNode>();
+ bridgeTargets = new HashSet<String>();
+ methodNameMap = new HashMap<String,String>();
}
addLocalMethods();
addInterfaces(this);
@@ -211,7 +211,7 @@ public class ClassWrapper
// methods by definition override a method from the superclass --
// and we have to consider the superclass' header as an
// unchangeable entity.
- Iterator i = methods.iterator();
+ Iterator<?> i = methods.iterator();
while (i.hasNext())
{
MethodNode m = (MethodNode) i.next();
@@ -234,7 +234,7 @@ public class ClassWrapper
private void printFields(CniPrintStream out)
{
- Iterator i = fields.iterator();
+ Iterator<?> i = fields.iterator();
ClassWrapper self = superClass;
while (i.hasNext())
{
@@ -251,7 +251,7 @@ public class ClassWrapper
// A given method is either static, overrides a super method, or
// is already in vtable order.
- Iterator i = methods.iterator();
+ Iterator<?> i = methods.iterator();
while (i.hasNext())
{
MethodNode m = (MethodNode) i.next();
@@ -266,15 +266,15 @@ public class ClassWrapper
}
}
- private void printTextList(PrintStream out, int what, ArrayList textList)
+ private void printTextList(PrintStream out, int what, ArrayList<Text> textList)
{
if (textList == null)
return;
- Iterator i = textList.iterator();
+ Iterator<Text> i = textList.iterator();
boolean first = true;
while (i.hasNext())
{
- Text item = (Text) i.next();
+ Text item = i.next();
if (item.type == what)
{
if (first)
@@ -295,7 +295,7 @@ public class ClassWrapper
}
// This prints the body of a class to a CxxPrintStream.
- private void printContents(CniPrintStream out, ArrayList textList)
+ private void printContents(CniPrintStream out, ArrayList<Text> textList)
throws IOException
{
printTextList(out, Text.PREPEND, textList);
@@ -337,7 +337,7 @@ public class ClassWrapper
{
linkSupers();
- ArrayList textList = classpath.getClassTextList(name);
+ ArrayList<Text> textList = classpath.getClassTextList(name);
out.println("// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-");
out.println();
diff --git a/tools/gnu/classpath/tools/javah/CniPrintStream.java b/tools/gnu/classpath/tools/javah/CniPrintStream.java
index 64ba537d4..33fd58b1e 100644
--- a/tools/gnu/classpath/tools/javah/CniPrintStream.java
+++ b/tools/gnu/classpath/tools/javah/CniPrintStream.java
@@ -55,7 +55,7 @@ public class CniPrintStream
boolean sawArray;
// All the classes referenced by this header.
- HashSet allClasses = new HashSet();
+ HashSet<String> allClasses = new HashSet<String>();
String[] previousPackage = new String[0];
@@ -214,7 +214,7 @@ public class CniPrintStream
out.println();
}
- String[] classes = (String[]) allClasses.toArray(new String[0]);
+ String[] classes = allClasses.toArray(new String[0]);
Arrays.sort(classes);
boolean first = true;
diff --git a/tools/gnu/classpath/tools/javah/CniStubPrinter.java b/tools/gnu/classpath/tools/javah/CniStubPrinter.java
index 3acec2328..f96091ea1 100644
--- a/tools/gnu/classpath/tools/javah/CniStubPrinter.java
+++ b/tools/gnu/classpath/tools/javah/CniStubPrinter.java
@@ -103,7 +103,7 @@ public class CniStubPrinter
out.println("#include <" + klass.name + ".h>");
out.println();
- Iterator i = klass.methods.iterator();
+ Iterator<?> i = klass.methods.iterator();
boolean first = true;
while (i.hasNext())
{
diff --git a/tools/gnu/classpath/tools/javah/GcjhMain.java b/tools/gnu/classpath/tools/javah/GcjhMain.java
index 15bcec263..0b69d3116 100644
--- a/tools/gnu/classpath/tools/javah/GcjhMain.java
+++ b/tools/gnu/classpath/tools/javah/GcjhMain.java
@@ -49,7 +49,7 @@ import java.util.ArrayList;
public class GcjhMain extends Main
{
- ArrayList commands = new ArrayList();
+ ArrayList<Text> commands = new ArrayList<Text>();
public GcjhMain()
{
diff --git a/tools/gnu/classpath/tools/javah/JniIncludePrinter.java b/tools/gnu/classpath/tools/javah/JniIncludePrinter.java
index ba44a5711..856acf3e6 100644
--- a/tools/gnu/classpath/tools/javah/JniIncludePrinter.java
+++ b/tools/gnu/classpath/tools/javah/JniIncludePrinter.java
@@ -63,7 +63,7 @@ public class JniIncludePrinter
boolean wroteAny = false;
for (; klass != null; klass = klass.superClass)
{
- Iterator i = klass.fields.iterator();
+ Iterator<?> i = klass.fields.iterator();
while (i.hasNext())
{
FieldNode field = (FieldNode) i.next();
@@ -138,7 +138,7 @@ public class JniIncludePrinter
out.println("#endif");
out.println();
- Iterator i = klass.methods.iterator();
+ Iterator<?> i = klass.methods.iterator();
while (i.hasNext())
{
MethodNode method = (MethodNode) i.next();
diff --git a/tools/gnu/classpath/tools/javah/JniPrintStream.java b/tools/gnu/classpath/tools/javah/JniPrintStream.java
index a0461f475..96f9e7d1a 100644
--- a/tools/gnu/classpath/tools/javah/JniPrintStream.java
+++ b/tools/gnu/classpath/tools/javah/JniPrintStream.java
@@ -54,7 +54,7 @@ public class JniPrintStream
Main classpath;
// This is used to determine whether a method has an overload.
- HashMap methodNameMap = new HashMap();
+ HashMap<String,Integer> methodNameMap = new HashMap<String,Integer>();
public JniPrintStream(Main classpath, OutputStream out, ClassWrapper klass)
{
@@ -65,7 +65,7 @@ public class JniPrintStream
private void computeOverloads(ClassWrapper klass)
{
- Iterator i = klass.methods.iterator();
+ Iterator<?> i = klass.methods.iterator();
while (i.hasNext())
{
MethodNode method = (MethodNode) i.next();
@@ -73,11 +73,11 @@ public class JniPrintStream
continue;
if (methodNameMap.containsKey(method.name))
{
- Integer val = (Integer) methodNameMap.get(method.name);
- methodNameMap.put(method.name, new Integer(val.intValue() + 1));
+ Integer val = methodNameMap.get(method.name);
+ methodNameMap.put(method.name, Integer.valueOf(val.intValue() + 1));
}
else
- methodNameMap.put(method.name, new Integer(1));
+ methodNameMap.put(method.name, Integer.valueOf(1));
}
}
diff --git a/tools/gnu/classpath/tools/javah/JniStubPrinter.java b/tools/gnu/classpath/tools/javah/JniStubPrinter.java
index d4b34fc20..41b90b017 100644
--- a/tools/gnu/classpath/tools/javah/JniStubPrinter.java
+++ b/tools/gnu/classpath/tools/javah/JniStubPrinter.java
@@ -87,7 +87,7 @@ public class JniStubPrinter
out.print(klass.name.replace('/', '_'));
out.println(".h>");
- Iterator i = klass.methods.iterator();
+ Iterator<?> i = klass.methods.iterator();
while (i.hasNext())
{
MethodNode method = (MethodNode) i.next();
diff --git a/tools/gnu/classpath/tools/javah/Keywords.java b/tools/gnu/classpath/tools/javah/Keywords.java
index 46543ba45..9cab62283 100644
--- a/tools/gnu/classpath/tools/javah/Keywords.java
+++ b/tools/gnu/classpath/tools/javah/Keywords.java
@@ -65,10 +65,10 @@ public class Keywords
"void", "volatile", "wchar_t",
"while", "xor", "xor_eq" };
- private static final HashSet keywords;
+ private static final HashSet<String> keywords;
static
{
- keywords = new HashSet();
+ keywords = new HashSet<String>();
for (int i = 0; i < words.length; ++i)
keywords.add(words[i]);
}
diff --git a/tools/gnu/classpath/tools/javah/Main.java b/tools/gnu/classpath/tools/javah/Main.java
index bfca44446..15fd52c8a 100644
--- a/tools/gnu/classpath/tools/javah/Main.java
+++ b/tools/gnu/classpath/tools/javah/Main.java
@@ -96,10 +96,10 @@ public class Main
boolean force;
// Map class names to class wrappers.
- HashMap classMap = new HashMap();
+ HashMap<String,ClassWrapper> classMap = new HashMap<String,ClassWrapper>();
// Map class names to lists of Text objects.
- HashMap textMap = new HashMap();
+ HashMap<String,ArrayList<Text>> textMap = new HashMap<String,ArrayList<Text>>();
void readCommandFile(String textFileName) throws OptionException
{
@@ -114,7 +114,7 @@ public class Main
}
BufferedReader reader = new BufferedReader(new InputStreamReader(fis));
String currentClass = null;
- ArrayList currentValues = null;
+ ArrayList<Text> currentValues = null;
while (true)
{
String line;
@@ -142,7 +142,7 @@ public class Main
textMap.put(currentClass, currentValues);
}
currentClass = value;
- currentValues = new ArrayList();
+ currentValues = new ArrayList<Text>();
continue;
}
if (currentClass == null)
@@ -165,7 +165,7 @@ public class Main
}
}
- void scanDirectory(File dir, final HashSet results)
+ void scanDirectory(File dir, final HashSet<Object> results)
{
File[] files = dir.listFiles(new FileFilter()
{
@@ -317,15 +317,15 @@ public class Main
return result;
}
- private void writeHeaders(HashMap klasses, Printer printer)
+ private void writeHeaders(HashMap<File,ClassWrapper> klasses, Printer printer)
throws IOException
{
- Iterator i = klasses.entrySet().iterator();
+ Iterator<Map.Entry<File,ClassWrapper>> i = klasses.entrySet().iterator();
while (i.hasNext())
{
- Map.Entry e = (Map.Entry) i.next();
- File file = (File) e.getKey();
- ClassWrapper klass = (ClassWrapper) e.getValue();
+ Map.Entry<File,ClassWrapper> e = i.next();
+ File file = e.getKey();
+ ClassWrapper klass = e.getValue();
if (verbose)
System.err.println("[writing " + klass + " as " + file + "]");
printer.printClass(file, klass);
@@ -368,7 +368,7 @@ public class Main
// First we load all of the files. That way if
// there are references between the files we will
// be loading the set that the user asked for.
- HashSet klasses = new HashSet();
+ HashSet<Object> klasses = new HashSet<Object>();
if (allDirectory != null)
scanDirectory(new File(allDirectory), klasses);
// Add the command-line arguments. We use the type of
@@ -385,8 +385,8 @@ public class Main
}
}
- Iterator i = klasses.iterator();
- HashMap results = new HashMap();
+ Iterator<Object> i = klasses.iterator();
+ HashMap<File,ClassWrapper> results = new HashMap<File,ClassWrapper>();
while (i.hasNext())
{
// Let user specify either kind of class name or a
@@ -419,9 +419,9 @@ public class Main
writeHeaders(results, printer);
}
- public ArrayList getClassTextList(String name)
+ public ArrayList<Text> getClassTextList(String name)
{
- return (ArrayList) textMap.get(name);
+ return textMap.get(name);
}
private ClassWrapper readClass(InputStream is) throws IOException
diff --git a/tools/gnu/classpath/tools/javah/MethodHelper.java b/tools/gnu/classpath/tools/javah/MethodHelper.java
index 4359523ba..3efd05019 100644
--- a/tools/gnu/classpath/tools/javah/MethodHelper.java
+++ b/tools/gnu/classpath/tools/javah/MethodHelper.java
@@ -64,7 +64,7 @@ public class MethodHelper
{
if ((meth.access & Opcodes.ACC_BRIDGE) == 0)
return null;
- Iterator i = meth.instructions.iterator();
+ Iterator<?> i = meth.instructions.iterator();
while (i.hasNext())
{
AbstractInsnNode insn = (AbstractInsnNode) i.next();
diff --git a/tools/gnu/classpath/tools/javah/PathOptionGroup.java b/tools/gnu/classpath/tools/javah/PathOptionGroup.java
index ea61eece7..8eec4cc60 100644
--- a/tools/gnu/classpath/tools/javah/PathOptionGroup.java
+++ b/tools/gnu/classpath/tools/javah/PathOptionGroup.java
@@ -55,11 +55,11 @@ import java.util.StringTokenizer;
public class PathOptionGroup
extends OptionGroup
{
- ArrayList classpath = new ArrayList();
+ ArrayList<String> classpath = new ArrayList<String>();
- ArrayList bootclasspath = new ArrayList();
+ ArrayList<String> bootclasspath = new ArrayList<String>();
- void setPath(ArrayList list, String path)
+ void setPath(ArrayList<String> list, String path)
{
list.clear();
StringTokenizer st = new StringTokenizer(path, File.pathSeparator);
@@ -69,7 +69,7 @@ public class PathOptionGroup
}
}
- void addExtDirs(ArrayList list, String path)
+ void addExtDirs(ArrayList<String> list, String path)
{
StringTokenizer tok = new StringTokenizer(path, File.pathSeparator);
while (tok.hasMoreTokens())
@@ -133,15 +133,15 @@ public class PathOptionGroup
public URLClassLoader getLoader() throws MalformedURLException
{
- ArrayList urls = new ArrayList();
+ ArrayList<URL> urls = new ArrayList<URL>();
classpath.addAll(bootclasspath);
- Iterator i = classpath.iterator();
+ Iterator<String> i = classpath.iterator();
while (i.hasNext())
{
- String f = (String) i.next();
+ String f = i.next();
urls.add(new File(f).toURL());
}
- URL[] urlArray = (URL[]) urls.toArray(new URL[0]);
+ URL[] urlArray = urls.toArray(new URL[0]);
return new URLClassLoader(urlArray);
}
}
diff --git a/tools/gnu/classpath/tools/taglets/AuthorTaglet.java b/tools/gnu/classpath/tools/taglets/AuthorTaglet.java
index 6bade8499..fd6e924f1 100644
--- a/tools/gnu/classpath/tools/taglets/AuthorTaglet.java
+++ b/tools/gnu/classpath/tools/taglets/AuthorTaglet.java
@@ -1,293 +1,293 @@
-/* gnu.classpath.tools.taglets.AuthorTaglet
- Copyright (C) 2001 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
-
-package gnu.classpath.tools.taglets;
-
-import java.util.Map;
-
-import java.util.regex.Pattern;
-import java.util.regex.Matcher;
-
-import com.sun.tools.doclets.Taglet;
-
-import com.sun.javadoc.Tag;
-
-/**
- * The default Taglet which handles Author information.
- *
- * @author Julian Scheid (julian@sektor37.de)
- */
-public class AuthorTaglet implements Taglet {
-
- /**
- * Enum class which denotes whether and how to replace email
- * addresses in author tags.
- */
- public static class EmailReplacement {
- private EmailReplacement() {}
-
- /**
- * Specifies that email addresses should not be replaced.
- */
- public static final EmailReplacement NO_REPLACEMENT = new EmailReplacement();
-
- /**
- * Specifies that author tag text matching "Real Name
- * (user@domain.tld)" is converted to "&lt;a
- * href="mailto:user@domain.tld"&gt;Real Name&lt;/a&gt;.
- */
- public static final EmailReplacement MAILTO_NAME = new EmailReplacement();
-
- /**
- * Specifies that author tag text matching "Real Name
- * (user@domain.tld)" is converted to "Real Name (&lt;a
- * href="mailto:user@domain.tld"&gt;user@domain.tld&lt;/a&gt;).
- */
- public static final EmailReplacement NAME_MAILTO_ADDRESS = new EmailReplacement();
-
- /**
- * Specifies that author tag text matching "Real Name
- * (user@domain.tld)" is converted to "Real Name (user AT
- * domain DOT tld)", where the "AT" and "DOT" replacement are
- * specified by AuthorTaglet.emailAtReplacement and
- * AuthorTaglet.emailDotReplacement.
- */
- public static final EmailReplacement NAME_MANGLED_ADDRESS = new EmailReplacement();
- }
-
- private static EmailReplacement emailReplacementType = EmailReplacement.NO_REPLACEMENT;
- private static String atReplacement = " <b>at</b> ";
- private static String dotReplacement = " <b>dot</b> ";
-
- private static final String NAME = "author";
- private static final String SINGLE_HEADER = "Author:";
- private static final String MULTI_HEADER = "Authors:";
-
- private static boolean enabled = true;
-
- /**
- * Matches <code>.</code> (dot).
- */
- private static final Pattern dotPattern = Pattern.compile("[.]");
-
- /**
- * Matches <code>@</code> (at sign).
- */
- private static final Pattern atPattern = Pattern.compile("[@]");
-
- /**
- * Matches <code>Real Name (user@domain.tld)</code>.
- */
- private static final Pattern authorEmailPattern
- = Pattern.compile("^"
- + "\\s*" // optional whitespace
- + "(" // group #1 start (real name)
- + "(?:[^\t\r\n ]|\\()+" // first name
- + "(?:\\s+(?:[^\t\r\n ]|\\()+)*" // additional names
- + ")" // group #1 end
- + "\\s*" // optional whitespace
- + "[(<]" // opening paren
- + "\\s*" // optional whitespace
- + "(" // group #2 start (email address)
- + "(" // group #3 start (email user)
- + "[A-z0-9_\\-\\.]+" // username
- + ")" // group #3 end
- + "[@]" // at sign
- + "[A-z0-9_\\-]+(?:[.][A-z0-9_\\-]+)+[A-z]" // domain
- + ")" // group #2 end
- + "\\s*" // optional whitespace
- + "(?:\\)|>)" // closing paren
- + "$");
-
- public String getName() {
- return NAME;
- }
-
- public boolean inField() {
- return true;
- }
-
- public boolean inConstructor() {
- return true;
- }
-
- public boolean inMethod() {
- return true;
- }
-
- public boolean inOverview() {
- return true;
- }
-
- public boolean inPackage() {
- return true;
- }
-
- public boolean inType() {
- return true;
- }
-
- public boolean isInlineTag() {
- return false;
- }
-
- public static void register(Map tagletMap) {
- AuthorTaglet authorTaglet = new AuthorTaglet();
- tagletMap.put(authorTaglet.getName(), authorTaglet);
- }
-
- public String toString(Tag tag) {
- if (enabled) {
- return toString(new Tag[] { tag });
- }
- else {
- return null;
- }
- }
-
- public String toString(Tag[] tags) {
- if (!enabled || tags.length == 0) {
- return null;
- }
- else {
- boolean haveValidTag = false;
- for (int i = 0; i < tags.length && !haveValidTag; ++i) {
- if (tags[i].text().length() > 0) {
- haveValidTag = true;
- }
- }
-
- if (haveValidTag) {
- StringBuffer result = new StringBuffer();
- result.append("<dl class=\"tag list\">");
- result.append("<dt class=\"tag section header\"><b>");
- if (tags.length == 1) {
- result.append(SINGLE_HEADER);
- }
- else {
- result.append(MULTI_HEADER);
- }
- result.append("</b></dt>");
- for (int i = 0; i < tags.length; i++) {
- result.append("<dd class=\"tag item\">");
- result.append(replaceEmail(tags[i].text()));
- result.append("</dd>");
- }
- result.append("</dl>");
- return result.toString();
- }
- else {
- return null;
- }
- }
- }
-
- /**
- * Reformat the tag text according to {@link #emailReplacementType}.
- */
- private String replaceEmail(String text) {
-
- if (EmailReplacement.NO_REPLACEMENT == emailReplacementType) {
- return text;
- }
- else {
- Matcher matcher = authorEmailPattern.matcher(text);
- if (matcher.matches()) {
- String realName = matcher.group(1);
- String emailAddress = matcher.group(2);
- if (EmailReplacement.MAILTO_NAME == emailReplacementType) {
- return "<a href=\"mailto:" + emailAddress + "\">" + realName + "</a>";
- }
- else if (EmailReplacement.NAME_MAILTO_ADDRESS == emailReplacementType) {
- return realName + " (<a href=\"mailto:" + emailAddress + "\">" + emailAddress + "</a>)";
- }
- else if (EmailReplacement.NAME_MANGLED_ADDRESS == emailReplacementType) {
- Matcher dotMatcher = dotPattern.matcher(emailAddress);
- Matcher atMatcher = atPattern.matcher(dotMatcher.replaceAll(dotReplacement));
- String mangledAddress = atMatcher.replaceAll(atReplacement);
- return realName + " (" + mangledAddress + ")";
- }
- else {
- // this shouldn't happen
- return text;
- }
- }
- else {
- return text;
- }
- }
- }
-
- /**
- * Set the email replacement type.
- */
- public static void setEmailReplacementType(EmailReplacement emailReplacementType)
- {
- if (null == emailReplacementType) {
- throw new NullPointerException();
- }
- AuthorTaglet.emailReplacementType = emailReplacementType;
- }
-
- /**
- * Set the HTML text by which the <code>@</code> (at sign) in email
- * addresses should be replaced if the email replacement type is
- * <code>NAME_MANGLED_ADDRESS</code>.
- */
- public static void setAtReplacement(String atReplacement)
- {
- AuthorTaglet.atReplacement = atReplacement;
- }
-
- /**
- * Set the HTML text by which the <code>.</code> (dot) in email
- * addresses should be replaced if the email replacement type is
- * <code>NAME_MANGLED_ADDRESS</code>.
- */
- public static void setDotReplacement(String dotReplacement)
- {
- AuthorTaglet.dotReplacement = dotReplacement;
- }
-
- /**
- * Enables/disables this taglet.
- */
- public static void setTagletEnabled(boolean enabled)
- {
- AuthorTaglet.enabled = enabled;
- }
-}
+/* gnu.classpath.tools.taglets.AuthorTaglet
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.taglets;
+
+import java.util.Map;
+
+import java.util.regex.Pattern;
+import java.util.regex.Matcher;
+
+import com.sun.tools.doclets.Taglet;
+
+import com.sun.javadoc.Tag;
+
+/**
+ * The default Taglet which handles Author information.
+ *
+ * @author Julian Scheid (julian@sektor37.de)
+ */
+public class AuthorTaglet implements Taglet {
+
+ /**
+ * Enum class which denotes whether and how to replace email
+ * addresses in author tags.
+ */
+ public static class EmailReplacement {
+ private EmailReplacement() {}
+
+ /**
+ * Specifies that email addresses should not be replaced.
+ */
+ public static final EmailReplacement NO_REPLACEMENT = new EmailReplacement();
+
+ /**
+ * Specifies that author tag text matching "Real Name
+ * (user@domain.tld)" is converted to "&lt;a
+ * href="mailto:user@domain.tld"&gt;Real Name&lt;/a&gt;.
+ */
+ public static final EmailReplacement MAILTO_NAME = new EmailReplacement();
+
+ /**
+ * Specifies that author tag text matching "Real Name
+ * (user@domain.tld)" is converted to "Real Name (&lt;a
+ * href="mailto:user@domain.tld"&gt;user@domain.tld&lt;/a&gt;).
+ */
+ public static final EmailReplacement NAME_MAILTO_ADDRESS = new EmailReplacement();
+
+ /**
+ * Specifies that author tag text matching "Real Name
+ * (user@domain.tld)" is converted to "Real Name (user AT
+ * domain DOT tld)", where the "AT" and "DOT" replacement are
+ * specified by AuthorTaglet.emailAtReplacement and
+ * AuthorTaglet.emailDotReplacement.
+ */
+ public static final EmailReplacement NAME_MANGLED_ADDRESS = new EmailReplacement();
+ }
+
+ private static EmailReplacement emailReplacementType = EmailReplacement.NO_REPLACEMENT;
+ private static String atReplacement = " <b>at</b> ";
+ private static String dotReplacement = " <b>dot</b> ";
+
+ private static final String NAME = "author";
+ private static final String SINGLE_HEADER = "Author:";
+ private static final String MULTI_HEADER = "Authors:";
+
+ private static boolean enabled = true;
+
+ /**
+ * Matches <code>.</code> (dot).
+ */
+ private static final Pattern dotPattern = Pattern.compile("[.]");
+
+ /**
+ * Matches <code>@</code> (at sign).
+ */
+ private static final Pattern atPattern = Pattern.compile("[@]");
+
+ /**
+ * Matches <code>Real Name (user@domain.tld)</code>.
+ */
+ private static final Pattern authorEmailPattern
+ = Pattern.compile("^"
+ + "\\s*" // optional whitespace
+ + "(" // group #1 start (real name)
+ + "(?:[^\t\r\n ]|\\()+" // first name
+ + "(?:\\s+(?:[^\t\r\n ]|\\()+)*" // additional names
+ + ")" // group #1 end
+ + "\\s*" // optional whitespace
+ + "[(<]" // opening paren
+ + "\\s*" // optional whitespace
+ + "(" // group #2 start (email address)
+ + "(" // group #3 start (email user)
+ + "[A-z0-9_\\-\\.]+" // username
+ + ")" // group #3 end
+ + "[@]" // at sign
+ + "[A-z0-9_\\-]+(?:[.][A-z0-9_\\-]+)+[A-z]" // domain
+ + ")" // group #2 end
+ + "\\s*" // optional whitespace
+ + "(?:\\)|>)" // closing paren
+ + "$");
+
+ public String getName() {
+ return NAME;
+ }
+
+ public boolean inField() {
+ return true;
+ }
+
+ public boolean inConstructor() {
+ return true;
+ }
+
+ public boolean inMethod() {
+ return true;
+ }
+
+ public boolean inOverview() {
+ return true;
+ }
+
+ public boolean inPackage() {
+ return true;
+ }
+
+ public boolean inType() {
+ return true;
+ }
+
+ public boolean isInlineTag() {
+ return false;
+ }
+
+ public static void register(Map tagletMap) {
+ AuthorTaglet authorTaglet = new AuthorTaglet();
+ tagletMap.put(authorTaglet.getName(), authorTaglet);
+ }
+
+ public String toString(Tag tag) {
+ if (enabled) {
+ return toString(new Tag[] { tag });
+ }
+ else {
+ return null;
+ }
+ }
+
+ public String toString(Tag[] tags) {
+ if (!enabled || tags.length == 0) {
+ return null;
+ }
+ else {
+ boolean haveValidTag = false;
+ for (int i = 0; i < tags.length && !haveValidTag; ++i) {
+ if (tags[i].text().length() > 0) {
+ haveValidTag = true;
+ }
+ }
+
+ if (haveValidTag) {
+ StringBuffer result = new StringBuffer();
+ result.append("<dl class=\"tag list\">");
+ result.append("<dt class=\"tag section header\"><b>");
+ if (tags.length == 1) {
+ result.append(SINGLE_HEADER);
+ }
+ else {
+ result.append(MULTI_HEADER);
+ }
+ result.append("</b></dt>");
+ for (int i = 0; i < tags.length; i++) {
+ result.append("<dd class=\"tag item\">");
+ result.append(replaceEmail(tags[i].text()));
+ result.append("</dd>");
+ }
+ result.append("</dl>");
+ return result.toString();
+ }
+ else {
+ return null;
+ }
+ }
+ }
+
+ /**
+ * Reformat the tag text according to {@link #emailReplacementType}.
+ */
+ private String replaceEmail(String text) {
+
+ if (EmailReplacement.NO_REPLACEMENT == emailReplacementType) {
+ return text;
+ }
+ else {
+ Matcher matcher = authorEmailPattern.matcher(text);
+ if (matcher.matches()) {
+ String realName = matcher.group(1);
+ String emailAddress = matcher.group(2);
+ if (EmailReplacement.MAILTO_NAME == emailReplacementType) {
+ return "<a href=\"mailto:" + emailAddress + "\">" + realName + "</a>";
+ }
+ else if (EmailReplacement.NAME_MAILTO_ADDRESS == emailReplacementType) {
+ return realName + " (<a href=\"mailto:" + emailAddress + "\">" + emailAddress + "</a>)";
+ }
+ else if (EmailReplacement.NAME_MANGLED_ADDRESS == emailReplacementType) {
+ Matcher dotMatcher = dotPattern.matcher(emailAddress);
+ Matcher atMatcher = atPattern.matcher(dotMatcher.replaceAll(dotReplacement));
+ String mangledAddress = atMatcher.replaceAll(atReplacement);
+ return realName + " (" + mangledAddress + ")";
+ }
+ else {
+ // this shouldn't happen
+ return text;
+ }
+ }
+ else {
+ return text;
+ }
+ }
+ }
+
+ /**
+ * Set the email replacement type.
+ */
+ public static void setEmailReplacementType(EmailReplacement emailReplacementType)
+ {
+ if (null == emailReplacementType) {
+ throw new NullPointerException();
+ }
+ AuthorTaglet.emailReplacementType = emailReplacementType;
+ }
+
+ /**
+ * Set the HTML text by which the <code>@</code> (at sign) in email
+ * addresses should be replaced if the email replacement type is
+ * <code>NAME_MANGLED_ADDRESS</code>.
+ */
+ public static void setAtReplacement(String atReplacement)
+ {
+ AuthorTaglet.atReplacement = atReplacement;
+ }
+
+ /**
+ * Set the HTML text by which the <code>.</code> (dot) in email
+ * addresses should be replaced if the email replacement type is
+ * <code>NAME_MANGLED_ADDRESS</code>.
+ */
+ public static void setDotReplacement(String dotReplacement)
+ {
+ AuthorTaglet.dotReplacement = dotReplacement;
+ }
+
+ /**
+ * Enables/disables this taglet.
+ */
+ public static void setTagletEnabled(boolean enabled)
+ {
+ AuthorTaglet.enabled = enabled;
+ }
+}
diff --git a/tools/gnu/classpath/tools/taglets/CopyrightTaglet.java b/tools/gnu/classpath/tools/taglets/CopyrightTaglet.java
index 656302716..6f744a9f2 100644
--- a/tools/gnu/classpath/tools/taglets/CopyrightTaglet.java
+++ b/tools/gnu/classpath/tools/taglets/CopyrightTaglet.java
@@ -1,123 +1,123 @@
-/* gnu.classpath.tools.taglets.CopyrightTaglet
- Copyright (C) 2001 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
-
-package gnu.classpath.tools.taglets;
-
-import java.util.Map;
-
-import com.sun.tools.doclets.Taglet;
-
-import com.sun.javadoc.Tag;
-
-/**
- * A simple Taglet which handles Copyright information.
- */
-public class CopyrightTaglet implements Taglet {
-
- private static final String NAME = "copyright";
- private static final String HEADER = "Copyright:";
-
- public String getName() {
- return NAME;
- }
-
- public boolean inField() {
- return true;
- }
-
- public boolean inConstructor() {
- return true;
- }
-
- public boolean inMethod() {
- return true;
- }
-
- public boolean inOverview() {
- return true;
- }
-
- public boolean inPackage() {
- return true;
- }
-
- public boolean inType() {
- return true;
- }
-
- public boolean isInlineTag() {
- return false;
- }
-
- public static void register(Map tagletMap) {
- CopyrightTaglet copyrightTaglet = new CopyrightTaglet();
- tagletMap.put(copyrightTaglet.getName(), copyrightTaglet);
- }
-
- public String toString(Tag tag) {
- return toString(new Tag[] { tag });
- }
-
- public String toString(Tag[] tags) {
- if (tags.length == 0) {
- return null;
- }
- else {
- boolean haveValidTag = false;
- for (int i = 0; i < tags.length && !haveValidTag; ++i) {
- if (tags[i].text().length() > 0) {
- haveValidTag = true;
- }
- }
-
- if (haveValidTag) {
- StringBuffer result = new StringBuffer();
- result.append("<dl>");
- for (int i = 0; i < tags.length; i++) {
- if (tags[i].text().length() > 0) {
- result.append("<dt><i>Copyright &#169; " + tags[i].text() + "</i></dt>");
- }
- }
- result.append("</dl>");
- return result.toString();
- }
- else {
- return null;
- }
- }
- }
-}
+/* gnu.classpath.tools.taglets.CopyrightTaglet
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.taglets;
+
+import java.util.Map;
+
+import com.sun.tools.doclets.Taglet;
+
+import com.sun.javadoc.Tag;
+
+/**
+ * A simple Taglet which handles Copyright information.
+ */
+public class CopyrightTaglet implements Taglet {
+
+ private static final String NAME = "copyright";
+ private static final String HEADER = "Copyright:";
+
+ public String getName() {
+ return NAME;
+ }
+
+ public boolean inField() {
+ return true;
+ }
+
+ public boolean inConstructor() {
+ return true;
+ }
+
+ public boolean inMethod() {
+ return true;
+ }
+
+ public boolean inOverview() {
+ return true;
+ }
+
+ public boolean inPackage() {
+ return true;
+ }
+
+ public boolean inType() {
+ return true;
+ }
+
+ public boolean isInlineTag() {
+ return false;
+ }
+
+ public static void register(Map tagletMap) {
+ CopyrightTaglet copyrightTaglet = new CopyrightTaglet();
+ tagletMap.put(copyrightTaglet.getName(), copyrightTaglet);
+ }
+
+ public String toString(Tag tag) {
+ return toString(new Tag[] { tag });
+ }
+
+ public String toString(Tag[] tags) {
+ if (tags.length == 0) {
+ return null;
+ }
+ else {
+ boolean haveValidTag = false;
+ for (int i = 0; i < tags.length && !haveValidTag; ++i) {
+ if (tags[i].text().length() > 0) {
+ haveValidTag = true;
+ }
+ }
+
+ if (haveValidTag) {
+ StringBuffer result = new StringBuffer();
+ result.append("<dl>");
+ for (int i = 0; i < tags.length; i++) {
+ if (tags[i].text().length() > 0) {
+ result.append("<dt><i>Copyright &#169; " + tags[i].text() + "</i></dt>");
+ }
+ }
+ result.append("</dl>");
+ return result.toString();
+ }
+ else {
+ return null;
+ }
+ }
+ }
+}
diff --git a/tools/gnu/classpath/tools/taglets/DeprecatedTaglet.java b/tools/gnu/classpath/tools/taglets/DeprecatedTaglet.java
index 92f3b3921..aae4ad357 100644
--- a/tools/gnu/classpath/tools/taglets/DeprecatedTaglet.java
+++ b/tools/gnu/classpath/tools/taglets/DeprecatedTaglet.java
@@ -1,132 +1,132 @@
-/* gnu.classpath.tools.taglets.DeprecatedTaglet
- Copyright (C) 2001 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
-
-package gnu.classpath.tools.taglets;
-
-import java.util.Map;
-
-import com.sun.tools.doclets.Taglet;
-
-import com.sun.javadoc.Tag;
-
-/**
- * The default Taglet which handles deprecated information.
- *
- * @author Julian Scheid (julian@sektor37.de)
- */
-public class DeprecatedTaglet implements Taglet {
-
- private static final String NAME = "deprecated";
- private static final String HEADER = "Deprecated:";
-
- private static boolean enabled = true;
-
- public String getName() {
- return NAME;
- }
-
- public boolean inField() {
- return true;
- }
-
- public boolean inConstructor() {
- return true;
- }
-
- public boolean inMethod() {
- return true;
- }
-
- public boolean inOverview() {
- return true;
- }
-
- public boolean inPackage() {
- return true;
- }
-
- public boolean inType() {
- return true;
- }
-
- public boolean isInlineTag() {
- return false;
- }
-
- public static void register(Map tagletMap) {
- DeprecatedTaglet deprecatedTaglet = new DeprecatedTaglet();
- tagletMap.put(deprecatedTaglet.getName(), deprecatedTaglet);
- }
-
- public String toString(Tag tag) {
- if (enabled) {
- return toString(new Tag[] { tag });
- }
- else {
- return null;
- }
- }
-
- public String toString(Tag[] tags) {
- if (!enabled || tags.length == 0) {
- return null;
- }
- else {
-
- StringBuffer result = new StringBuffer();
- result.append("<div class=\"classdoc-tag-section-header\">");
- result.append(HEADER);
- result.append("</div>");
- result.append("<dl class=\"classdoc-list\">");
- for (int i = 0; i < tags.length; i++) {
- result.append("<dt>");
- result.append(tags[i].text());
- result.append("</dt>");
- }
- result.append("</dl>");
- return result.toString();
- }
- }
-
- /**
- * Enables/disables this taglet.
- */
- public static void setTagletEnabled(boolean enabled)
- {
- DeprecatedTaglet.enabled = enabled;
- }
-}
+/* gnu.classpath.tools.taglets.DeprecatedTaglet
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.taglets;
+
+import java.util.Map;
+
+import com.sun.tools.doclets.Taglet;
+
+import com.sun.javadoc.Tag;
+
+/**
+ * The default Taglet which handles deprecated information.
+ *
+ * @author Julian Scheid (julian@sektor37.de)
+ */
+public class DeprecatedTaglet implements Taglet {
+
+ private static final String NAME = "deprecated";
+ private static final String HEADER = "Deprecated:";
+
+ private static boolean enabled = true;
+
+ public String getName() {
+ return NAME;
+ }
+
+ public boolean inField() {
+ return true;
+ }
+
+ public boolean inConstructor() {
+ return true;
+ }
+
+ public boolean inMethod() {
+ return true;
+ }
+
+ public boolean inOverview() {
+ return true;
+ }
+
+ public boolean inPackage() {
+ return true;
+ }
+
+ public boolean inType() {
+ return true;
+ }
+
+ public boolean isInlineTag() {
+ return false;
+ }
+
+ public static void register(Map tagletMap) {
+ DeprecatedTaglet deprecatedTaglet = new DeprecatedTaglet();
+ tagletMap.put(deprecatedTaglet.getName(), deprecatedTaglet);
+ }
+
+ public String toString(Tag tag) {
+ if (enabled) {
+ return toString(new Tag[] { tag });
+ }
+ else {
+ return null;
+ }
+ }
+
+ public String toString(Tag[] tags) {
+ if (!enabled || tags.length == 0) {
+ return null;
+ }
+ else {
+
+ StringBuffer result = new StringBuffer();
+ result.append("<div class=\"classdoc-tag-section-header\">");
+ result.append(HEADER);
+ result.append("</div>");
+ result.append("<dl class=\"classdoc-list\">");
+ for (int i = 0; i < tags.length; i++) {
+ result.append("<dt>");
+ result.append(tags[i].text());
+ result.append("</dt>");
+ }
+ result.append("</dl>");
+ return result.toString();
+ }
+ }
+
+ /**
+ * Enables/disables this taglet.
+ */
+ public static void setTagletEnabled(boolean enabled)
+ {
+ DeprecatedTaglet.enabled = enabled;
+ }
+}
diff --git a/tools/gnu/classpath/tools/taglets/GenericTaglet.java b/tools/gnu/classpath/tools/taglets/GenericTaglet.java
index 3a32647cb..34eac2bad 100644
--- a/tools/gnu/classpath/tools/taglets/GenericTaglet.java
+++ b/tools/gnu/classpath/tools/taglets/GenericTaglet.java
@@ -1,157 +1,157 @@
-/* gnu.classpath.tools.taglets.GenericTaglet
- Copyright (C) 2001 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
-
-package gnu.classpath.tools.taglets;
-
-import java.util.Map;
-
-import com.sun.tools.doclets.Taglet;
-
-import com.sun.javadoc.Tag;
-
-/**
- * A taglet which can be configured at runtime.
- *
- * @author Julian Scheid (julian@sektor37.de)
- */
-public class GenericTaglet implements Taglet {
-
- private String name = "since";
- private String header = "Since:";
-
- private boolean scopeOverview;
- private boolean scopePackage;
- private boolean scopeType;
- private boolean scopeConstructor;
- private boolean scopeMethod;
- private boolean scopeField;
-
- private boolean enabled = true;
-
- public GenericTaglet(String name,
- String header,
- boolean scopeOverview,
- boolean scopePackage,
- boolean scopeType,
- boolean scopeConstructor,
- boolean scopeMethod,
- boolean scopeField)
- {
- this.name = name;
- this.header = header;
- this.scopeOverview = scopeOverview;
- this.scopePackage = scopePackage;
- this.scopeType = scopeType;
- this.scopeConstructor = scopeConstructor;
- this.scopeMethod = scopeMethod;
- this.scopeField = scopeField;
- }
-
- public String getName() {
- return name;
- }
-
- public boolean inField() {
- return scopeField;
- }
-
- public boolean inConstructor() {
- return scopeConstructor;
- }
-
- public boolean inMethod() {
- return scopeMethod;
- }
-
- public boolean inOverview() {
- return scopeOverview;
- }
-
- public boolean inPackage() {
- return scopePackage;
- }
-
- public boolean inType() {
- return scopeType;
- }
-
- public boolean isInlineTag() {
- return false;
- }
-
- public void register(Map tagletMap) {
- tagletMap.put(getName(), this);
- }
-
- public String toString(Tag tag) {
- if (enabled) {
- return toString(new Tag[] { tag });
- }
- else {
- return null;
- }
- }
-
- public String toString(Tag[] tags) {
- if (!enabled || tags.length == 0) {
- return null;
- }
- else {
-
- StringBuffer result = new StringBuffer();
- result.append("<div class=\"classdoc-tag-section-header\">");
- result.append(header);
- result.append("</div>");
- result.append("<dl class=\"classdoc-list\">");
- for (int i = 0; i < tags.length; i++) {
- result.append("<dt>");
- result.append(tags[i].text());
- result.append("</dt>");
- }
- result.append("</dl>");
- return result.toString();
- }
- }
-
- /**
- * Enables/disables this taglet.
- */
- public void setTagletEnabled(boolean enabled)
- {
- this.enabled = enabled;
- }
-}
+/* gnu.classpath.tools.taglets.GenericTaglet
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.taglets;
+
+import java.util.Map;
+
+import com.sun.tools.doclets.Taglet;
+
+import com.sun.javadoc.Tag;
+
+/**
+ * A taglet which can be configured at runtime.
+ *
+ * @author Julian Scheid (julian@sektor37.de)
+ */
+public class GenericTaglet implements Taglet {
+
+ private String name = "since";
+ private String header = "Since:";
+
+ private boolean scopeOverview;
+ private boolean scopePackage;
+ private boolean scopeType;
+ private boolean scopeConstructor;
+ private boolean scopeMethod;
+ private boolean scopeField;
+
+ private boolean enabled = true;
+
+ public GenericTaglet(String name,
+ String header,
+ boolean scopeOverview,
+ boolean scopePackage,
+ boolean scopeType,
+ boolean scopeConstructor,
+ boolean scopeMethod,
+ boolean scopeField)
+ {
+ this.name = name;
+ this.header = header;
+ this.scopeOverview = scopeOverview;
+ this.scopePackage = scopePackage;
+ this.scopeType = scopeType;
+ this.scopeConstructor = scopeConstructor;
+ this.scopeMethod = scopeMethod;
+ this.scopeField = scopeField;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public boolean inField() {
+ return scopeField;
+ }
+
+ public boolean inConstructor() {
+ return scopeConstructor;
+ }
+
+ public boolean inMethod() {
+ return scopeMethod;
+ }
+
+ public boolean inOverview() {
+ return scopeOverview;
+ }
+
+ public boolean inPackage() {
+ return scopePackage;
+ }
+
+ public boolean inType() {
+ return scopeType;
+ }
+
+ public boolean isInlineTag() {
+ return false;
+ }
+
+ public void register(Map tagletMap) {
+ tagletMap.put(getName(), this);
+ }
+
+ public String toString(Tag tag) {
+ if (enabled) {
+ return toString(new Tag[] { tag });
+ }
+ else {
+ return null;
+ }
+ }
+
+ public String toString(Tag[] tags) {
+ if (!enabled || tags.length == 0) {
+ return null;
+ }
+ else {
+
+ StringBuffer result = new StringBuffer();
+ result.append("<div class=\"classdoc-tag-section-header\">");
+ result.append(header);
+ result.append("</div>");
+ result.append("<dl class=\"classdoc-list\">");
+ for (int i = 0; i < tags.length; i++) {
+ result.append("<dt>");
+ result.append(tags[i].text());
+ result.append("</dt>");
+ }
+ result.append("</dl>");
+ return result.toString();
+ }
+ }
+
+ /**
+ * Enables/disables this taglet.
+ */
+ public void setTagletEnabled(boolean enabled)
+ {
+ this.enabled = enabled;
+ }
+}
diff --git a/tools/gnu/classpath/tools/taglets/SinceTaglet.java b/tools/gnu/classpath/tools/taglets/SinceTaglet.java
index 5c9927b62..aa1e11491 100644
--- a/tools/gnu/classpath/tools/taglets/SinceTaglet.java
+++ b/tools/gnu/classpath/tools/taglets/SinceTaglet.java
@@ -1,161 +1,161 @@
-/* gnu.classpath.tools.taglets.SinceTaglet
- Copyright (C) 2001 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
-
-package gnu.classpath.tools.taglets;
-
-import java.util.Map;
-
-import com.sun.tools.doclets.Taglet;
-
-import com.sun.javadoc.Tag;
-
-import gnu.classpath.tools.doclets.InlineTagRenderer;
-
-/**
- * The default Taglet which handles since information.
- *
- * @author Julian Scheid (julian@sektor37.de)
- */
-public class SinceTaglet implements GnuExtendedTaglet {
-
- private static final String NAME = "since";
- private static final String HEADER = "Since:";
-
- private static boolean enabled = true;
-
- private InlineTagRenderer inlineTagRenderer;
-
- public SinceTaglet(InlineTagRenderer inlineTagRenderer)
- {
- this.inlineTagRenderer = inlineTagRenderer;
- }
-
- public String getName() {
- return NAME;
- }
-
- public boolean inField() {
- return true;
- }
-
- public boolean inConstructor() {
- return true;
- }
-
- public boolean inMethod() {
- return true;
- }
-
- public boolean inOverview() {
- return true;
- }
-
- public boolean inPackage() {
- return true;
- }
-
- public boolean inType() {
- return true;
- }
-
- public boolean isInlineTag() {
- return false;
- }
-
- public String toString(Tag tag) {
- // should raise assertion
- if (enabled) {
- return toString(new Tag[] { tag });
- }
- else {
- return null;
- }
- }
-
- public String toString(Tag[] tags) {
- // should raise assertion
- return toString(tags, null);
- }
-
- public String toString(Tag tag, TagletContext context)
- {
- return null;
- }
-
- public String toString(Tag[] tags, TagletContext context)
- {
- if (!enabled || tags.length == 0) {
- return null;
- }
- else {
- boolean haveValidTag = false;
- for (int i = 0; i < tags.length && !haveValidTag; ++i) {
- if (tags[i].text().length() > 0) {
- haveValidTag = true;
- }
- }
-
- if (haveValidTag) {
- StringBuffer result = new StringBuffer();
- result.append("<dl class=\"tag list\">");
- result.append("<dt class=\"tag section header\"><b>");
- result.append(HEADER);
- result.append("</b></dt>");
- for (int i = 0; i < tags.length; ++i) {
- if (tags[i].text().length() > 0) {
- result.append("<dd>");
- result.append(inlineTagRenderer.renderInlineTags(tags[i].inlineTags(), context));
- result.append("</dd>");
- }
- }
- result.append("</dl>");
- return result.toString();
- }
- else {
- return null;
- }
- }
- }
-
- /**
- * Enables/disables this taglet.
- */
- public static void setTagletEnabled(boolean enabled)
- {
- SinceTaglet.enabled = enabled;
- }
-}
+/* gnu.classpath.tools.taglets.SinceTaglet
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.taglets;
+
+import java.util.Map;
+
+import com.sun.tools.doclets.Taglet;
+
+import com.sun.javadoc.Tag;
+
+import gnu.classpath.tools.doclets.InlineTagRenderer;
+
+/**
+ * The default Taglet which handles since information.
+ *
+ * @author Julian Scheid (julian@sektor37.de)
+ */
+public class SinceTaglet implements GnuExtendedTaglet {
+
+ private static final String NAME = "since";
+ private static final String HEADER = "Since:";
+
+ private static boolean enabled = true;
+
+ private InlineTagRenderer inlineTagRenderer;
+
+ public SinceTaglet(InlineTagRenderer inlineTagRenderer)
+ {
+ this.inlineTagRenderer = inlineTagRenderer;
+ }
+
+ public String getName() {
+ return NAME;
+ }
+
+ public boolean inField() {
+ return true;
+ }
+
+ public boolean inConstructor() {
+ return true;
+ }
+
+ public boolean inMethod() {
+ return true;
+ }
+
+ public boolean inOverview() {
+ return true;
+ }
+
+ public boolean inPackage() {
+ return true;
+ }
+
+ public boolean inType() {
+ return true;
+ }
+
+ public boolean isInlineTag() {
+ return false;
+ }
+
+ public String toString(Tag tag) {
+ // should raise assertion
+ if (enabled) {
+ return toString(new Tag[] { tag });
+ }
+ else {
+ return null;
+ }
+ }
+
+ public String toString(Tag[] tags) {
+ // should raise assertion
+ return toString(tags, null);
+ }
+
+ public String toString(Tag tag, TagletContext context)
+ {
+ return null;
+ }
+
+ public String toString(Tag[] tags, TagletContext context)
+ {
+ if (!enabled || tags.length == 0) {
+ return null;
+ }
+ else {
+ boolean haveValidTag = false;
+ for (int i = 0; i < tags.length && !haveValidTag; ++i) {
+ if (tags[i].text().length() > 0) {
+ haveValidTag = true;
+ }
+ }
+
+ if (haveValidTag) {
+ StringBuffer result = new StringBuffer();
+ result.append("<dl class=\"tag list\">");
+ result.append("<dt class=\"tag section header\"><b>");
+ result.append(HEADER);
+ result.append("</b></dt>");
+ for (int i = 0; i < tags.length; ++i) {
+ if (tags[i].text().length() > 0) {
+ result.append("<dd>");
+ result.append(inlineTagRenderer.renderInlineTags(tags[i].inlineTags(), context));
+ result.append("</dd>");
+ }
+ }
+ result.append("</dl>");
+ return result.toString();
+ }
+ else {
+ return null;
+ }
+ }
+ }
+
+ /**
+ * Enables/disables this taglet.
+ */
+ public static void setTagletEnabled(boolean enabled)
+ {
+ SinceTaglet.enabled = enabled;
+ }
+}
diff --git a/tools/gnu/classpath/tools/taglets/VersionTaglet.java b/tools/gnu/classpath/tools/taglets/VersionTaglet.java
index 62e4d566c..fadb972ea 100644
--- a/tools/gnu/classpath/tools/taglets/VersionTaglet.java
+++ b/tools/gnu/classpath/tools/taglets/VersionTaglet.java
@@ -1,153 +1,153 @@
-/* gnu.classpath.tools.taglets.VersionTaglet
- Copyright (C) 2001 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
-
-package gnu.classpath.tools.taglets;
-
-import java.util.Map;
-
-import com.sun.tools.doclets.Taglet;
-
-import com.sun.javadoc.Tag;
-
-/**
- * The default Taglet which handles version information.
- *
- * @author Julian Scheid (julian@sektor37.de)
- */
-public class VersionTaglet implements Taglet {
-
- private static final String NAME = "version";
- private static final String HEADER = "Version:";
-
- private static boolean enabled = true;
-
- public String getName() {
- return NAME;
- }
-
- public boolean inField() {
- return true;
- }
-
- public boolean inConstructor() {
- return true;
- }
-
- public boolean inMethod() {
- return true;
- }
-
- public boolean inOverview() {
- return true;
- }
-
- public boolean inPackage() {
- return true;
- }
-
- public boolean inType() {
- return true;
- }
-
- public boolean isInlineTag() {
- return false;
- }
-
- public static void register(Map tagletMap) {
- VersionTaglet versionTaglet = new VersionTaglet();
- tagletMap.put(versionTaglet.getName(), versionTaglet);
- }
-
- public String toString(Tag tag) {
- if (enabled) {
- return toString(new Tag[] { tag });
- }
- else {
- return null;
- }
- }
-
- public String toString(Tag[] tags) {
- if (!enabled || tags.length == 0) {
- return null;
- }
- else {
- boolean haveValidTag = false;
- for (int i = 0; i < tags.length && !haveValidTag; ++i) {
- if (tags[i].text().length() > 0) {
- haveValidTag = true;
- }
- }
-
- if (haveValidTag) {
-
- StringBuffer result = new StringBuffer();
- result.append("<dl class=\"tag list\">");
- result.append("</dl>");
- result.append("<dt class=\"tag section header\"><b>");
- result.append(HEADER);
- result.append("</b></dt><dd>");
- boolean firstEntry = true;
- for (int i = 0; i < tags.length; i++) {
- if (tags[i].text().length() > 0) {
- if (!firstEntry) {
- result.append(", ");
- }
- else {
- firstEntry = false;
- }
- result.append(tags[i].text());
- }
- }
- result.append("</dd>");
- result.append("</dl>");
- return result.toString();
- }
- else {
- return null;
- }
- }
- }
-
- /**
- * Enables/disables this taglet.
- */
- public static void setTagletEnabled(boolean enabled)
- {
- VersionTaglet.enabled = enabled;
- }
-}
+/* gnu.classpath.tools.taglets.VersionTaglet
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.taglets;
+
+import java.util.Map;
+
+import com.sun.tools.doclets.Taglet;
+
+import com.sun.javadoc.Tag;
+
+/**
+ * The default Taglet which handles version information.
+ *
+ * @author Julian Scheid (julian@sektor37.de)
+ */
+public class VersionTaglet implements Taglet {
+
+ private static final String NAME = "version";
+ private static final String HEADER = "Version:";
+
+ private static boolean enabled = true;
+
+ public String getName() {
+ return NAME;
+ }
+
+ public boolean inField() {
+ return true;
+ }
+
+ public boolean inConstructor() {
+ return true;
+ }
+
+ public boolean inMethod() {
+ return true;
+ }
+
+ public boolean inOverview() {
+ return true;
+ }
+
+ public boolean inPackage() {
+ return true;
+ }
+
+ public boolean inType() {
+ return true;
+ }
+
+ public boolean isInlineTag() {
+ return false;
+ }
+
+ public static void register(Map tagletMap) {
+ VersionTaglet versionTaglet = new VersionTaglet();
+ tagletMap.put(versionTaglet.getName(), versionTaglet);
+ }
+
+ public String toString(Tag tag) {
+ if (enabled) {
+ return toString(new Tag[] { tag });
+ }
+ else {
+ return null;
+ }
+ }
+
+ public String toString(Tag[] tags) {
+ if (!enabled || tags.length == 0) {
+ return null;
+ }
+ else {
+ boolean haveValidTag = false;
+ for (int i = 0; i < tags.length && !haveValidTag; ++i) {
+ if (tags[i].text().length() > 0) {
+ haveValidTag = true;
+ }
+ }
+
+ if (haveValidTag) {
+
+ StringBuffer result = new StringBuffer();
+ result.append("<dl class=\"tag list\">");
+ result.append("</dl>");
+ result.append("<dt class=\"tag section header\"><b>");
+ result.append(HEADER);
+ result.append("</b></dt><dd>");
+ boolean firstEntry = true;
+ for (int i = 0; i < tags.length; i++) {
+ if (tags[i].text().length() > 0) {
+ if (!firstEntry) {
+ result.append(", ");
+ }
+ else {
+ firstEntry = false;
+ }
+ result.append(tags[i].text());
+ }
+ }
+ result.append("</dd>");
+ result.append("</dl>");
+ return result.toString();
+ }
+ else {
+ return null;
+ }
+ }
+ }
+
+ /**
+ * Enables/disables this taglet.
+ */
+ public static void setTagletEnabled(boolean enabled)
+ {
+ VersionTaglet.enabled = enabled;
+ }
+}