checkstyle passes

git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@46 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/build-tools/doctool/src/com/google/doctool/Booklet.java b/build-tools/doctool/src/com/google/doctool/Booklet.java
index 5ed1e03..d8a3b05 100644
--- a/build-tools/doctool/src/com/google/doctool/Booklet.java
+++ b/build-tools/doctool/src/com/google/doctool/Booklet.java
@@ -1,4 +1,18 @@
-// Copyright 2006 Google Inc. All Rights Reserved.
+/*
+ * Copyright 2006 Google Inc.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
 package com.google.doctool;
 
 import com.google.doctool.LinkResolver.ExtraClassResolver;
@@ -31,6 +45,10 @@
 import java.util.Iterator;
 import java.util.Stack;
 
+/**
+ * Generates XML from Javadoc source, with particular idioms to make it possible
+ * to translate into either expository doc or API doc.
+ */
 public class Booklet {
 
   private static final String OPT_BKCODE = "-bkcode";
@@ -46,12 +64,13 @@
   }
 
   public static int optionLength(String option) {
-    if (option.equals(OPT_BKOUT))
+    if (option.equals(OPT_BKOUT)) {
       return 2;
-    else if (option.equals(OPT_BKDOCPKG))
+    } else if (option.equals(OPT_BKDOCPKG)) {
       return 2;
-    else if (option.equals(OPT_BKCODE))
+    } else if (option.equals(OPT_BKCODE)) {
       return 1;
+    }
     return 0;
   }
 
@@ -60,8 +79,9 @@
     try {
       fr = new FileReader(position.file());
       BufferedReader br = new BufferedReader(fr);
-      for (int i = 0, n = position.line() - 1; i < n; ++i)
+      for (int i = 0, n = position.line() - 1; i < n; ++i) {
         br.readLine();
+      }
 
       StringBuffer lines = new StringBuffer();
       String line = br.readLine();
@@ -70,11 +90,14 @@
       boolean seenSemiColonOrBrace = false;
       while (line != null) {
         if (indent == -1) {
-          for (indent = 0; Character.isWhitespace(line.charAt(indent)); ++indent);
+          for (indent = 0; Character.isWhitespace(line.charAt(indent)); ++indent) {
+            // just accumulate
+          }
         }
 
-        if (line.length() >= indent)
+        if (line.length() >= indent) {
           line = line.substring(indent);
+        }
 
         lines.append(line + "\n");
         for (int i = 0, n = line.length(); i < n; ++i) {
@@ -102,8 +125,9 @@
       e.printStackTrace();
     } finally {
       try {
-        if (fr != null)
+        if (fr != null) {
           fr.close();
+        }
       } catch (IOException e) {
         e.printStackTrace();
       }
@@ -122,8 +146,9 @@
   }
 
   private static Booklet getBooklet() {
-    if (sBooklet == null)
+    if (sBooklet == null) {
       sBooklet = new Booklet();
+    }
     return sBooklet;
   }
 
@@ -154,7 +179,7 @@
 
     if (fOutputPath == null) {
       reporter.printError("You must specify an output directory with "
-        + OPT_BKOUT);
+          + OPT_BKOUT);
       return false;
     }
 
@@ -301,7 +326,7 @@
       myTitle = fRootDoc.name();
     } else {
       throw new IllegalStateException(
-        "Expected only a member, type, or package");
+          "Expected only a member, type, or package");
     }
 
     Doc parent = getParentDoc(doc);
@@ -326,29 +351,34 @@
   }
 
   private void emitModifiers(ProgramElementDoc doc) {
-    if (doc.isPrivate())
+    if (doc.isPrivate()) {
       beginEndln("isPrivate");
-    else if (doc.isProtected())
+    } else if (doc.isProtected()) {
       beginEndln("isProtected");
-    else if (doc.isPublic())
+    } else if (doc.isPublic()) {
       beginEndln("isPublic");
-    else if (doc.isPackagePrivate())
+    } else if (doc.isPackagePrivate()) {
       beginEndln("isPackagePrivate");
+    }
 
-    if (doc.isStatic())
+    if (doc.isStatic()) {
       beginEndln("isStatic");
+    }
 
-    if (doc.isFinal())
+    if (doc.isFinal()) {
       beginEndln("isFinal");
+    }
 
     if (doc instanceof MethodDoc) {
       MethodDoc methodDoc = (MethodDoc) doc;
 
-      if (methodDoc.isAbstract())
+      if (methodDoc.isAbstract()) {
         beginEndln("isAbstract");
+      }
 
-      if (methodDoc.isSynchronized())
+      if (methodDoc.isSynchronized()) {
         beginEndln("isSynchronized");
+      }
     }
   }
 
@@ -361,10 +391,11 @@
   private void emitType(Type type) {
     ClassDoc typeAsClass = type.asClassDoc();
 
-    if (typeAsClass != null)
+    if (typeAsClass != null) {
       begin("type", "ref", getId(typeAsClass));
-    else
+    } else {
       begin("type");
+    }
 
     String typeName = type.typeName();
     String dims = type.dimension();
@@ -411,9 +442,10 @@
         // Try the superinterfaces of this interface.
         //
         MethodDoc foundMethodDoc = findMatchingInterfaceMethodDoc(
-          currentIntfDoc.interfaces(), methodDoc);
-        if (foundMethodDoc != null)
+            currentIntfDoc.interfaces(), methodDoc);
+        if (foundMethodDoc != null) {
           return foundMethodDoc;
+        }
       }
     }
 
@@ -442,14 +474,15 @@
   }
 
   private String getId(MemberDoc memberDoc) {
-    if (memberDoc.isMethod())
+    if (memberDoc.isMethod()) {
       return getId((MethodDoc) memberDoc);
-    else if (memberDoc.isConstructor())
+    } else if (memberDoc.isConstructor()) {
       return getId((ConstructorDoc) memberDoc);
-    else if (memberDoc.isField())
+    } else if (memberDoc.isField()) {
       return getId((FieldDoc) memberDoc);
-    else
+    } else {
       throw new RuntimeException("Unknown member type");
+    }
   }
 
   private String getId(PackageDoc packageDoc) {
@@ -474,7 +507,7 @@
       return null;
     } else {
       throw new IllegalStateException(
-        "Expected only a member, type, or package");
+          "Expected only a member, type, or package");
     }
   }
 
@@ -485,10 +518,11 @@
     SourcePosition classPos = memberDoc.containingClass().position();
     int classLine = classPos.line();
 
-    if (memberLine == classLine)
+    if (memberLine == classLine) {
       return true;
-    else
+    } else {
       return false;
+    }
   }
 
   private void process(ClassDoc enclosing, ClassDoc classDoc) {
@@ -500,15 +534,16 @@
       return;
     }
 
-    if (classDoc.isInterface())
+    if (classDoc.isInterface()) {
       beginln("interface");
-    else
+    } else {
       beginln("class");
+    }
 
     emitIdentity(getId(classDoc), classDoc.name());
     emitLocation(classDoc);
     emitDescription(enclosing, classDoc, classDoc.firstSentenceTags(),
-      classDoc.inlineTags());
+        classDoc.inlineTags());
     emitOutOfLineTags(classDoc.tags());
     emitModifiers(classDoc);
 
@@ -533,16 +568,19 @@
     }
 
     FieldDoc[] fda = classDoc.fields();
-    for (int i = 0; i < fda.length; i++)
+    for (int i = 0; i < fda.length; i++) {
       process(classDoc, fda[i]);
+    }
 
     ConstructorDoc[] ctorDocs = classDoc.constructors();
-    for (int i = 0; i < ctorDocs.length; i++)
+    for (int i = 0; i < ctorDocs.length; i++) {
       process(classDoc, ctorDocs[i]);
+    }
 
     MethodDoc[] methods = classDoc.methods();
-    for (int i = 0; i < methods.length; i++)
+    for (int i = 0; i < methods.length; i++) {
       process(classDoc, methods[i]);
+    }
 
     endln();
   }
@@ -585,10 +623,11 @@
             // If so, borrow its description.
             //
             superMethodDoc = findMatchingInterfaceMethodDoc(
-              classDocToTry.interfaces(), methodDoc);
+                classDocToTry.interfaces(), methodDoc);
 
-            if (superMethodDoc != null)
+            if (superMethodDoc != null) {
               break;
+            }
 
             classDocToTry = classDocToTry.superclass();
           }
@@ -609,7 +648,7 @@
     }
 
     emitDescription(enclosing, memberDoc, memberDoc.firstSentenceTags(),
-      memberDoc.inlineTags());
+        memberDoc.inlineTags());
     emitOutOfLineTags(memberDoc.tags());
     emitModifiers(memberDoc);
 
@@ -619,8 +658,9 @@
 
     // Return type if it's a method
     //
-    if (memberDoc instanceof MethodDoc)
+    if (memberDoc instanceof MethodDoc) {
       emitType(((MethodDoc) memberDoc).returnType());
+    }
 
     // Parameters
     //
@@ -682,14 +722,15 @@
 
     String commentText = fieldDoc.commentText();
     if (fieldDoc.isPrivate()
-      && (commentText == null || commentText.length() == 0))
+        && (commentText == null || commentText.length() == 0)) {
       return;
+    }
 
     beginln("field");
     emitIdentity(fieldDoc.qualifiedName(), fieldDoc.name());
     emitLocation(fieldDoc);
     emitDescription(enclosing, fieldDoc, fieldDoc.firstSentenceTags(),
-      fieldDoc.inlineTags());
+        fieldDoc.inlineTags());
     emitOutOfLineTags(fieldDoc.tags());
     emitModifiers(fieldDoc);
     emitType(fieldDoc.type());
@@ -702,7 +743,7 @@
     emitIdentity(packageDoc.name(), packageDoc.name());
     emitLocation(packageDoc);
     emitDescription(null, packageDoc, packageDoc.firstSentenceTags(),
-      packageDoc.inlineTags());
+        packageDoc.inlineTags());
     emitOutOfLineTags(packageDoc.tags());
 
     // Top-level classes
@@ -761,7 +802,7 @@
       emitIdentity(fRootDocId, title);
       emitLocation(rootDoc);
       emitDescription(null, rootDoc, rootDoc.firstSentenceTags(),
-        rootDoc.inlineTags());
+          rootDoc.inlineTags());
       emitOutOfLineTags(rootDoc.tags());
 
       // Create a list of the packages to iterate over.
@@ -786,7 +827,7 @@
         // included.
         //
         if (fPackagesToGenerate == null
-          || fPackagesToGenerate.contains(packageName)) {
+            || fPackagesToGenerate.contains(packageName)) {
           PackageDoc pd = fRootDoc.packageNamed(packageName);
           process(pd);
         }
@@ -817,8 +858,9 @@
       Tag[] titleTag = cd.tags("@title");
       if (titleTag.length > 0) {
         title = titleTag[0].text().trim();
-        if (title.length() == 0)
+        if (title.length() == 0) {
           title = null;
+        }
       }
     } else if (null != (pd = seeTag.referencedPackage())) {
       ref = getId(pd);
@@ -836,8 +878,9 @@
       } else {
         label = seeTag.text();
 
-        if (label.endsWith("."))
+        if (label.endsWith(".")) {
           label = label.substring(0, label.length() - 1);
+        }
 
         // Rip off all but the last interesting part to prevent fully-qualified
         // names everywhere.
@@ -849,8 +892,9 @@
           // Use the class name plus the member name.
           //
           label = label.substring(last1 + 1).replace('#', '.');
-        } else if (last1 != -1)
+        } else if (last1 != -1) {
           label = label.substring(last1 + 1);
+        }
 
         if (label.charAt(0) == '.') {
           // Started with "#" so remove the dot.
@@ -866,7 +910,7 @@
       end();
     } else {
       fRootDoc.printWarning(seeTag.position(),
-        "Unverifiable cross-reference to '" + seeTag.text() + "'");
+          "Unverifiable cross-reference to '" + seeTag.text() + "'");
       // The link probably won't work, but emit it anyway.
       begin("link");
       text(label != null ? label.trim() : "");
@@ -918,14 +962,15 @@
   }
 
   private ExtraClassResolver getExtraClassResolver(Tag tag) {
-    
+
     if (tag.holder() instanceof PackageDoc) {
       return new ExtraClassResolver() {
         public ClassDoc findClass(String className) {
           return fRootDoc.classNamed(className);
-        }};
+        }
+      };
     }
-    
+
     return null;
   }
 
diff --git a/build-tools/doctool/src/com/google/doctool/DocTool.java b/build-tools/doctool/src/com/google/doctool/DocTool.java
index 44b58e6..be36083 100644
--- a/build-tools/doctool/src/com/google/doctool/DocTool.java
+++ b/build-tools/doctool/src/com/google/doctool/DocTool.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2006 Google Inc.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
 package com.google.doctool;
 
 import org.xml.sax.Attributes;
@@ -37,13 +52,12 @@
 import javax.xml.transform.stream.StreamResult;
 import javax.xml.transform.stream.StreamSource;
 
+/**
+ * Orchestrates the behavior of {@link Booklet}, {@link SplitterJoiner} and
+ * other tools to create user documentation and API documentation.
+ */
 public class DocTool {
 
-  public static final class GenType {
-    private GenType() {
-    }
-  }
-
   private class ImageCopier extends DefaultHandler {
 
     private ImageCopier(File htmlDir) {
@@ -74,7 +88,7 @@
                 File outFileDir = outFile.getParentFile();
                 if (!outFileDir.exists() && !outFileDir.mkdirs()) {
                   fErr.println("Unable to create image output dir "
-                    + outFileDir);
+                      + outFileDir);
                   break;
                 }
               }
@@ -94,7 +108,7 @@
   }
 
   private static final Pattern IN_XML_FILENAME = Pattern.compile(
-    "(.+)\\.([^\\.]+)\\.xml", Pattern.CASE_INSENSITIVE);
+      "(.+)\\.([^\\.]+)\\.xml", Pattern.CASE_INSENSITIVE);
 
   public static void main(String[] args) {
     DocToolFactory factory = new DocToolFactory();
@@ -144,16 +158,18 @@
           factory.addToImagePath(entries[entryIndex]);
         }
       } else {
-        if (factory.getFileType() == null)
+        if (factory.getFileType() == null) {
           factory.setFileType(args[i]);
-        else
+        } else {
           factory.setFileBase(args[i]);
+        }
       }
     }
 
     DocTool docTool = factory.create(System.out, System.err);
-    if (docTool != null)
+    if (docTool != null) {
       docTool.process();
+    }
   }
 
   public static boolean recursiveDelete(File file) {
@@ -161,8 +177,9 @@
       File[] children = file.listFiles();
       if (children != null) {
         for (int i = 0; i < children.length; i++) {
-          if (!recursiveDelete(children[i]))
+          if (!recursiveDelete(children[i])) {
             return false;
+          }
         }
       }
     }
@@ -211,12 +228,12 @@
           String arg = args[i + 1];
           if (arg.startsWith("-")) {
             System.out.println("Warning: arg to " + name
-              + " looks more like a flag: " + arg);
+                + " looks more like a flag: " + arg);
           }
           return arg;
         } else {
           throw new IllegalArgumentException("Expecting an argument after "
-            + name);
+              + name);
         }
       }
     }
@@ -228,8 +245,9 @@
    */
   private static boolean tryParseFlag(String[] args, int i, String name) {
     if (i < args.length) {
-      if (args[i].equals(name))
+      if (args[i].equals(name)) {
         return true;
+      }
     }
     return false;
   }
@@ -307,16 +325,18 @@
     } catch (SAXException e) {
       caught = e;
       Exception inner = e.getException();
-      if (inner != null)
+      if (inner != null) {
         caught = inner;
+      }
     } catch (ParserConfigurationException e) {
       caught = e;
     } catch (IOException e) {
       caught = e;
     } finally {
       try {
-        if (fileReader != null)
+        if (fileReader != null) {
           fileReader.close();
+        }
       } catch (IOException e) {
         e.printStackTrace(fErr);
       }
@@ -340,7 +360,7 @@
       for (int i = 0, n = children.length; i < n; ++i) {
         File child = children[i];
         String childName = parentPackage
-          + (parentPackage.length() > 0 ? "." : "") + child.getName();
+            + (parentPackage.length() > 0 ? "." : "") + child.getName();
         if (child.isDirectory()) {
           // Recurse
           findSourcePackages(results, child, childName);
@@ -357,16 +377,18 @@
     String path = "";
     for (int i = 0, n = entries.length; i < n; ++i) {
       File entry = entries[i];
-      if (i > 0)
+      if (i > 0) {
         path += pathSep;
+      }
       path += entry.getAbsolutePath();
     }
     return path;
   }
 
   private void freshenIf(File file) {
-    if (!file.isFile())
+    if (!file.isFile()) {
       return;
+    }
 
     String name = file.getName();
     Matcher matcher = IN_XML_FILENAME.matcher(name);
@@ -390,15 +412,16 @@
     File htmlDir = new File(fOutDir, "html");
     if (!htmlDir.exists() && !htmlDir.mkdirs()) {
       fErr.println("Cannot create html output directory "
-        + htmlDir.getAbsolutePath());
+          + htmlDir.getAbsolutePath());
       return false;
     }
 
     // Merge all *.topics.xml into one topics.xml file.
     //
     File mergedTopicsFile = new File(fOutDir, "topics.xml");
-    if (!mergeTopics(mergedTopicsFile))
+    if (!mergeTopics(mergedTopicsFile)) {
       return false;
+    }
 
     // Parse it all to find the images and copy them over.
     //
@@ -419,8 +442,9 @@
 
       // Split the merged htmls into many html files.
       //
-      if (!splitHtmls(mergedHtmlsFile))
+      if (!splitHtmls(mergedHtmlsFile)) {
         return false;
+      }
 
       // Create a table of contents.
       //
@@ -439,8 +463,7 @@
         e.printStackTrace(fErr);
       }
     } else {
-      fOut
-        .println("Skipping html creation since nothing seems to have changed since "
+      fOut.println("Skipping html creation since nothing seems to have changed since "
           + mergedHtmlsFile.getAbsolutePath());
     }
 
@@ -463,8 +486,9 @@
         }
         return sw.toString();
       } finally {
-        if (in != null)
+        if (in != null) {
           in.close();
+        }
       }
     } catch (IOException e) {
       throw new RuntimeException(e);
@@ -516,9 +540,9 @@
       // Produce XML from JavaDoc.
       //
       String fileName = fFileBase + "." + fFileType + ".xml";
-      if (!runBooklet(new File(fOutDir, fileName)))
+      if (!runBooklet(new File(fOutDir, fileName))) {
         return false;
-
+      }
     }
 
     // Process existing files to get them into topics format.
@@ -528,8 +552,9 @@
 
     if (fGenerateHtml) {
       // Merge into HTML.
-      if (!genHtml())
+      if (!genHtml()) {
         return false;
+      }
     }
 
     return true;
@@ -585,7 +610,7 @@
     }
 
     args.add("-breakiterator");
-    
+
     // Specify the set of input packages (needed by JavaDoc)
     args.addAll(srcPackages);
 
@@ -628,11 +653,11 @@
       StreamSource xsltSource = new StreamSource(new StringReader(xslt));
       Transformer transformer = transformerFactory.newTransformer(xsltSource);
       transformer.setOutputProperty(
-        javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes");
+          javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes");
       transformer.setOutputProperty(javax.xml.transform.OutputKeys.INDENT,
-        "yes");
+          "yes");
       transformer.setOutputProperty(
-        "{http://xml.apache.org/xslt}indent-amount", "4");
+          "{http://xml.apache.org/xslt}indent-amount", "4");
 
       if (params != null) {
         for (Iterator iter = params.entrySet().iterator(); iter.hasNext();) {
diff --git a/build-tools/doctool/src/com/google/doctool/DocToolFactory.java b/build-tools/doctool/src/com/google/doctool/DocToolFactory.java
index 7cc51f9..f0027f9 100644
--- a/build-tools/doctool/src/com/google/doctool/DocToolFactory.java
+++ b/build-tools/doctool/src/com/google/doctool/DocToolFactory.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2006 Google Inc.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
 package com.google.doctool;
 
 import java.io.File;
@@ -5,6 +20,9 @@
 import java.util.ArrayList;
 import java.util.List;
 
+/**
+ * Supports two-phase creation of {@link DocTool} objects.
+ */
 public class DocToolFactory {
 
   public DocToolFactory() {
@@ -35,7 +53,7 @@
     if (localOutDir == null) {
       localOutDir = new File(System.getProperty("user.dir"), "out");
       out.println("Using default output directory: "
-        + localOutDir.getAbsolutePath());
+          + localOutDir.getAbsolutePath());
     }
 
     File[] classPath = null;
@@ -48,16 +66,17 @@
         err.println("A file base must be specified when generating doc");
         return null;
       }
-//      if (overviewFile == null) {
-//        err
-//          .println("An overview file must be specified when generating doc; if you don't have one, use this:");
-//        err.println("<html><body>");
-//        err.println(" " + fileBase + "documentation");
-//        err.println(" @id " + fileBase + "-doc");
-//        err.println(" @title Documentation for " + fileBase);
-//        err.println("</body></html>");
-//        return null;
-//      }
+      // if (overviewFile == null) {
+      // err
+      // .println("An overview file must be specified when generating doc; if
+      // you don't have one, use this:");
+      // err.println("<html><body>");
+      // err.println(" " + fileBase + "documentation");
+      // err.println(" @id " + fileBase + "-doc");
+      // err.println(" @title Documentation for " + fileBase);
+      // err.println("</body></html>");
+      // return null;
+      // }
       classPath = (File[]) classPathEntries.toArray(new File[0]);
       sourcePath = (File[]) srcPathEntries.toArray(new File[0]);
       packageNames = (String[]) packageNameEntries.toArray(new String[0]);
@@ -75,8 +94,7 @@
       }
     }
 
-    String[] htmlFileBaseArray = (String[]) htmlFileBases
-      .toArray(new String[0]);
+    String[] htmlFileBaseArray = (String[]) htmlFileBases.toArray(new String[0]);
 
     // Handle -imagepath
     //
@@ -89,8 +107,8 @@
     File[] imagePath = (File[]) imagePathEntries.toArray(new File[0]);
 
     return new DocTool(out, err, localOutDir, generateHtml, title,
-      htmlFileBaseArray, fileType, fileBase, overviewFile, sourcePath,
-      classPath, packageNames, imagePath);
+        htmlFileBaseArray, fileType, fileBase, overviewFile, sourcePath,
+        classPath, packageNames, imagePath);
   }
 
   public String getFileType() {
diff --git a/build-tools/doctool/src/com/google/doctool/LinkResolver.java b/build-tools/doctool/src/com/google/doctool/LinkResolver.java
index c36d2c0..f16777d 100644
--- a/build-tools/doctool/src/com/google/doctool/LinkResolver.java
+++ b/build-tools/doctool/src/com/google/doctool/LinkResolver.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2006 Google Inc.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
 package com.google.doctool;
 
 import com.sun.javadoc.ClassDoc;
@@ -9,8 +24,14 @@
 import com.sun.javadoc.SourcePosition;
 import com.sun.javadoc.Tag;
 
+/**
+ * Methods related to resolving cross-references in source.
+ */
 public class LinkResolver {
 
+  /**
+   * Abstracts out mechanisms for finding different bits of doc.
+   */
   public interface ExtraClassResolver {
     ClassDoc findClass(String className);
   }
@@ -56,7 +77,7 @@
       }
       if (targetClass == null) {
         System.err.println(tag.position().toString()
-          + ": unable to resolve class " + className + " for " + tag);
+            + ": unable to resolve class " + className + " for " + tag);
         System.exit(1);
       }
     }
@@ -66,7 +87,7 @@
     }
 
     String paramSig = methodSig.substring(methodSig.indexOf('(') + 1,
-      methodSig.lastIndexOf(')'));
+        methodSig.lastIndexOf(')'));
     String[] resolvedParamTypes;
     if (paramSig.length() > 0) {
       String[] unresolvedParamTypes = paramSig.split("\\s*,\\s*");
@@ -78,8 +99,8 @@
         }
         if (paramType == null) {
           System.err.println(tag.position().toString()
-            + ": unable to resolve class " + unresolvedParamTypes[i] + " for "
-            + tag);
+              + ": unable to resolve class " + unresolvedParamTypes[i]
+              + " for " + tag);
           System.exit(1);
         }
         resolvedParamTypes[i] = paramType.qualifiedTypeName();
@@ -102,7 +123,7 @@
         }
         for (int j = 0; j < tryParams.length; ++j) {
           if (!tryParams[j].type().qualifiedTypeName().equals(
-            resolvedParamTypes[j])) {
+              resolvedParamTypes[j])) {
             // param type mismatch
             continue outer;
           }
@@ -112,9 +133,9 @@
     }
 
     System.err.println(tag.position().toString()
-      + ": unable to resolve method for " + tag);
+        + ": unable to resolve method for " + tag);
     if (possibleOverloads.length() > 0) {
-      System.err.println("Possible overloads:" + possibleOverloads);
+      System.err.println("Possible overloads: " + possibleOverloads);
     }
     System.exit(1);
     return null;
diff --git a/build-tools/doctool/src/com/google/doctool/ResourceIncluder.java b/build-tools/doctool/src/com/google/doctool/ResourceIncluder.java
index d3afc89..91757d7 100644
--- a/build-tools/doctool/src/com/google/doctool/ResourceIncluder.java
+++ b/build-tools/doctool/src/com/google/doctool/ResourceIncluder.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2006 Google Inc.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
 package com.google.doctool;
 
 import com.sun.javadoc.Tag;
@@ -7,6 +22,9 @@
 import java.io.IOException;
 import java.io.InputStream;
 
+/**
+ * Utility methods related to including external resources in doc.
+ */
 public class ResourceIncluder {
 
   public static String getResourceFromClasspathScrubbedForHTML(Tag tag) {
@@ -18,7 +36,7 @@
       return contents;
     } catch (IOException e) {
       System.err.println(tag.position().toString()
-        + ": unable to include resource " + partialPath + " for tag " + tag);
+          + ": unable to include resource " + partialPath + " for tag " + tag);
       System.exit(1);
       return null;
     }
@@ -29,8 +47,9 @@
    */
   public static void close(InputStream is) {
     try {
-      if (is != null)
+      if (is != null) {
         is.close();
+      }
     } catch (IOException e) {
     }
   }
@@ -42,7 +61,7 @@
   private static String getFileFromClassPath(String partialPath)
       throws IOException {
     InputStream in = ResourceIncluder.class.getClassLoader().getResourceAsStream(
-      partialPath);
+        partialPath);
     try {
       if (in == null) {
         throw new FileNotFoundException(partialPath);
diff --git a/build-tools/doctool/src/com/google/doctool/SplitterJoiner.java b/build-tools/doctool/src/com/google/doctool/SplitterJoiner.java
index 473f830..abe678d 100644
--- a/build-tools/doctool/src/com/google/doctool/SplitterJoiner.java
+++ b/build-tools/doctool/src/com/google/doctool/SplitterJoiner.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2006 Google Inc.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
 package com.google.doctool;
 
 import org.w3c.dom.Document;
@@ -21,9 +36,9 @@
 import javax.xml.transform.stream.StreamResult;
 
 /**
- * Takes an input stream and splits it into multiple files.
- * A new file begins when a line in the input stream begins with a specific <emph>prefix</emph> 
- * followed by whitespace then an absolute or relative file name to create.
+ * Takes an input stream and splits it into multiple files. A new file begins
+ * when a line in the input stream begins with a specific prefix followed by
+ * whitespace then an absolute or relative file name to create.
  */
 public class SplitterJoiner {
 
@@ -36,8 +51,9 @@
 
       // Close the current reader, if any.
       //
-      if (reader != null)
+      if (reader != null) {
         reader.close();
+      }
 
       // Open the next reader.
       //                
@@ -45,7 +61,7 @@
       inputFile = new File(file);
       if (!inputFile.exists()) {
         System.err.println("Error: Cannot find input file "
-          + inputFile.getPath());
+            + inputFile.getPath());
         return;
       }
       reader = new BufferedReader(new FileReader(inputFile));
@@ -68,8 +84,9 @@
         } else if (line.startsWith(prefix)) {
           // Close the current writer.
           //
-          if (writer != null)
+          if (writer != null) {
             writer.close();
+          }
 
           // Create the next writer.
           //
@@ -78,16 +95,15 @@
           if (!outFile.isAbsolute() && inputFile != null) {
             // Make the created file relative to the input file.
             //
-            File absoluteParentDir = inputFile.getCanonicalFile()
-              .getParentFile();
+            File absoluteParentDir = inputFile.getCanonicalFile().getParentFile();
             outFile = new File(absoluteParentDir, outPath);
             outFile.getParentFile().mkdirs();
           }
 
           writer = new PrintWriter(new FileWriter(outFile), true);
-          
+
           writer.println("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">");
-          
+
         } else if (writer != null) {
           // Write this line to the current file.
           //
@@ -100,8 +116,9 @@
         line = reader.readLine();
       }
 
-      if (writer != null)
+      if (writer != null) {
         writer.close();
+      }
     }
   }
 
@@ -110,10 +127,11 @@
     StreamResult result = new StreamResult(out);
     TransformerFactory transformerFactory = TransformerFactory.newInstance();
     Transformer transformer = transformerFactory.newTransformer();
-    transformer.setOutputProperty(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes");
+    transformer.setOutputProperty(
+        javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes");
     transformer.setOutputProperty(javax.xml.transform.OutputKeys.INDENT, "yes");
     transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount",
-      "4");
+        "4");
 
     Node child = doc.getDocumentElement().getFirstChild();
     while (child != null) {
@@ -127,13 +145,12 @@
       throws IOException, ParserConfigurationException, SAXException,
       TransformerException {
     if (!inputFile.exists()) {
-      System.err
-        .println("Error: Cannot find input file " + inputFile.getPath());
+      System.err.println("Error: Cannot find input file " + inputFile.getPath());
       return;
     }
 
     if (inputFile.getCanonicalFile().equals(outputFile)) {
-      // skip 
+      // skip
       return;
     }
 
@@ -188,8 +205,9 @@
           if (children != null) {
             for (int j = 0; j < children.length; ++j) {
               if (children[j].isFile()
-                && children[j].getPath().endsWith(".xml"))
+                  && children[j].getPath().endsWith(".xml")) {
                 emitFile(out, outputFile, children[j]);
+              }
             }
           }
         }
@@ -211,8 +229,9 @@
   }
 
   private static boolean isNewerThan(File file, long lastModified) {
-    if (file.isFile())
+    if (file.isFile()) {
       return file.lastModified() > lastModified;
+    }
 
     File[] children = file.listFiles();
     if (children != null) {
@@ -230,19 +249,13 @@
   private static void help() {
     System.out.println("Usage: SplitterJoiner split infile+");
     System.out.println("Usage: SplitterJoiner join tag outfile (infile|dir)+");
-    System.out
-      .println("\tsplit         indicates that inputs file should be split into multiple output files");
-    System.out
-      .println("\tjoin          indicates xml files (or directories) should be merged into one big xml file (on stdout)");
-    System.out
-      .println("\ttag           when joining, the outermost xml tag name");
-    System.out
-      .println("\toutfile       when joining, the file to write the joined output into");
+    System.out.println("\tsplit         indicates that inputs file should be split into multiple output files");
+    System.out.println("\tjoin          indicates xml files (or directories) should be merged into one big xml file (on stdout)");
+    System.out.println("\ttag           when joining, the outermost xml tag name");
+    System.out.println("\toutfile       when joining, the file to write the joined output into");
     System.out.println("\tinfile        if splitting, an input file to split");
-    System.out
-      .println("\t              if joining, a file whose contents should be merged in");
-    System.out
-      .println("\tdir           when joining, a directory whose xml files' contents should be merged in");
+    System.out.println("\t              if joining, a file whose contents should be merged in");
+    System.out.println("\tdir           when joining, a directory whose xml files' contents should be merged in");
   }
 
   public static void main(String[] args) throws IOException {
@@ -262,12 +275,12 @@
       System.arraycopy(args, 3, files, 0, args.length - 3);
       merge(args[1], args[2], files);
     } else {
-      if (!args[0].equals("-h") && !args[0].equals("-?"))
+      if (!args[0].equals("-h") && !args[0].equals("-?")) {
         System.err.println("Error: don't know '" + args[0] + "'");
+      }
       help();
       return;
     }
-
   }
 
 }
diff --git a/build-tools/doctool/src/com/google/doctool/custom/ExampleTaglet.java b/build-tools/doctool/src/com/google/doctool/custom/ExampleTaglet.java
index f2b99ba..d29a4af 100644
--- a/build-tools/doctool/src/com/google/doctool/custom/ExampleTaglet.java
+++ b/build-tools/doctool/src/com/google/doctool/custom/ExampleTaglet.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2006 Google Inc.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
 package com.google.doctool.custom;
 
 import com.google.doctool.Booklet;
@@ -11,6 +26,9 @@
 
 import java.util.Map;
 
+/**
+ * A taglet for slurping examples into javadoc output.
+ */
 public class ExampleTaglet implements Taglet {
 
   public static void register(Map tagletMap) {
@@ -56,11 +74,11 @@
 
   public String toString(Tag tag) {
     SourcePosition position = LinkResolver.resolveLink(tag,
-      new ExtraClassResolver() {
-        public ClassDoc findClass(String className) {
-          return GWTJavaDoclet.root.classNamed(className);
-        }
-      });
+        new ExtraClassResolver() {
+          public ClassDoc findClass(String className) {
+            return GWTJavaDoclet.root.classNamed(className);
+          }
+        });
 
     String slurpSource = Booklet.slurpSource(position);
     return "<blockquote><pre>" + slurpSource + "</pre></blockquote>";
diff --git a/build-tools/doctool/src/com/google/doctool/custom/GWTJavaDoclet.java b/build-tools/doctool/src/com/google/doctool/custom/GWTJavaDoclet.java
index 1c883f8..ad9e747 100644
--- a/build-tools/doctool/src/com/google/doctool/custom/GWTJavaDoclet.java
+++ b/build-tools/doctool/src/com/google/doctool/custom/GWTJavaDoclet.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2006 Google Inc.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
 package com.google.doctool.custom;
 
 import com.sun.javadoc.Doclet;
@@ -9,13 +24,16 @@
 import java.util.Arrays;
 import java.util.List;
 
+/**
+ * A doclet for using GWT-specific tags in standard javadoc output.
+ */
 public class GWTJavaDoclet extends Doclet {
 
   static RootDoc root = null;
 
-  private static final String[] TAGLET_ARGS = new String[]{
-    "-taglet", ExampleTaglet.class.getName(), "-taglet",
-    TipTaglet.class.getName(), "-taglet", IncludeTaglet.class.getName()};
+  private static final String[] TAGLET_ARGS = new String[] {
+      "-taglet", ExampleTaglet.class.getName(), "-taglet",
+      TipTaglet.class.getName(), "-taglet", IncludeTaglet.class.getName()};
 
   public static void main(String[] args) {
     List examplePackages = new ArrayList();
@@ -45,11 +63,11 @@
     List myArgs = new ArrayList();
     myArgs.addAll(filteredArgs);
     myArgs.addAll(examplePackages);
-    Main.execute(name, name, (String[]) myArgs.toArray(new String[]{}));
+    Main.execute(name, name, (String[]) myArgs.toArray(new String[] {}));
 
     // Now delegate to the real javadoc without the example packages
     filteredArgs.addAll(0, Arrays.asList(TAGLET_ARGS));
-    Main.execute((String[]) filteredArgs.toArray(new String[]{}));
+    Main.execute((String[]) filteredArgs.toArray(new String[] {}));
   }
 
   public static int optionLength(String option) {
diff --git a/build-tools/doctool/src/com/google/doctool/custom/IncludeTaglet.java b/build-tools/doctool/src/com/google/doctool/custom/IncludeTaglet.java
index 3c2e214..26e18bf 100644
--- a/build-tools/doctool/src/com/google/doctool/custom/IncludeTaglet.java
+++ b/build-tools/doctool/src/com/google/doctool/custom/IncludeTaglet.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2006 Google Inc.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
 package com.google.doctool.custom;
 
 import com.google.doctool.ResourceIncluder;
@@ -7,6 +22,10 @@
 
 import java.util.Map;
 
+/**
+ * A taglet for slurping in the content of artbitrary files appearing on the
+ * classpath into javadoc.
+ */
 public class IncludeTaglet implements Taglet {
 
   public static void register(Map tagletMap) {
diff --git a/build-tools/doctool/src/com/google/doctool/custom/TipTaglet.java b/build-tools/doctool/src/com/google/doctool/custom/TipTaglet.java
index 0cc7fbe..e20fb41 100644
--- a/build-tools/doctool/src/com/google/doctool/custom/TipTaglet.java
+++ b/build-tools/doctool/src/com/google/doctool/custom/TipTaglet.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2006 Google Inc.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
 package com.google.doctool.custom;
 
 import com.sun.tools.doclets.Taglet;
@@ -5,6 +20,9 @@
 
 import java.util.Map;
 
+/**
+ * A taglet for including GWT tip tags in javadoc output.
+ */
 public class TipTaglet extends SimpleTaglet {
 
   public static void register(Map tagletMap) {