From 0a7f6ac8bee428e35b432a1e6c224998e37f4e59 Mon Sep 17 00:00:00 2001
From: Andrew John Hughes
Date: Fri, 20 Mar 2009 13:03:45 +0000
Subject: Cleanup generic warnings in gjavah.
2009-03-20 Andrew John Hughes
* 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.
---
ChangeLog | 34 +
.../gnu/classpath/tools/FileSystemClassLoader.java | 626 +--
.../classpath/tools/doclets/xmldoclet/Driver.java | 4902 ++++++++++----------
.../tools/doclets/xmldoclet/Driver1_4.java | 168 +-
.../tools/doclets/xmldoclet/HtmlRepairer.java | 1382 +++---
.../tools/doclets/xmldoclet/TargetContext.java | 206 +-
.../xmldoclet/doctranslet/OutputFileInfo.java | 132 +-
tools/gnu/classpath/tools/gjdoc/ErrorReporter.java | 242 +-
.../gnu/classpath/tools/gjdoc/TemporaryStore.java | 264 +-
tools/gnu/classpath/tools/gjdoc/WritableType.java | 88 +-
tools/gnu/classpath/tools/javah/ClassWrapper.java | 50 +-
.../gnu/classpath/tools/javah/CniPrintStream.java | 4 +-
.../gnu/classpath/tools/javah/CniStubPrinter.java | 2 +-
tools/gnu/classpath/tools/javah/GcjhMain.java | 2 +-
.../classpath/tools/javah/JniIncludePrinter.java | 4 +-
.../gnu/classpath/tools/javah/JniPrintStream.java | 10 +-
.../gnu/classpath/tools/javah/JniStubPrinter.java | 2 +-
tools/gnu/classpath/tools/javah/Keywords.java | 4 +-
tools/gnu/classpath/tools/javah/Main.java | 30 +-
tools/gnu/classpath/tools/javah/MethodHelper.java | 2 +-
.../gnu/classpath/tools/javah/PathOptionGroup.java | 16 +-
.../gnu/classpath/tools/taglets/AuthorTaglet.java | 586 +--
.../classpath/tools/taglets/CopyrightTaglet.java | 246 +-
.../classpath/tools/taglets/DeprecatedTaglet.java | 264 +-
.../gnu/classpath/tools/taglets/GenericTaglet.java | 314 +-
tools/gnu/classpath/tools/taglets/SinceTaglet.java | 322 +-
.../gnu/classpath/tools/taglets/VersionTaglet.java | 306 +-
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
+
+ * 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
+
+ * 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
* 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 ClassLoader 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 ClassLoader 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 /dev/null.
- */
- 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 null.
- */
- 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
- * indentStep 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 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 0) {
- printOpenTag(2, "serializableFields");
-
- FieldDoc[] sfields = classDoc.serializableFields();
- for (int i=0, ilim=sfields.length; i 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");
- }
- //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");
- }
- 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= 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:Xaoptcmf:\".");
- }
- }
- }
-
- // 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, "");
- println("");
- 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, "");
-
- 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, "");
- ClassDoc[] specifiedClasses = rootDoc.specifiedClasses();
- for (int i=0, ilim=specifiedClasses.length; i");
- PackageDoc[] specifiedPackages = rootDoc.specifiedPackages();
- for (int i=0, ilim=specifiedPackages.length; i");
- {
- 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, "");
- PackageDoc[] packages = rootDoc.specifiedPackages();
- for (int i=0, ilim=packages.length; i");
- ClassDoc[] sumclasses = rootDoc.classes();
- for (int i=0, ilim=sumclasses.length; i");
- 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("");
- println("");
-
- 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; irm -Rf directory
- *
- * @return true on success
- */
- private static boolean deleteRecursive(File directory) {
-
- boolean success = true;
-
- File[] files = directory.listFiles();
-
- for (int i=0, ilim=files.length; i");
- }
-
- /**
- * 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 < with <,
- * > with > and
- * & with &.
- *
- * @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,
- "<", "<"
- ),
- ">", ">"
- ),
- "&", "&"
- );
- }
-
- /**
- * Replaces all occurences of string needle within string
- * haystack by string replacement.
- *
- * @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 needle 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=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= 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 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, "");
- println("");
- 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; i0) {
- 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/dev/null.
+ */
+ 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 null.
+ */
+ 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
+ * indentStep 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 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 0) {
+ printOpenTag(2, "serializableFields");
+
+ FieldDoc[] sfields = classDoc.serializableFields();
+ for (int i=0, ilim=sfields.length; i 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");
+ }
+ //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");
+ }
+ 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= 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:Xaoptcmf:\".");
+ }
+ }
+ }
+
+ // 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, "");
+ println("");
+ 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, "");
+
+ 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, "");
+ ClassDoc[] specifiedClasses = rootDoc.specifiedClasses();
+ for (int i=0, ilim=specifiedClasses.length; i");
+ PackageDoc[] specifiedPackages = rootDoc.specifiedPackages();
+ for (int i=0, ilim=specifiedPackages.length; i");
+ {
+ 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, "");
+ PackageDoc[] packages = rootDoc.specifiedPackages();
+ for (int i=0, ilim=packages.length; i");
+ ClassDoc[] sumclasses = rootDoc.classes();
+ for (int i=0, ilim=sumclasses.length; i");
+ 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("");
+ println("");
+
+ 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; irm -Rf directory
+ *
+ * @return true on success
+ */
+ private static boolean deleteRecursive(File directory) {
+
+ boolean success = true;
+
+ File[] files = directory.listFiles();
+
+ for (int i=0, ilim=files.length; i");
+ }
+
+ /**
+ * 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 < with <,
+ * > with > and
+ * & with &.
+ *
+ * @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,
+ "<", "<"
+ ),
+ ">", ">"
+ ),
+ "&", "&"
+ );
+ }
+
+ /**
+ * Replaces all occurences of string needle within string
+ * haystack by string replacement.
+ *
+ * @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 needle 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=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= 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 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, "");
+ println("");
+ 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; i0) {
+ 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");
- }
- */
-
- 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, ""+fieldDoc.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, "");
+ }
+ */
+
+ 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, ""+fieldDoc.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 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 '' 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=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("<"+tag+">");
- return;
- }
-
- tagName = tagName.toLowerCase();
-
- if (_isLeadingTag && "p".equals(tagName) && !isEndTag && throwAwayLeadingPara) {
- return;
- }
-
- if ("p".equals(tagName) || "br".equals(tagName) || "hr".equals(tagName)) {
- // throw away
and
- if (isEndTag) {
- return;
- }
- // make sure every
is a
and every is a
- 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=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 '
...
...');
- 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; i0) {
- haveText(buf.toString());
- buf.setLength(0);
- }
- }
- else if ('>'==c) {
- // assume this is a greater-than sign
- buf.append(">");
- }
- 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("&");
- 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("&");
- buf.append(">");
- state = STATE_INITIAL;
- }
- else if ('&'==c) {
- buf.append("&");
- buf.append("&");
- state = STATE_INITIAL;
- }
- else if (-1==c) {
- buf.append("&");
- 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=0) {
- //continue;
-
- // new: assume this is a less-sign
- haveText("<"+c);
- state = STATE_INITIAL;
- }
- else if ('/'==c) {
- buf.append((char)c);
- state = STATE_TAG;
- }
- else if ('<'==c) {
- // assume this is a less-sign
- haveText("<<");
- state = STATE_INITIAL;
- }
- else if ('>'==c) {
- // assume this is a less-sign
- haveText("<>");
- 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("<"+(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 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 '' 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=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("<"+tag+">");
+ return;
+ }
+
+ tagName = tagName.toLowerCase();
+
+ if (_isLeadingTag && "p".equals(tagName) && !isEndTag && throwAwayLeadingPara) {
+ return;
+ }
+
+ if ("p".equals(tagName) || "br".equals(tagName) || "hr".equals(tagName)) {
+ // throw away and
+ if (isEndTag) {
+ return;
+ }
+ // make sure every
is a
and every is a
+ 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=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 '
...
...');
+ 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; i0) {
+ haveText(buf.toString());
+ buf.setLength(0);
+ }
+ }
+ else if ('>'==c) {
+ // assume this is a greater-than sign
+ buf.append(">");
+ }
+ 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("&");
+ 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("&");
+ buf.append(">");
+ state = STATE_INITIAL;
+ }
+ else if ('&'==c) {
+ buf.append("&");
+ buf.append("&");
+ state = STATE_INITIAL;
+ }
+ else if (-1==c) {
+ buf.append("&");
+ 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=0) {
+ //continue;
+
+ // new: assume this is a less-sign
+ haveText("<"+c);
+ state = STATE_INITIAL;
+ }
+ else if ('/'==c) {
+ buf.append((char)c);
+ state = STATE_TAG;
+ }
+ else if ('<'==c) {
+ // assume this is a less-sign
+ haveText("<<");
+ state = STATE_INITIAL;
+ }
+ else if ('>'==c) {
+ // assume this is a less-sign
+ haveText("<>");
+ 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("<"+(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 DocErrorReporter: writes
- * to System.err.
- */
-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 true, no notices will be emitted.
- */
- private boolean quiet = false;
-
- /*
- * When true, 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 DocErrorReporter: writes
+ * to System.err.
+ */
+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 true, no notices will be emitted.
+ */
+ private boolean quiet = false;
+
+ /*
+ * When true, 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.
- *
- * Consider the following problem:
- *
- * 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
- * }
- * }
- *
- *
- * In method bar(), the array cannot be garbage
- * collected because the local variable hugeArray in
- * method foo() still holds a reference to the array.
- *
- *
- * When calling bar(new long[1000000]); in
- * arr the array can be collected in
- * bar(), but that way it can't be initialized in
- * foo(). A local variable is needed for
- * initialization, but the variable can't be cleared before it is
- * passed to bar()!
- *
- * TemporaryStore is the solution for this
- * dilemma. The modified method foo() which uses a
- * TemporaryStore object would look like this:
- *
- *
- * 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());
- * }
- *
- *
- * When control flow is transferred to bar(),
- * foo() will hold no more references to the array
- * and so it can be garbage collected in bar().
- *
- */
-public class TemporaryStore {
-
- private Object storedObject;
-
- /**
- * Temporarily store the given object for passing it to a
- * different method.
- *
- * 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.
- *
- *
- * 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.
+ *
+ * Consider the following problem:
+ *
+ * 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
+ * }
+ * }
+ *
+ *
+ * In method bar(), the array cannot be garbage
+ * collected because the local variable hugeArray in
+ * method foo() still holds a reference to the array.
+ *
+ *
+ * When calling bar(new long[1000000]); in
+ * arr the array can be collected in
+ * bar(), but that way it can't be initialized in
+ * foo(). A local variable is needed for
+ * initialization, but the variable can't be cleared before it is
+ * passed to bar()!
+ *
+ * TemporaryStore is the solution for this
+ * dilemma. The modified method foo() which uses a
+ * TemporaryStore object would look like this:
+ *
+ *
+ * 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());
+ * }
+ *
+ *
+ * When control flow is transferred to bar(),
+ * foo() will hold no more references to the array
+ * and so it can be garbage collected in bar().
+ *
+ */
+public class TemporaryStore {
+
+ private Object storedObject;
+
+ /**
+ * Temporarily store the given object for passing it to a
+ * different method.
+ *
+ * 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.
+ *
+ *
+ * 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 interfaceClasses;
// The virtual table for this class.
- ArrayList vtable;
+ ArrayList vtable;
// A set of all the bridge method targets we've found.
- HashSet bridgeTargets;
+ HashSet bridgeTargets;
// A set of all the method names in this class.
- HashSet methodNames = new HashSet();
+ HashSet methodNames = new HashSet();
// 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 methodNameMap = new HashMap();
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();
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(superClass.vtable);
+ bridgeTargets = new HashSet(superClass.bridgeTargets);
+ methodNameMap = new HashMap(superClass.methodNameMap);
}
else
{
// Object.
- vtable = new ArrayList();
- bridgeTargets = new HashSet();
- methodNameMap = new HashMap();
+ vtable = new ArrayList();
+ bridgeTargets = new HashSet();
+ methodNameMap = new HashMap();
}
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 textList)
{
if (textList == null)
return;
- Iterator i = textList.iterator();
+ Iterator 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 textList)
throws IOException
{
printTextList(out, Text.PREPEND, textList);
@@ -337,7 +337,7 @@ public class ClassWrapper
{
linkSupers();
- ArrayList textList = classpath.getClassTextList(name);
+ ArrayList 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 allClasses = new HashSet();
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 commands = new ArrayList();
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 methodNameMap = new HashMap();
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 keywords;
static
{
- keywords = new HashSet();
+ keywords = new HashSet();
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 classMap = new HashMap();
// Map class names to lists of Text objects.
- HashMap textMap = new HashMap();
+ HashMap> textMap = new HashMap>();
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 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();
continue;
}
if (currentClass == null)
@@ -165,7 +165,7 @@ public class Main
}
}
- void scanDirectory(File dir, final HashSet results)
+ void scanDirectory(File dir, final HashSet