changeset 850:a3b5b531542a jdk7-b123

Merge
author lana
date Mon, 20 Dec 2010 21:10:57 -0800
parents 98570f7ba610 7b99f98b3035
children 659417e931fe
files src/share/classes/com/sun/tools/apt/main/JavaCompiler.java src/share/classes/com/sun/tools/doclets/formats/html/StylesheetWriter.java src/share/classes/com/sun/tools/doclets/internal/toolkit/util/SourceToHTMLConverter.java test/tools/javac/diags/examples/VarargsFilename.java test/tools/javac/diags/examples/VarargsFilenameAdditional.java test/tools/javac/diags/examples/VarargsPlural/VarargsFilename.java test/tools/javac/diags/examples/VarargsPlural/VarargsPlural.java test/tools/javac/diags/examples/VarargsPluralAdditional/VarargsFilename.java test/tools/javac/diags/examples/VarargsPluralAdditional/VarargsPlural.java test/tools/javac/diags/examples/VarargsPluralAdditional/VarargsPluralAdditional.java
diffstat 253 files changed, 17386 insertions(+), 8638 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/source/util/Trees.java	Thu Dec 16 19:57:01 2010 -0800
+++ b/src/share/classes/com/sun/source/util/Trees.java	Mon Dec 20 21:10:57 2010 -0800
@@ -52,6 +52,7 @@
 public abstract class Trees {
     /**
      * Gets a Trees object for a given CompilationTask.
+     * @param task the compilation task for which to get the Trees object
      * @throws IllegalArgumentException if the task does not support the Trees API.
      */
     public static Trees instance(CompilationTask task) {
@@ -61,7 +62,8 @@
     }
 
     /**
-     * Gets a Trees object for a given CompilationTask.
+     * Gets a Trees object for a given ProcessingEnvironment.
+     * @param env the processing environment for which to get the Trees object
      * @throws IllegalArgumentException if the env does not support the Trees API.
      */
     public static Trees instance(ProcessingEnvironment env) {
@@ -163,6 +165,12 @@
     public abstract Scope getScope(TreePath path);
 
     /**
+     * Gets the doc comment, if any, for the Tree node identified by a given TreePath.
+     * Returns null if no doc comment was found.
+     */
+    public abstract String getDocComment(TreePath path);
+
+    /**
      * Checks whether a given type is accessible in a given scope.
      * @param scope the scope to be checked
      * @param type the type to be checked
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/com/sun/tools/apt/main/AptJavaCompiler.java	Mon Dec 20 21:10:57 2010 -0800
@@ -0,0 +1,292 @@
+/*
+ * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code 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
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.apt.main;
+
+import java.io.*;
+import java.util.Map;
+
+import javax.tools.JavaFileManager;
+import javax.tools.JavaFileObject;
+
+import com.sun.tools.javac.file.JavacFileManager;
+import com.sun.tools.javac.util.*;
+import com.sun.tools.javac.code.*;
+import com.sun.tools.javac.jvm.*;
+
+import com.sun.tools.javac.code.Symbol.*;
+import com.sun.tools.javac.tree.JCTree.*;
+
+import com.sun.tools.apt.comp.*;
+import com.sun.tools.apt.util.Bark;
+import com.sun.mirror.apt.AnnotationProcessorFactory;
+import com.sun.tools.javac.parser.DocCommentScanner;
+
+/**
+ *  <p><b>This is NOT part of any supported API.
+ *  If you write code that depends on this, you do so at your own
+ *  risk.  This code and its internal interfaces are subject to change
+ *  or deletion without notice.</b>
+ */
+@SuppressWarnings("deprecation")
+public class AptJavaCompiler extends com.sun.tools.javac.main.JavaCompiler {
+    /** The context key for the compiler. */
+    protected static final Context.Key<AptJavaCompiler> compilerKey =
+        new Context.Key<AptJavaCompiler>();
+
+    /** Get the JavaCompiler instance for this context. */
+    public static AptJavaCompiler instance(Context context) {
+        AptJavaCompiler instance = context.get(compilerKey);
+        if (instance == null)
+            instance = new AptJavaCompiler(context);
+        return instance;
+    }
+
+
+    java.util.Set<String> genSourceFileNames;
+    java.util.Set<String> genClassFileNames;
+
+    public java.util.Set<String> getSourceFileNames() {
+        return genSourceFileNames;
+    }
+
+    /** List of names of generated class files.
+     */
+    public java.util.Set<String> getClassFileNames() {
+        return genClassFileNames;
+    }
+
+    java.util.Set<java.io.File> aggregateGenFiles = java.util.Collections.emptySet();
+
+    public java.util.Set<java.io.File> getAggregateGenFiles() {
+        return aggregateGenFiles;
+    }
+
+    /** The bark to be used for error reporting.
+     */
+    Bark bark;
+
+    /** The log to be used for error reporting.
+     */
+    Log log;
+
+    /** The annotation framework
+     */
+    Apt apt;
+
+    private static Context preRegister(Context context) {
+        Bark.preRegister(context);
+
+        if (context.get(JavaFileManager.class) == null)
+            JavacFileManager.preRegister(context);
+
+        return context;
+    }
+
+    /** Construct a new compiler from a shared context.
+     */
+    public AptJavaCompiler(Context context) {
+        super(preRegister(context));
+
+        context.put(compilerKey, this);
+        apt = Apt.instance(context);
+
+        ClassReader classReader = ClassReader.instance(context);
+        classReader.preferSource = true;
+
+        // TEMPORARY NOTE: bark==log, but while refactoring, we maintain their
+        // original identities, to remember the original intent.
+        log = Log.instance(context);
+        bark = Bark.instance(context);
+
+        Options options = Options.instance(context);
+        classOutput   = options.get("-retrofit")      == null;
+        nocompile     = options.get("-nocompile")     != null;
+        print         = options.get("-print")         != null;
+        classesAsDecls= options.get("-XclassesAsDecls") != null;
+
+        genSourceFileNames = new java.util.LinkedHashSet<String>();
+        genClassFileNames  = new java.util.LinkedHashSet<String>();
+
+        // this forces a copy of the line map to be kept in the tree,
+        // for use by com.sun.mirror.util.SourcePosition.
+        lineDebugInfo = true;
+    }
+
+    /* Switches:
+     */
+
+    /** Emit class files. This switch is always set, except for the first
+     *  phase of retrofitting, where signatures are parsed.
+     */
+    public boolean classOutput;
+
+    /** The internal printing annotation processor should be used.
+     */
+    public boolean print;
+
+    /** Compilation should not be done after annotation processing.
+     */
+    public boolean nocompile;
+
+    /** Are class files being treated as declarations
+     */
+    public boolean classesAsDecls;
+
+    /** Try to open input stream with given name.
+     *  Report an error if this fails.
+     *  @param filename   The file name of the input stream to be opened.
+     */
+    // PROVIDED FOR EXTREME BACKWARDS COMPATIBILITY
+    // There are some very obscure errors that can arise while translating
+    // the contents of a file from bytes to characters. In Tiger, these
+    // diagnostics were ignored. This method provides compatibility with
+    // that behavior. It would be better to honor those diagnostics, in which
+    // case, this method can be deleted.
+    @Override
+    public CharSequence readSource(JavaFileObject filename) {
+        try {
+            inputFiles.add(filename);
+            boolean prev = bark.setDiagnosticsIgnored(true);
+            try {
+                return filename.getCharContent(false);
+            }
+            finally {
+                bark.setDiagnosticsIgnored(prev);
+            }
+        } catch (IOException e) {
+            bark.error(Position.NOPOS, "cant.read.file", filename);
+            return null;
+        }
+    }
+
+    /** Parse contents of input stream.
+     *  @param filename     The name of the file from which input stream comes.
+     *  @param input        The input stream to be parsed.
+     */
+    // PROVIDED FOR BACKWARDS COMPATIBILITY
+    // In Tiger, diagnostics from the scanner and parser were ignored.
+    // This method provides compatibility with that behavior.
+    // It would be better to honor those diagnostics, in which
+    // case, this method can be deleted.
+    @Override
+    protected JCCompilationUnit parse(JavaFileObject filename, CharSequence content) {
+        boolean prev = bark.setDiagnosticsIgnored(true);
+        try {
+            return super.parse(filename, content);
+        }
+        finally {
+            bark.setDiagnosticsIgnored(prev);
+        }
+    }
+
+    @Override
+    protected boolean keepComments() {
+        return true;  // make doc comments available to mirror API impl.
+    }
+
+    /** Track when the JavaCompiler has been used to compile something. */
+    private boolean hasBeenUsed = false;
+
+    /** Main method: compile a list of files, return all compiled classes
+     *  @param filenames     The names of all files to be compiled.
+     */
+    public List<ClassSymbol> compile(List<String> filenames,
+                                     Map<String, String> origOptions,
+                                     ClassLoader aptCL,
+                                     AnnotationProcessorFactory providedFactory,
+                                     java.util.Set<Class<? extends AnnotationProcessorFactory> > productiveFactories,
+                                     java.util.Set<java.io.File> aggregateGenFiles)
+        throws Throwable {
+        // as a JavaCompiler can only be used once, throw an exception if
+        // it has been used before.
+        assert !hasBeenUsed : "attempt to reuse JavaCompiler";
+        hasBeenUsed = true;
+
+        this.aggregateGenFiles = aggregateGenFiles;
+
+        long msec = System.currentTimeMillis();
+
+        ListBuffer<ClassSymbol> classes = new ListBuffer<ClassSymbol>();
+        try {
+            JavacFileManager fm = (JavacFileManager)fileManager;
+            //parse all files
+            ListBuffer<JCCompilationUnit> trees = new ListBuffer<JCCompilationUnit>();
+            for (List<String> l = filenames; l.nonEmpty(); l = l.tail) {
+                if (classesAsDecls) {
+                    if (! l.head.endsWith(".java") ) { // process as class file
+                        ClassSymbol cs = reader.enterClass(names.fromString(l.head));
+                        try {
+                            cs.complete();
+                        } catch(Symbol.CompletionFailure cf) {
+                            bark.aptError("CantFindClass", l);
+                            continue;
+                        }
+
+                        classes.append(cs); // add to list of classes
+                        continue;
+                    }
+                }
+                JavaFileObject fo = fm.getJavaFileObjectsFromStrings(List.of(l.head)).iterator().next();
+                trees.append(parse(fo));
+            }
+
+            //enter symbols for all files
+            List<JCCompilationUnit> roots = trees.toList();
+
+            if (errorCount() == 0) {
+                boolean prev = bark.setDiagnosticsIgnored(true);
+                try {
+                    enter.main(roots);
+                }
+                finally {
+                    bark.setDiagnosticsIgnored(prev);
+                }
+            }
+
+            if (errorCount() == 0) {
+                apt.main(roots,
+                         classes,
+                         origOptions, aptCL,
+                         providedFactory,
+                         productiveFactories);
+                genSourceFileNames.addAll(apt.getSourceFileNames());
+                genClassFileNames.addAll(apt.getClassFileNames());
+            }
+
+        } catch (Abort ex) {
+        }
+
+        if (verbose)
+            printVerbose("total", Long.toString(System.currentTimeMillis() - msec));
+
+        chk.reportDeferredDiagnostics();
+
+        printCount("error", errorCount());
+        printCount("warn", warningCount());
+
+        return classes.toList();
+    }
+}
--- a/src/share/classes/com/sun/tools/apt/main/JavaCompiler.java	Thu Dec 16 19:57:01 2010 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,292 +0,0 @@
-/*
- * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code 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
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.tools.apt.main;
-
-import java.io.*;
-import java.util.Map;
-
-import javax.tools.JavaFileManager;
-import javax.tools.JavaFileObject;
-
-import com.sun.tools.javac.file.JavacFileManager;
-import com.sun.tools.javac.util.*;
-import com.sun.tools.javac.code.*;
-import com.sun.tools.javac.jvm.*;
-
-import com.sun.tools.javac.code.Symbol.*;
-import com.sun.tools.javac.tree.JCTree.*;
-
-import com.sun.tools.apt.comp.*;
-import com.sun.tools.apt.util.Bark;
-import com.sun.mirror.apt.AnnotationProcessorFactory;
-import com.sun.tools.javac.parser.DocCommentScanner;
-
-/**
- *  <p><b>This is NOT part of any supported API.
- *  If you write code that depends on this, you do so at your own
- *  risk.  This code and its internal interfaces are subject to change
- *  or deletion without notice.</b>
- */
-@SuppressWarnings("deprecation")
-public class JavaCompiler extends com.sun.tools.javac.main.JavaCompiler {
-    /** The context key for the compiler. */
-    protected static final Context.Key<JavaCompiler> compilerKey =
-        new Context.Key<JavaCompiler>();
-
-    /** Get the JavaCompiler instance for this context. */
-    public static JavaCompiler instance(Context context) {
-        JavaCompiler instance = context.get(compilerKey);
-        if (instance == null)
-            instance = new JavaCompiler(context);
-        return instance;
-    }
-
-
-    java.util.Set<String> genSourceFileNames;
-    java.util.Set<String> genClassFileNames;
-
-    public java.util.Set<String> getSourceFileNames() {
-        return genSourceFileNames;
-    }
-
-    /** List of names of generated class files.
-     */
-    public java.util.Set<String> getClassFileNames() {
-        return genClassFileNames;
-    }
-
-    java.util.Set<java.io.File> aggregateGenFiles = java.util.Collections.emptySet();
-
-    public java.util.Set<java.io.File> getAggregateGenFiles() {
-        return aggregateGenFiles;
-    }
-
-    /** The bark to be used for error reporting.
-     */
-    Bark bark;
-
-    /** The log to be used for error reporting.
-     */
-    Log log;
-
-    /** The annotation framework
-     */
-    Apt apt;
-
-    private static Context preRegister(Context context) {
-        Bark.preRegister(context);
-
-        if (context.get(JavaFileManager.class) == null)
-            JavacFileManager.preRegister(context);
-
-        return context;
-    }
-
-    /** Construct a new compiler from a shared context.
-     */
-    public JavaCompiler(Context context) {
-        super(preRegister(context));
-
-        context.put(compilerKey, this);
-        apt = Apt.instance(context);
-
-        ClassReader classReader = ClassReader.instance(context);
-        classReader.preferSource = true;
-
-        // TEMPORARY NOTE: bark==log, but while refactoring, we maintain their
-        // original identities, to remember the original intent.
-        log = Log.instance(context);
-        bark = Bark.instance(context);
-
-        Options options = Options.instance(context);
-        classOutput   = options.get("-retrofit")      == null;
-        nocompile     = options.get("-nocompile")     != null;
-        print         = options.get("-print")         != null;
-        classesAsDecls= options.get("-XclassesAsDecls") != null;
-
-        genSourceFileNames = new java.util.LinkedHashSet<String>();
-        genClassFileNames  = new java.util.LinkedHashSet<String>();
-
-        // this forces a copy of the line map to be kept in the tree,
-        // for use by com.sun.mirror.util.SourcePosition.
-        lineDebugInfo = true;
-    }
-
-    /* Switches:
-     */
-
-    /** Emit class files. This switch is always set, except for the first
-     *  phase of retrofitting, where signatures are parsed.
-     */
-    public boolean classOutput;
-
-    /** The internal printing annotation processor should be used.
-     */
-    public boolean print;
-
-    /** Compilation should not be done after annotation processing.
-     */
-    public boolean nocompile;
-
-    /** Are class files being treated as declarations
-     */
-    public boolean classesAsDecls;
-
-    /** Try to open input stream with given name.
-     *  Report an error if this fails.
-     *  @param filename   The file name of the input stream to be opened.
-     */
-    // PROVIDED FOR EXTREME BACKWARDS COMPATIBILITY
-    // There are some very obscure errors that can arise while translating
-    // the contents of a file from bytes to characters. In Tiger, these
-    // diagnostics were ignored. This method provides compatibility with
-    // that behavior. It would be better to honor those diagnostics, in which
-    // case, this method can be deleted.
-    @Override
-    public CharSequence readSource(JavaFileObject filename) {
-        try {
-            inputFiles.add(filename);
-            boolean prev = bark.setDiagnosticsIgnored(true);
-            try {
-                return filename.getCharContent(false);
-            }
-            finally {
-                bark.setDiagnosticsIgnored(prev);
-            }
-        } catch (IOException e) {
-            bark.error(Position.NOPOS, "cant.read.file", filename);
-            return null;
-        }
-    }
-
-    /** Parse contents of input stream.
-     *  @param filename     The name of the file from which input stream comes.
-     *  @param input        The input stream to be parsed.
-     */
-    // PROVIDED FOR BACKWARDS COMPATIBILITY
-    // In Tiger, diagnostics from the scanner and parser were ignored.
-    // This method provides compatibility with that behavior.
-    // It would be better to honor those diagnostics, in which
-    // case, this method can be deleted.
-    @Override
-    protected JCCompilationUnit parse(JavaFileObject filename, CharSequence content) {
-        boolean prev = bark.setDiagnosticsIgnored(true);
-        try {
-            return super.parse(filename, content);
-        }
-        finally {
-            bark.setDiagnosticsIgnored(prev);
-        }
-    }
-
-    @Override
-    protected boolean keepComments() {
-        return true;  // make doc comments available to mirror API impl.
-    }
-
-    /** Track when the JavaCompiler has been used to compile something. */
-    private boolean hasBeenUsed = false;
-
-    /** Main method: compile a list of files, return all compiled classes
-     *  @param filenames     The names of all files to be compiled.
-     */
-    public List<ClassSymbol> compile(List<String> filenames,
-                                     Map<String, String> origOptions,
-                                     ClassLoader aptCL,
-                                     AnnotationProcessorFactory providedFactory,
-                                     java.util.Set<Class<? extends AnnotationProcessorFactory> > productiveFactories,
-                                     java.util.Set<java.io.File> aggregateGenFiles)
-        throws Throwable {
-        // as a JavaCompiler can only be used once, throw an exception if
-        // it has been used before.
-        assert !hasBeenUsed : "attempt to reuse JavaCompiler";
-        hasBeenUsed = true;
-
-        this.aggregateGenFiles = aggregateGenFiles;
-
-        long msec = System.currentTimeMillis();
-
-        ListBuffer<ClassSymbol> classes = new ListBuffer<ClassSymbol>();
-        try {
-            JavacFileManager fm = (JavacFileManager)fileManager;
-            //parse all files
-            ListBuffer<JCCompilationUnit> trees = new ListBuffer<JCCompilationUnit>();
-            for (List<String> l = filenames; l.nonEmpty(); l = l.tail) {
-                if (classesAsDecls) {
-                    if (! l.head.endsWith(".java") ) { // process as class file
-                        ClassSymbol cs = reader.enterClass(names.fromString(l.head));
-                        try {
-                            cs.complete();
-                        } catch(Symbol.CompletionFailure cf) {
-                            bark.aptError("CantFindClass", l);
-                            continue;
-                        }
-
-                        classes.append(cs); // add to list of classes
-                        continue;
-                    }
-                }
-                JavaFileObject fo = fm.getJavaFileObjectsFromStrings(List.of(l.head)).iterator().next();
-                trees.append(parse(fo));
-            }
-
-            //enter symbols for all files
-            List<JCCompilationUnit> roots = trees.toList();
-
-            if (errorCount() == 0) {
-                boolean prev = bark.setDiagnosticsIgnored(true);
-                try {
-                    enter.main(roots);
-                }
-                finally {
-                    bark.setDiagnosticsIgnored(prev);
-                }
-            }
-
-            if (errorCount() == 0) {
-                apt.main(roots,
-                         classes,
-                         origOptions, aptCL,
-                         providedFactory,
-                         productiveFactories);
-                genSourceFileNames.addAll(apt.getSourceFileNames());
-                genClassFileNames.addAll(apt.getClassFileNames());
-            }
-
-        } catch (Abort ex) {
-        }
-
-        if (verbose)
-            printVerbose("total", Long.toString(System.currentTimeMillis() - msec));
-
-        chk.reportDeferredDiagnostics();
-
-        printCount("error", errorCount());
-        printCount("warn", warningCount());
-
-        return classes.toList();
-    }
-}
--- a/src/share/classes/com/sun/tools/apt/main/Main.java	Thu Dec 16 19:57:01 2010 -0800
+++ b/src/share/classes/com/sun/tools/apt/main/Main.java	Mon Dec 20 21:10:57 2010 -0800
@@ -421,7 +421,7 @@
         },
         new AptOption("-version",               "opt.version") {
             boolean process(String option) {
-                Bark.printLines(out, ownName + " " + JavaCompiler.version());
+                Bark.printLines(out, ownName + " " + AptJavaCompiler.version());
                 return super.process(option);
             }
         },
@@ -1111,11 +1111,11 @@
         }
         int exitCode = EXIT_OK;
 
-        JavaCompiler comp = null;
+        AptJavaCompiler comp = null;
         try {
             context.put(Bark.outKey, out);
 
-            comp = JavaCompiler.instance(context);
+            comp = AptJavaCompiler.instance(context);
             if (comp == null)
                 return EXIT_SYSERR;
 
@@ -1184,7 +1184,7 @@
      */
     void bugMessage(Throwable ex) {
         Bark.printLines(out, getLocalizedString("msg.bug",
-                                               JavaCompiler.version()));
+                                               AptJavaCompiler.version()));
         ex.printStackTrace(out);
     }
 
--- a/src/share/classes/com/sun/tools/apt/mirror/apt/FilerImpl.java	Thu Dec 16 19:57:01 2010 -0800
+++ b/src/share/classes/com/sun/tools/apt/mirror/apt/FilerImpl.java	Mon Dec 20 21:10:57 2010 -0800
@@ -120,7 +120,7 @@
 
     private final Options opts;
     private final DeclarationMaker declMaker;
-    private final com.sun.tools.apt.main.JavaCompiler comp;
+    private final com.sun.tools.apt.main.AptJavaCompiler comp;
 
     // Platform's default encoding
     private final static String DEFAULT_ENCODING =
@@ -177,7 +177,7 @@
         opts = Options.instance(context);
         declMaker = DeclarationMaker.instance(context);
         bark = Bark.instance(context);
-        comp = com.sun.tools.apt.main.JavaCompiler.instance(context);
+        comp = com.sun.tools.apt.main.AptJavaCompiler.instance(context);
         roundOver = false;
         this.filesCreated = comp.getAggregateGenFiles();
 
--- a/src/share/classes/com/sun/tools/doclets/formats/html/AbstractExecutableMemberWriter.java	Thu Dec 16 19:57:01 2010 -0800
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/AbstractExecutableMemberWriter.java	Mon Dec 20 21:10:57 2010 -0800
@@ -26,12 +26,16 @@
 package com.sun.tools.doclets.formats.html;
 
 import com.sun.javadoc.*;
+import com.sun.tools.doclets.formats.html.markup.*;
+import com.sun.tools.doclets.internal.toolkit.*;
+import com.sun.tools.doclets.internal.toolkit.util.*;
 
 /**
  * Print method and constructor info.
  *
  * @author Robert Field
  * @author Atul M Dambalkar
+ * @author Bhavesh Patel (Modified)
  */
 public abstract class AbstractExecutableMemberWriter extends AbstractMemberWriter {
 
@@ -45,82 +49,111 @@
     }
 
     /**
-     * Write the type parameters for the executable member.
+     * Add the type parameters for the executable member.
      *
      * @param member the member to write type parameters for.
+     * @param htmltree the content tree to which the parameters will be added.
      * @return the display length required to write this information.
      */
-    protected int writeTypeParameters(ExecutableMemberDoc member) {
+    protected int addTypeParameters(ExecutableMemberDoc member, Content htmltree) {
         LinkInfoImpl linkInfo = new LinkInfoImpl(
             LinkInfoImpl.CONTEXT_MEMBER_TYPE_PARAMS, member, false);
         String typeParameters = writer.getTypeParameterLinks(linkInfo);
         if (linkInfo.displayLength > 0) {
-            writer.print(typeParameters + " ");
+            Content linkContent = new RawHtml(typeParameters);
+            htmltree.addContent(linkContent);
+            htmltree.addContent(writer.getSpace());
             writer.displayLength += linkInfo.displayLength + 1;
         }
         return linkInfo.displayLength;
     }
 
-    protected void writeSignature(ExecutableMemberDoc member) {
-        writer.displayLength = 0;
-        writer.pre();
-        writer.writeAnnotationInfo(member);
-        printModifiers(member);
-        writeTypeParameters(member);
-        if (configuration().linksource &&
-            member.position().line() != classdoc.position().line()) {
-            writer.printSrcLink(member, member.name());
-        } else {
-            strong(member.name());
-        }
-        writeParameters(member);
-        writeExceptions(member);
-        writer.preEnd();
+    /**
+     * {@inheritDoc}
+     */
+    protected Content getDeprecatedLink(ProgramElementDoc member) {
+        ExecutableMemberDoc emd = (ExecutableMemberDoc)member;
+        return writer.getDocLink(LinkInfoImpl.CONTEXT_MEMBER, (MemberDoc) emd,
+                emd.qualifiedName() + emd.flatSignature());
     }
 
-    protected void writeDeprecatedLink(ProgramElementDoc member) {
+    /**
+     * Add the summary link for the member.
+     *
+     * @param context the id of the context where the link will be printed
+     * @param classDoc the classDoc that we should link to
+     * @param member the member being linked to
+     * @param tdSummary the content tree to which the link will be added
+     */
+    protected void addSummaryLink(int context, ClassDoc cd, ProgramElementDoc member,
+            Content tdSummary) {
         ExecutableMemberDoc emd = (ExecutableMemberDoc)member;
-        writer.printDocLink(LinkInfoImpl.CONTEXT_MEMBER, (MemberDoc) emd,
-            emd.qualifiedName() + emd.flatSignature(), false);
+        String name = emd.name();
+        Content strong = HtmlTree.STRONG(new RawHtml(
+                writer.getDocLink(context, cd, (MemberDoc) emd,
+                name, false)));
+        Content code = HtmlTree.CODE(strong);
+        writer.displayLength = name.length();
+        addParameters(emd, false, code);
+        tdSummary.addContent(code);
     }
 
-    protected void writeSummaryLink(int context, ClassDoc cd, ProgramElementDoc member) {
-        ExecutableMemberDoc emd = (ExecutableMemberDoc)member;
-        String name = emd.name();
-        writer.strong();
-        writer.printDocLink(context, cd, (MemberDoc) emd,
-            name, false);
-        writer.strongEnd();
-        writer.displayLength = name.length();
-        writeParameters(emd, false);
+    /**
+     * Add the inherited summary link for the member.
+     *
+     * @param classDoc the classDoc that we should link to
+     * @param member the member being linked to
+     * @param linksTree the content tree to which the link will be added
+     */
+    protected void addInheritedSummaryLink(ClassDoc cd,
+            ProgramElementDoc member, Content linksTree) {
+        linksTree.addContent(new RawHtml(
+                writer.getDocLink(LinkInfoImpl.CONTEXT_MEMBER, cd, (MemberDoc) member,
+                member.name(), false)));
     }
 
-    protected void writeInheritedSummaryLink(ClassDoc cd,
-            ProgramElementDoc member) {
-        writer.printDocLink(LinkInfoImpl.CONTEXT_MEMBER, cd, (MemberDoc) member,
-            member.name(), false);
-    }
-
-    protected void writeParam(ExecutableMemberDoc member, Parameter param,
-        boolean isVarArg) {
+    /**
+     * Add the parameter for the executable member.
+     *
+     * @param member the member to write parameter for.
+     * @param param the parameter that needs to be written.
+     * @param isVarArg true if this is a link to var arg.
+     * @param tree the content tree to which the parameter information will be added.
+     */
+    protected void addParam(ExecutableMemberDoc member, Parameter param,
+        boolean isVarArg, Content tree) {
         if (param.type() != null) {
-            writer.printLink(new LinkInfoImpl(
-                LinkInfoImpl.CONTEXT_EXECUTABLE_MEMBER_PARAM, param.type(),
-                isVarArg));
+            Content link = new RawHtml(writer.getLink(new LinkInfoImpl(
+                    LinkInfoImpl.CONTEXT_EXECUTABLE_MEMBER_PARAM, param.type(),
+                    isVarArg)));
+            tree.addContent(link);
         }
         if(param.name().length() > 0) {
-            writer.space();
-            writer.print(param.name());
+            tree.addContent(writer.getSpace());
+            tree.addContent(param.name());
         }
     }
 
-    protected void writeParameters(ExecutableMemberDoc member) {
-        writeParameters(member, true);
+    /**
+     * Add all the parameters for the executable member.
+     *
+     * @param member the member to write parameters for.
+     * @param tree the content tree to which the parameters information will be added.
+     */
+    protected void addParameters(ExecutableMemberDoc member, Content htmltree) {
+        addParameters(member, true, htmltree);
     }
 
-    protected void writeParameters(ExecutableMemberDoc member,
-            boolean includeAnnotations) {
-        print('(');
+    /**
+     * Add all the parameters for the executable member.
+     *
+     * @param member the member to write parameters for.
+     * @param includeAnnotations true if annotation information needs to be added.
+     * @param tree the content tree to which the parameters information will be added.
+     */
+    protected void addParameters(ExecutableMemberDoc member,
+            boolean includeAnnotations, Content htmltree) {
+        htmltree.addContent("(");
         Parameter[] params = member.parameters();
         String indent = makeSpace(writer.displayLength);
         if (configuration().linksource) {
@@ -132,58 +165,70 @@
             Parameter param = params[paramstart];
             if (!param.name().startsWith("this$")) {
                 if (includeAnnotations) {
-                        boolean foundAnnotations =
-                                writer.writeAnnotationInfo(indent.length(), member, param);
-                        if (foundAnnotations) {
-                                writer.println();
-                                writer.print(indent);
+                    boolean foundAnnotations =
+                            writer.addAnnotationInfo(indent.length(),
+                            member, param, htmltree);
+                    if (foundAnnotations) {
+                        htmltree.addContent(DocletConstants.NL);
+                        htmltree.addContent(indent);
                     }
                 }
-                writeParam(member, param,
-                    (paramstart == params.length - 1) && member.isVarArgs());
+                addParam(member, param,
+                    (paramstart == params.length - 1) && member.isVarArgs(), htmltree);
                 break;
             }
         }
 
         for (int i = paramstart + 1; i < params.length; i++) {
-            writer.print(',');
-            writer.println();
-            writer.print(indent);
+            htmltree.addContent(",");
+            htmltree.addContent(DocletConstants.NL);
+            htmltree.addContent(indent);
             if (includeAnnotations) {
                 boolean foundAnnotations =
-                    writer.writeAnnotationInfo(indent.length(), member, params[i]);
+                        writer.addAnnotationInfo(indent.length(), member, params[i],
+                        htmltree);
                 if (foundAnnotations) {
-                    writer.println();
-                    writer.print(indent);
+                    htmltree.addContent(DocletConstants.NL);
+                    htmltree.addContent(indent);
                 }
             }
-            writeParam(member, params[i], (i == params.length - 1) && member.isVarArgs());
+            addParam(member, params[i], (i == params.length - 1) && member.isVarArgs(),
+                    htmltree);
         }
-        writer.print(')');
+        htmltree.addContent(")");
     }
 
-    protected void writeExceptions(ExecutableMemberDoc member) {
+    /**
+     * Add exceptions for the executable member.
+     *
+     * @param member the member to write exceptions for.
+     * @param htmltree the content tree to which the exceptions information will be added.
+     */
+    protected void addExceptions(ExecutableMemberDoc member, Content htmltree) {
         Type[] exceptions = member.thrownExceptionTypes();
         if(exceptions.length > 0) {
             LinkInfoImpl memberTypeParam = new LinkInfoImpl(
-                LinkInfoImpl.CONTEXT_MEMBER, member, false);
+                    LinkInfoImpl.CONTEXT_MEMBER, member, false);
             int retlen = getReturnTypeLength(member);
             writer.getTypeParameterLinks(memberTypeParam);
             retlen += memberTypeParam.displayLength == 0 ?
                 0 : memberTypeParam.displayLength + 1;
             String indent = makeSpace(modifierString(member).length() +
-                member.name().length() + retlen - 4);
-            writer.println();
-            writer.print(indent);
-            writer.print("throws ");
+                    member.name().length() + retlen - 4);
+            htmltree.addContent(DocletConstants.NL);
+            htmltree.addContent(indent);
+            htmltree.addContent("throws ");
             indent += "       ";
-            writer.printLink(new LinkInfoImpl(
-                LinkInfoImpl.CONTEXT_MEMBER, exceptions[0]));
+            Content link = new RawHtml(writer.getLink(new LinkInfoImpl(
+                    LinkInfoImpl.CONTEXT_MEMBER, exceptions[0])));
+            htmltree.addContent(link);
             for(int i = 1; i < exceptions.length; i++) {
-                writer.println(",");
-                writer.print(indent);
-                writer.printLink(new LinkInfoImpl(
-                    LinkInfoImpl.CONTEXT_MEMBER, exceptions[i]));
+                htmltree.addContent(",");
+                htmltree.addContent(DocletConstants.NL);
+                htmltree.addContent(indent);
+                Content exceptionLink = new RawHtml(writer.getLink(new LinkInfoImpl(
+                        LinkInfoImpl.CONTEXT_MEMBER, exceptions[i])));
+                htmltree.addContent(exceptionLink);
             }
         }
     }
--- a/src/share/classes/com/sun/tools/doclets/formats/html/AbstractIndexWriter.java	Thu Dec 16 19:57:01 2010 -0800
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/AbstractIndexWriter.java	Mon Dec 20 21:10:57 2010 -0800
@@ -30,6 +30,8 @@
 
 import com.sun.javadoc.*;
 import com.sun.tools.doclets.internal.toolkit.util.*;
+import com.sun.tools.doclets.formats.html.markup.*;
+import com.sun.tools.doclets.internal.toolkit.*;
 
 /**
  * Generate Index for all the Member Names with Indexing in
@@ -39,6 +41,7 @@
  *
  * @see    IndexBuilder
  * @author Atul M Dambalkar
+ * @author Bhavesh Patel (Modified)
  */
 public class AbstractIndexWriter extends HtmlDocletWriter {
 
@@ -78,175 +81,187 @@
     }
 
     /**
-     * Print the text "Index" in strong format in the navigation bar.
+     * Get the index label for navigation bar.
+     *
+     * @return a content tree for the tree label
      */
-    protected void navLinkIndex() {
-        navCellRevStart();
-        fontStyle("NavBarFont1Rev");
-        strongText("doclet.Index");
-        fontEnd();
-        navCellEnd();
+    protected Content getNavLinkIndex() {
+        Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, indexLabel);
+        return li;
     }
 
     /**
-     * Generate the member information for the unicode character along with the
+     * Add the member information for the unicode character along with the
      * list of the members.
      *
-     * @param unicode Unicode for which member list information to be generated.
-     * @param memberlist List of members for the unicode character.
+     * @param unicode Unicode for which member list information to be generated
+     * @param memberlist List of members for the unicode character
+     * @param contentTree the content tree to which the information will be added
      */
-    protected void generateContents(Character unicode, List<? extends Doc> memberlist) {
-        anchor("_" + unicode + "_");
-        h2();
-        strong(unicode.toString());
-        h2End();
+    protected void addContents(Character unicode, List<? extends Doc> memberlist,
+            Content contentTree) {
+        contentTree.addContent(getMarkerAnchor("_" + unicode + "_"));
+        Content headContent = new StringContent(unicode.toString());
+        Content heading = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, false,
+                HtmlStyle.title, headContent);
+        contentTree.addContent(heading);
         int memberListSize = memberlist.size();
         // Display the list only if there are elements to be displayed.
         if (memberListSize > 0) {
-            dl();
+            Content dl = new HtmlTree(HtmlTag.DL);
             for (int i = 0; i < memberListSize; i++) {
                 Doc element = memberlist.get(i);
                 if (element instanceof MemberDoc) {
-                    printDescription((MemberDoc)element);
+                    addDescription((MemberDoc)element, dl);
                 } else if (element instanceof ClassDoc) {
-                    printDescription((ClassDoc)element);
+                    addDescription((ClassDoc)element, dl);
                 } else if (element instanceof PackageDoc) {
-                    printDescription((PackageDoc)element);
+                    addDescription((PackageDoc)element, dl);
                 }
             }
-            dlEnd();
+            contentTree.addContent(dl);
         }
-        hr();
-    }
-
-
-    /**
-     * Print one line summary comment for the package.
-     *
-     * @param pkg PackageDoc passed.
-     */
-    protected void printDescription(PackageDoc pkg) {
-        dt();
-        printPackageLink(pkg, Util.getPackageName(pkg), true);
-        print(" - ");
-        print(configuration.getText("doclet.package") + " " + pkg.name());
-        dtEnd();
-        dd();
-        printSummaryComment(pkg);
-        ddEnd();
     }
 
     /**
-     * Print one line summary comment for the class.
+     * Add one line summary comment for the package.
      *
-     * @param cd ClassDoc passed.
+     * @param pkg the package to be documented
+     * @param dlTree the content tree to which the description will be added
      */
-    protected void printDescription(ClassDoc cd) {
-        dt();
-        printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_INDEX, cd, true));
-        print(" - ");
-        printClassInfo(cd);
-        dtEnd();
-        dd();
-        printComment(cd);
-        ddEnd();
+    protected void addDescription(PackageDoc pkg, Content dlTree) {
+        Content link = getPackageLink(pkg, new StringContent(Util.getPackageName(pkg)));
+        Content dt = HtmlTree.DT(link);
+        dt.addContent(" - ");
+        dt.addContent(getResource("doclet.package"));
+        dt.addContent(" " + pkg.name());
+        dlTree.addContent(dt);
+        Content dd = new HtmlTree(HtmlTag.DD);
+        addSummaryComment(pkg, dd);
+        dlTree.addContent(dd);
     }
 
     /**
-     * Print the classkind(class, interface, exception, error of the class
+     * Add one line summary comment for the class.
+     *
+     * @param cd the class being documented
+     * @param dlTree the content tree to which the description will be added
+     */
+    protected void addDescription(ClassDoc cd, Content dlTree) {
+        Content link = new RawHtml(
+                getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_INDEX, cd, true)));
+        Content dt = HtmlTree.DT(link);
+        dt.addContent(" - ");
+        addClassInfo(cd, dt);
+        dlTree.addContent(dt);
+        Content dd = new HtmlTree(HtmlTag.DD);
+        addComment(cd, dd);
+        dlTree.addContent(dd);
+    }
+
+    /**
+     * Add the classkind(class, interface, exception, error of the class
      * passed.
      *
-     * @param cd ClassDoc.
+     * @param cd the class being documented
+     * @param contentTree the content tree to which the class info will be added
      */
-    protected void printClassInfo(ClassDoc cd) {
-        print(configuration.getText("doclet.in",
-            Util.getTypeName(configuration, cd, false),
-            getPackageLink(cd.containingPackage(),
+    protected void addClassInfo(ClassDoc cd, Content contentTree) {
+        contentTree.addContent(getResource("doclet.in",
+                Util.getTypeName(configuration, cd, false),
+                getPackageLinkString(cd.containingPackage(),
                 Util.getPackageName(cd.containingPackage()), false)));
     }
 
-
     /**
-     * Generate Description for Class, Field, Method or Constructor.
-     * for Java.* Packages Class Members.
+     * Add description for Class, Field, Method or Constructor.
      *
-     * @param member MemberDoc for the member of the Class Kind.
-     * @see com.sun.javadoc.MemberDoc
+     * @param member MemberDoc for the member of the Class Kind
+     * @param dlTree the content tree to which the description will be added
      */
-    protected void printDescription(MemberDoc member) {
+    protected void addDescription(MemberDoc member, Content dlTree) {
         String name = (member instanceof ExecutableMemberDoc)?
             member.name() + ((ExecutableMemberDoc)member).flatSignature() :
             member.name();
         if (name.indexOf("<") != -1 || name.indexOf(">") != -1) {
                 name = Util.escapeHtmlChars(name);
         }
-        ClassDoc containing = member.containingClass();
-        dt();
-        printDocLink(LinkInfoImpl.CONTEXT_INDEX, member, name, true);
-        println(" - ");
-        printMemberDesc(member);
-        println();
-        dtEnd();
-        dd();
-        printComment(member);
-        ddEnd();
-        println();
+        Content span = HtmlTree.SPAN(HtmlStyle.strong,
+                getDocLink(LinkInfoImpl.CONTEXT_INDEX, member, name));
+        Content dt = HtmlTree.DT(span);
+        dt.addContent(" - ");
+        addMemberDesc(member, dt);
+        dlTree.addContent(dt);
+        Content dd = new HtmlTree(HtmlTag.DD);
+        addComment(member, dd);
+        dlTree.addContent(dd);
     }
 
-
     /**
-     * Print comment for each element in the index. If the element is deprecated
+     * Add comment for each element in the index. If the element is deprecated
      * and it has a @deprecated tag, use that comment. Else if the containing
      * class for this element is deprecated, then add the word "Deprecated." at
      * the start and then print the normal comment.
      *
-     * @param element Index element.
+     * @param element Index element
+     * @param contentTree the content tree to which the comment will be added
      */
-    protected void printComment(ProgramElementDoc element) {
+    protected void addComment(ProgramElementDoc element, Content contentTree) {
         Tag[] tags;
+        Content span = HtmlTree.SPAN(HtmlStyle.strong, deprecatedPhrase);
+        HtmlTree div = new HtmlTree(HtmlTag.DIV);
+        div.addStyle(HtmlStyle.block);
         if (Util.isDeprecated(element)) {
-            strongText("doclet.Deprecated"); space();
+            div.addContent(span);
             if ((tags = element.tags("deprecated")).length > 0)
-                printInlineDeprecatedComment(element, tags[0]);
+                addInlineDeprecatedComment(element, tags[0], div);
+            contentTree.addContent(div);
         } else {
             ClassDoc cont = element.containingClass();
             while (cont != null) {
                 if (Util.isDeprecated(cont)) {
-                    strongText("doclet.Deprecated"); space();
+                    div.addContent(span);
+                    contentTree.addContent(div);
                     break;
                 }
                 cont = cont.containingClass();
             }
-            printSummaryComment(element);
+            addSummaryComment(element, contentTree);
         }
     }
 
     /**
-     * Print description about the Static Varible/Method/Constructor for a
+     * Add description about the Static Varible/Method/Constructor for a
      * member.
      *
-     * @param member MemberDoc for the member within the Class Kind.
-     * @see com.sun.javadoc.MemberDoc
+     * @param member MemberDoc for the member within the Class Kind
+     * @param contentTree the content tree to which the member description will be added
      */
-    protected void printMemberDesc(MemberDoc member) {
+    protected void addMemberDesc(MemberDoc member, Content contentTree) {
         ClassDoc containing = member.containingClass();
-        String classdesc = Util.getTypeName(configuration, containing, true) + " " +
-            getPreQualifiedClassLink(LinkInfoImpl.CONTEXT_INDEX, containing,
-                false);
+        String classdesc = Util.getTypeName(
+                configuration, containing, true) + " ";
         if (member.isField()) {
             if (member.isStatic()) {
-                printText("doclet.Static_variable_in", classdesc);
+                contentTree.addContent(
+                        getResource("doclet.Static_variable_in", classdesc));
             } else {
-                printText("doclet.Variable_in", classdesc);
+                contentTree.addContent(
+                        getResource("doclet.Variable_in", classdesc));
             }
         } else if (member.isConstructor()) {
-            printText("doclet.Constructor_for", classdesc);
+            contentTree.addContent(
+                    getResource("doclet.Constructor_for", classdesc));
         } else if (member.isMethod()) {
             if (member.isStatic()) {
-                printText("doclet.Static_method_in", classdesc);
+                contentTree.addContent(
+                        getResource("doclet.Static_method_in", classdesc));
             } else {
-                printText("doclet.Method_in", classdesc);
+                contentTree.addContent(
+                        getResource("doclet.Method_in", classdesc));
             }
         }
+        addPreQualifiedClassLink(LinkInfoImpl.CONTEXT_INDEX, containing,
+                false, contentTree);
     }
 }
--- a/src/share/classes/com/sun/tools/doclets/formats/html/AbstractMemberWriter.java	Thu Dec 16 19:57:01 2010 -0800
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/AbstractMemberWriter.java	Mon Dec 20 21:10:57 2010 -0800
@@ -25,10 +25,11 @@
 
 package com.sun.tools.doclets.formats.html;
 
+import java.util.*;
 import java.lang.reflect.Modifier;
-import java.util.*;
-
 import com.sun.javadoc.*;
+import com.sun.tools.doclets.formats.html.markup.*;
+import com.sun.tools.doclets.internal.toolkit.*;
 import com.sun.tools.doclets.internal.toolkit.util.*;
 import com.sun.tools.doclets.internal.toolkit.taglets.*;
 
@@ -60,36 +61,125 @@
 
     /*** abstracts ***/
 
-    public abstract void printSummaryLabel();
+    /**
+     * Add the summary label for the member.
+     *
+     * @param memberTree the content tree to which the label will be added
+     */
+    public abstract void addSummaryLabel(Content memberTree);
 
-    public abstract void printTableSummary();
+    /**
+     * Get the summary for the member summary table.
+     *
+     * @return a string for the table summary
+     */
+    public abstract String getTableSummary();
 
-    public abstract void printSummaryTableHeader(ProgramElementDoc member);
+    /**
+     * Get the caption for the member summary table.
+     *
+     * @return a string for the table caption
+     */
+    public abstract String getCaption();
 
-    public abstract void printInheritedSummaryLabel(ClassDoc cd);
+    /**
+     * Get the summary table header for the member.
+     *
+     * @param member the member to be documented
+     * @return the summary table header
+     */
+    public abstract String[] getSummaryTableHeader(ProgramElementDoc member);
 
-    public abstract void printSummaryAnchor(ClassDoc cd);
+    /**
+     * Add inherited summary lable for the member.
+     *
+     * @param cd the class doc to which to link to
+     * @param inheritedTree the content tree to which the inherited summary label will be added
+     */
+    public abstract void addInheritedSummaryLabel(ClassDoc cd, Content inheritedTree);
 
-    public abstract void printInheritedSummaryAnchor(ClassDoc cd);
+    /**
+     * Add the anchor for the summary section of the member.
+     *
+     * @param cd the class doc to be documented
+     * @param memberTree the content tree to which the summary anchor will be added
+     */
+    public abstract void addSummaryAnchor(ClassDoc cd, Content memberTree);
 
-    protected abstract void printSummaryType(ProgramElementDoc member);
+    /**
+     * Add the anchor for the inherited summary section of the member.
+     *
+     * @param cd the class doc to be documented
+     * @param inheritedTree the content tree to which the inherited summary anchor will be added
+     */
+    public abstract void addInheritedSummaryAnchor(ClassDoc cd, Content inheritedTree);
 
-    protected void writeSummaryLink(ClassDoc cd, ProgramElementDoc member) {
-        writeSummaryLink(LinkInfoImpl.CONTEXT_MEMBER, cd, member);
+    /**
+     * Add the summary type for the member.
+     *
+     * @param member the member to be documented
+     * @param tdSummaryType the content tree to which the type will be added
+     */
+    protected abstract void addSummaryType(ProgramElementDoc member,
+            Content tdSummaryType);
+
+    /**
+     * Add the summary link for the member.
+     *
+     * @param cd the class doc to be documented
+     * @param member the member to be documented
+     * @param tdSummary the content tree to which the link will be added
+     */
+    protected void addSummaryLink(ClassDoc cd, ProgramElementDoc member,
+            Content tdSummary) {
+        addSummaryLink(LinkInfoImpl.CONTEXT_MEMBER, cd, member, tdSummary);
     }
 
-    protected abstract void writeSummaryLink(int context,
-                                             ClassDoc cd,
-                                             ProgramElementDoc member);
+    /**
+     * Add the summary link for the member.
+     *
+     * @param context the id of the context where the link will be printed
+     * @param cd the class doc to be documented
+     * @param member the member to be documented
+     * @param tdSummary the content tree to which the summary link will be added
+     */
+    protected abstract void addSummaryLink(int context,
+            ClassDoc cd, ProgramElementDoc member, Content tdSummary);
 
-    protected abstract void writeInheritedSummaryLink(ClassDoc cd,
-                                                     ProgramElementDoc member);
+    /**
+     * Add the inherited summary link for the member.
+     *
+     * @param cd the class doc to be documented
+     * @param member the member to be documented
+     * @param linksTree the content tree to which the inherited summary link will be added
+     */
+    protected abstract void addInheritedSummaryLink(ClassDoc cd,
+            ProgramElementDoc member, Content linksTree);
 
-    protected abstract void writeDeprecatedLink(ProgramElementDoc member);
+    /**
+     * Get the deprecated link.
+     *
+     * @param member the member being linked to
+     * @return a content tree representing the link
+     */
+    protected abstract Content getDeprecatedLink(ProgramElementDoc member);
 
-    protected abstract void printNavSummaryLink(ClassDoc cd, boolean link);
+    /**
+     * Get the navigation summary link.
+     *
+     * @param cd the class doc to be documented
+     * @param link true if its a link else the label to be printed
+     * @return a content tree for the navigation summary link.
+     */
+    protected abstract Content getNavSummaryLink(ClassDoc cd, boolean link);
 
-    protected abstract void printNavDetailLink(boolean link);
+    /**
+     * Add the navigation detail link.
+     *
+     * @param link true if its a link else the label to be printed
+     * @param liNav the content tree to which the navigation detail link will be added
+     */
+    protected abstract void addNavDetailLink(boolean link, Content liNav);
 
     /***  ***/
 
@@ -109,6 +199,17 @@
     }
 
     /**
+     * Add the member name to the content tree and modifies the display length.
+     *
+     * @param name the member name to be added to the content tree.
+     * @param htmltree the content tree to which the name will be added.
+     */
+    protected void addName(String name, Content htmltree) {
+        htmltree.addContent(name);
+        writer.displayLength += name.length();
+    }
+
+    /**
      * Return a string describing the access modifier flags.
      * Don't include native or synchronized.
      *
@@ -131,18 +232,24 @@
         return type;
     }
 
-    protected void printModifiers(MemberDoc member) {
+    /**
+     * Add the modifier for the member.
+     *
+     * @param member the member for which teh modifier will be added.
+     * @param htmltree the content tree to which the modifier information will be added.
+     */
+    protected void addModifiers(MemberDoc member, Content htmltree) {
         String mod = modifierString(member);
         // According to JLS, we should not be showing public modifier for
         // interface methods.
         if ((member.isField() || member.isMethod()) &&
             writer instanceof ClassWriterImpl &&
-             ((ClassWriterImpl) writer).getClassDoc().isInterface()) {
+            ((ClassWriterImpl) writer).getClassDoc().isInterface()) {
             mod = Util.replaceText(mod, "public", "").trim();
         }
         if(mod.length() > 0) {
-            print(mod);
-            print(' ');
+            htmltree.addContent(mod);
+            htmltree.addContent(writer.getSpace());
         }
     }
 
@@ -158,66 +265,43 @@
     }
 
     /**
-     * Print 'static' if static and type link.
+     * Add the modifier and type for the member in the member summary.
+     *
+     * @param member the member to add the type for
+     * @param type the type to add
+     * @param tdSummaryType the content tree to which the modified and type will be added
      */
-    protected void printStaticAndType(boolean isStatic, Type type) {
-        writer.printTypeSummaryHeader();
-        if (isStatic) {
-            print("static");
-        }
-        writer.space();
-        if (type != null) {
-            writer.printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER,
-                type));
-        }
-        writer.printTypeSummaryFooter();
-    }
-
-    /**
-     * Print the modifier and type for the member in the member summary.
-     *
-     * @param member the member to print the type for.
-     * @param type   the type to print.
-     */
-    protected void printModifierAndType(ProgramElementDoc member, Type type) {
-        writer.printTypeSummaryHeader();
-        printModifier(member);
+    protected void addModifierAndType(ProgramElementDoc member, Type type,
+            Content tdSummaryType) {
+        HtmlTree code = new HtmlTree(HtmlTag.CODE);
+        addModifier(member, code);
         if (type == null) {
-            writer.space();
             if (member.isClass()) {
-                print("class");
+                code.addContent("class");
             } else {
-                print("interface");
+                code.addContent("interface");
             }
+            code.addContent(writer.getSpace());
         } else {
             if (member instanceof ExecutableMemberDoc &&
                     ((ExecutableMemberDoc) member).typeParameters().length > 0) {
                 //Code to avoid ugly wrapping in member summary table.
-                writer.table(0,0,0);
-                writer.trAlignVAlign("right", "");
-                writer.tdNowrap();
-                writer.font("-1");
-                writer.code();
-                int displayLength = ((AbstractExecutableMemberWriter) this).
-                writeTypeParameters((ExecutableMemberDoc) member);
+                int displayLength = ((AbstractExecutableMemberWriter) this).addTypeParameters(
+                        (ExecutableMemberDoc) member, code);
                 if (displayLength > 10) {
-                    writer.br();
+                    code.addContent(new HtmlTree(HtmlTag.BR));
                 }
-                writer.printLink(new LinkInfoImpl(
-                    LinkInfoImpl.CONTEXT_SUMMARY_RETURN_TYPE, type));
-                writer.codeEnd();
-                writer.fontEnd();
-                writer.tdEnd();
-                writer.trEnd();
-                writer.tableEnd();
+                code.addContent(new RawHtml(
+                        writer.getLink(new LinkInfoImpl(
+                        LinkInfoImpl.CONTEXT_SUMMARY_RETURN_TYPE, type))));
             } else {
-                writer.space();
-                writer.printLink(new LinkInfoImpl(
-                    LinkInfoImpl.CONTEXT_SUMMARY_RETURN_TYPE, type));
+                code.addContent(new RawHtml(
+                        writer.getLink(new LinkInfoImpl(
+                        LinkInfoImpl.CONTEXT_SUMMARY_RETURN_TYPE, type))));
             }
 
         }
-        writer.printTypeSummaryFooter();
+        tdSummaryType.addContent(code);
     }
 
     private void printModifier(ProgramElementDoc member) {
@@ -238,25 +322,53 @@
     }
 
     /**
-     * Print the deprecated output for the given member.
+     * Add the modifier for the member.
+     *
+     * @param member the member to add the type for
+     * @param code the content tree to which the modified will be added
+     */
+    private void addModifier(ProgramElementDoc member, Content code) {
+        if (member.isProtected()) {
+            code.addContent("protected ");
+        } else if (member.isPrivate()) {
+            code.addContent("private ");
+        } else if (!member.isPublic()) { // Package private
+            code.addContent(configuration().getText("doclet.Package_private"));
+            code.addContent(" ");
+        }
+        if (member.isMethod() && ((MethodDoc)member).isAbstract()) {
+            code.addContent("abstract ");
+        }
+        if (member.isStatic()) {
+            code.addContent("static ");
+        }
+    }
+
+    /**
+     * Add the deprecated information for the given member.
      *
      * @param member the member being documented.
+     * @param contentTree the content tree to which the deprecated information will be added.
      */
-    protected void printDeprecated(ProgramElementDoc member) {
+    protected void addDeprecatedInfo(ProgramElementDoc member, Content contentTree) {
         String output = (new DeprecatedTaglet()).getTagletOutput(member,
             writer.getTagletWriterInstance(false)).toString().trim();
         if (!output.isEmpty()) {
-            writer.printMemberDetailsListStartTag();
-            writer.print(output);
+            Content deprecatedContent = new RawHtml(output);
+            Content div = HtmlTree.DIV(HtmlStyle.block, deprecatedContent);
+            contentTree.addContent(div);
         }
     }
 
-    protected void printComment(ProgramElementDoc member) {
+    /**
+     * Add the comment for the given member.
+     *
+     * @param member the member being documented.
+     * @param contentTree the content tree to which the comment will be added.
+     */
+    protected void addComment(ProgramElementDoc member, Content htmltree) {
         if (member.inlineTags().length > 0) {
-            writer.printMemberDetailsListStartTag();
-            writer.dd();
-            writer.printInlineComment(member);
-            writer.ddEnd();
+            writer.addInlineComment(member, htmltree);
         }
     }
 
@@ -264,67 +376,19 @@
         return member.name();
     }
 
-    protected void printHead(MemberDoc member) {
-        writer.h3();
-        writer.print(member.name());
-        writer.h3End();
-    }
-
-    protected void printFullComment(ProgramElementDoc member) {
-        if(configuration().nocomment){
-            return;
-        }
-        writer.dl();
-        print(((TagletOutputImpl)
-            (new DeprecatedTaglet()).getTagletOutput(member,
-            writer.getTagletWriterInstance(false))).toString());
-        printCommentAndTags(member);
-        writer.dlEnd();
-    }
-
-    protected void printCommentAndTags(ProgramElementDoc member) {
-        printComment(member);
-        writer.printTags(member);
+    /**
+     * Get the header for the section.
+     *
+     * @param member the member being documented.
+     * @return a header content for the section.
+     */
+    protected Content getHead(MemberDoc member) {
+        Content memberContent = new RawHtml(member.name());
+        Content heading = HtmlTree.HEADING(HtmlConstants.MEMBER_HEADING, memberContent);
+        return heading;
     }
 
     /**
-     * Write the member footer.
-     */
-    protected void printMemberFooter() {
-        writer.printMemberDetailsListEndTag();
-        assert !writer.getMemberDetailsListPrinted();
-    }
-
-    /**
-     * Forward to containing writer
-     */
-    public void printSummaryHeader(ClassDoc cd) {
-        printedSummaryHeader = true;
-        writer.printSummaryHeader(this, cd);
-    }
-
-    /**
-     * Forward to containing writer
-     */
-    public void printInheritedSummaryHeader(ClassDoc cd) {
-        writer.printInheritedSummaryHeader(this, cd);
-    }
-
-    /**
-     * Forward to containing writer
-     */
-    public void printInheritedSummaryFooter(ClassDoc cd) {
-        writer.printInheritedSummaryFooter(this, cd);
-    }
-
-    /**
-     * Forward to containing writer
-     */
-    public void printSummaryFooter(ClassDoc cd) {
-        writer.printSummaryFooter(this, cd);
-    }
-
-   /**
     * Return true if the given <code>ProgramElement</code> is inherited
     * by the class that is being documented.
     *
@@ -340,102 +404,134 @@
         return true;
     }
 
-
     /**
-     * Generate the code for listing the deprecated APIs. Create the table
-     * format for listing the API. Call methods from the sub-class to complete
-     * the generation.
+     * Add deprecated information to the documentation tree
+     *
+     * @param deprmembers list of deprecated members
+     * @param headingKey the caption for the deprecated members table
+     * @param tableSummary the summary for the deprecated members table
+     * @param tableHeader table headers for the deprecated members table
+     * @param contentTree the content tree to which the deprecated members table will be added
      */
-    protected void printDeprecatedAPI(List<Doc> deprmembers, String headingKey, String tableSummary, String[] tableHeader) {
+    protected void addDeprecatedAPI(List<Doc> deprmembers, String headingKey,
+            String tableSummary, String[] tableHeader, Content contentTree) {
         if (deprmembers.size() > 0) {
-            writer.tableIndexSummary(tableSummary);
-            writer.tableCaptionStart();
-            writer.printText(headingKey);
-            writer.tableCaptionEnd();
-            writer.summaryTableHeader(tableHeader, "col");
+            Content table = HtmlTree.TABLE(0, 3, 0, tableSummary,
+                writer.getTableCaption(configuration().getText(headingKey)));
+            table.addContent(writer.getSummaryTableHeader(tableHeader, "col"));
+            Content tbody = new HtmlTree(HtmlTag.TBODY);
             for (int i = 0; i < deprmembers.size(); i++) {
                 ProgramElementDoc member =(ProgramElementDoc)deprmembers.get(i);
-                writer.trBgcolorStyle("white", "TableRowColor");
-                writer.summaryRow(0);
-                writeDeprecatedLink(member);
-                writer.br();
-                writer.printNbsps();
+                HtmlTree td = HtmlTree.TD(HtmlStyle.colOne, getDeprecatedLink(member));
                 if (member.tags("deprecated").length > 0)
-                    writer.printInlineDeprecatedComment(member, member.tags("deprecated")[0]);
-                writer.space();
-                writer.summaryRowEnd();
-                writer.trEnd();
+                    writer.addInlineDeprecatedComment(member,
+                            member.tags("deprecated")[0], td);
+                HtmlTree tr = HtmlTree.TR(td);
+                if (i%2 == 0)
+                    tr.addStyle(HtmlStyle.altColor);
+                else
+                    tr.addStyle(HtmlStyle.rowColor);
+                tbody.addContent(tr);
             }
-            writer.tableEnd();
-            writer.space();
-            writer.p();
+            table.addContent(tbody);
+            Content li = HtmlTree.LI(HtmlStyle.blockList, table);
+            Content ul = HtmlTree.UL(HtmlStyle.blockList, li);
+            contentTree.addContent(ul);
         }
     }
 
     /**
-     * Print use info.
+     * Add use information to the documentation tree.
+     *
+     * @param mems list of program elements for which the use information will be added
+     * @param heading the section heading
+     * @param tableSummary the summary for the use table
+     * @param contentTree the content tree to which the use information will be added
      */
-    protected void printUseInfo(List<? extends ProgramElementDoc> mems, String heading, String tableSummary) {
+    protected void addUseInfo(List<? extends ProgramElementDoc> mems,
+            String heading, String tableSummary, Content contentTree) {
         if (mems == null) {
             return;
         }
         List<? extends ProgramElementDoc> members = mems;
         boolean printedUseTableHeader = false;
         if (members.size() > 0) {
-            writer.tableIndexSummary(tableSummary);
-            writer.tableSubCaptionStart();
-            writer.print(heading);
-            writer.tableCaptionEnd();
-            for (Iterator<? extends ProgramElementDoc> it = members.iterator(); it.hasNext(); ) {
+            Content table = HtmlTree.TABLE(0, 3, 0, tableSummary,
+                    writer.getTableCaption(heading));
+            Content tbody = new HtmlTree(HtmlTag.TBODY);
+            Iterator<? extends ProgramElementDoc> it = members.iterator();
+            for (int i = 0; it.hasNext(); i++) {
                 ProgramElementDoc pgmdoc = it.next();
                 ClassDoc cd = pgmdoc.containingClass();
                 if (!printedUseTableHeader) {
-                    // Passing ProgramElementDoc helps decides printing
-                    // interface or class header in case of nested classes.
-                    this.printSummaryTableHeader(pgmdoc);
+                    table.addContent(writer.getSummaryTableHeader(
+                            this.getSummaryTableHeader(pgmdoc), "col"));
                     printedUseTableHeader = true;
                 }
-
-                writer.printSummaryLinkType(this, pgmdoc);
+                HtmlTree tr = new HtmlTree(HtmlTag.TR);
+                if (i % 2 == 0) {
+                    tr.addStyle(HtmlStyle.altColor);
+                } else {
+                    tr.addStyle(HtmlStyle.rowColor);
+                }
+                HtmlTree tdFirst = new HtmlTree(HtmlTag.TD);
+                tdFirst.addStyle(HtmlStyle.colFirst);
+                writer.addSummaryType(this, pgmdoc, tdFirst);
+                tr.addContent(tdFirst);
+                HtmlTree tdLast = new HtmlTree(HtmlTag.TD);
+                tdLast.addStyle(HtmlStyle.colLast);
                 if (cd != null && !(pgmdoc instanceof ConstructorDoc)
-                               && !(pgmdoc instanceof ClassDoc)) {
-                    // Add class context
-                    writer.strong(cd.name() + ".");
+                        && !(pgmdoc instanceof ClassDoc)) {
+                    HtmlTree name = new HtmlTree(HtmlTag.SPAN);
+                    name.addStyle(HtmlStyle.strong);
+                    name.addContent(cd.name() + ".");
+                    tdLast.addContent(name);
                 }
-                writeSummaryLink(
-                    pgmdoc instanceof ClassDoc ?
-                        LinkInfoImpl.CONTEXT_CLASS_USE : LinkInfoImpl.CONTEXT_MEMBER,
-                    cd, pgmdoc);
-                writer.printSummaryLinkComment(this, pgmdoc);
+                addSummaryLink(pgmdoc instanceof ClassDoc ?
+                    LinkInfoImpl.CONTEXT_CLASS_USE : LinkInfoImpl.CONTEXT_MEMBER,
+                    cd, pgmdoc, tdLast);
+                writer.addSummaryLinkComment(this, pgmdoc, tdLast);
+                tr.addContent(tdLast);
+                tbody.addContent(tr);
             }
-            writer.tableEnd();
-            writer.space();
-            writer.p();
+            table.addContent(tbody);
+            contentTree.addContent(table);
         }
     }
 
-    protected void navDetailLink(List<?> members) {
-            printNavDetailLink(members.size() > 0? true: false);
+    /**
+     * Add the navigation detail link.
+     *
+     * @param members the members to be linked
+     * @param liNav the content tree to which the navigation detail link will be added
+     */
+    protected void addNavDetailLink(List<?> members, Content liNav) {
+        addNavDetailLink(members.size() > 0 ? true : false, liNav);
     }
 
-
-    protected void navSummaryLink(List<?> members,
-            VisibleMemberMap visibleMemberMap) {
+    /**
+     * Add the navigation summary link.
+     *
+     * @param members members to be linked
+     * @param visibleMemberMap the visible inherited members map
+     * @param liNav the content tree to which the navigation summary link will be added
+     */
+    protected void addNavSummaryLink(List<?> members,
+            VisibleMemberMap visibleMemberMap, Content liNav) {
         if (members.size() > 0) {
-            printNavSummaryLink(null, true);
+            liNav.addContent(getNavSummaryLink(null, true));
             return;
-        } else {
-            ClassDoc icd = classdoc.superclass();
-            while (icd != null) {
-                List<?> inhmembers = visibleMemberMap.getMembersFor(icd);
-                if (inhmembers.size() > 0) {
-                    printNavSummaryLink(icd, true);
-                    return;
-                }
-                icd = icd.superclass();
+        }
+        ClassDoc icd = classdoc.superclass();
+        while (icd != null) {
+            List<?> inhmembers = visibleMemberMap.getMembersFor(icd);
+            if (inhmembers.size() > 0) {
+                liNav.addContent(getNavSummaryLink(icd, true));
+                return;
             }
+            icd = icd.superclass();
         }
-        printNavSummaryLink(null, false);
+        liNav.addContent(getNavSummaryLink(null, false));
     }
 
     protected void serialWarning(SourcePosition pos, String key, String a1, String a2) {
@@ -453,12 +549,109 @@
     }
 
     /**
-     * {@inheritDoc}
+     * Add the member summary for the given class.
+     *
+     * @param classDoc the class that is being documented
+     * @param member the member being documented
+     * @param firstSentenceTags the first sentence tags to be added to the summary
+     * @param tableTree the content tree to which the documentation will be added
+     * @param counter the counter for determing style for the table row
      */
-    public void writeMemberSummary(ClassDoc classDoc, ProgramElementDoc member,
-        Tag[] firstSentenceTags, boolean isFirst, boolean isLast) {
-        writer.printSummaryLinkType(this, member);
-        writeSummaryLink(classDoc, member);
-        writer.printSummaryLinkComment(this, member, firstSentenceTags);
+    public void addMemberSummary(ClassDoc classDoc, ProgramElementDoc member,
+            Tag[] firstSentenceTags, Content tableTree, int counter) {
+        HtmlTree tdSummaryType = new HtmlTree(HtmlTag.TD);
+        tdSummaryType.addStyle(HtmlStyle.colFirst);
+        writer.addSummaryType(this, member, tdSummaryType);
+        HtmlTree tdSummary = new HtmlTree(HtmlTag.TD);
+        setSummaryColumnStyle(tdSummary);
+        addSummaryLink(classDoc, member, tdSummary);
+        writer.addSummaryLinkComment(this, member, firstSentenceTags, tdSummary);
+        HtmlTree tr = HtmlTree.TR(tdSummaryType);
+        tr.addContent(tdSummary);
+        if (counter%2 == 0)
+            tr.addStyle(HtmlStyle.altColor);
+        else
+            tr.addStyle(HtmlStyle.rowColor);
+        tableTree.addContent(tr);
+    }
+
+    /**
+     * Set the style for the summary column.
+     *
+     * @param tdTree the column for which the style will be set
+     */
+    public void setSummaryColumnStyle(HtmlTree tdTree) {
+        tdTree.addStyle(HtmlStyle.colLast);
+    }
+
+    /**
+     * Add inherited member summary for the given class and member.
+     *
+     * @param classDoc the class the inherited member belongs to
+     * @param nestedClass the inherited member that is summarized
+     * @param isFirst true if this is the first member in the list
+     * @param isLast true if this is the last member in the list
+     * @param linksTree the content tree to which the summary will be added
+     */
+    public void addInheritedMemberSummary(ClassDoc classDoc,
+            ProgramElementDoc nestedClass, boolean isFirst, boolean isLast,
+            Content linksTree) {
+        writer.addInheritedMemberSummary(this, classDoc, nestedClass, isFirst,
+                linksTree);
+    }
+
+    /**
+     * Get the inherited summary header for the given class.
+     *
+     * @param classDoc the class the inherited member belongs to
+     * @return a content tree for the inherited summary header
+     */
+    public Content getInheritedSummaryHeader(ClassDoc classDoc) {
+        Content inheritedTree = writer.getMemberTreeHeader();
+        writer.addInheritedSummaryHeader(this, classDoc, inheritedTree);
+        return inheritedTree;
+    }
+
+    /**
+     * Get the inherited summary links tree.
+     *
+     * @return a content tree for the inherited summary links
+     */
+    public Content getInheritedSummaryLinksTree() {
+        return new HtmlTree(HtmlTag.CODE);
+    }
+
+    /**
+     * Get the summary table tree for the given class.
+     *
+     * @param classDoc the class for which the summary table is generated
+     * @return a content tree for the summary table
+     */
+    public Content getSummaryTableTree(ClassDoc classDoc) {
+        return writer.getSummaryTableTree(this, classDoc);
+    }
+
+    /**
+     * Get the member tree to be documented.
+     *
+     * @param memberTree the content tree of member to be documented
+     * @return a content tree that will be added to the class documentation
+     */
+    public Content getMemberTree(Content memberTree) {
+        return writer.getMemberTree(memberTree);
+    }
+
+    /**
+     * Get the member tree to be documented.
+     *
+     * @param memberTree the content tree of member to be documented
+     * @param isLastContent true if the content to be added is the last content
+     * @return a content tree that will be added to the class documentation
+     */
+    public Content getMemberTree(Content memberTree, boolean isLastContent) {
+        if (isLastContent)
+            return HtmlTree.UL(HtmlStyle.blockListLast, memberTree);
+        else
+            return HtmlTree.UL(HtmlStyle.blockList, memberTree);
     }
 }
--- a/src/share/classes/com/sun/tools/doclets/formats/html/AbstractPackageIndexWriter.java	Thu Dec 16 19:57:01 2010 -0800
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/AbstractPackageIndexWriter.java	Mon Dec 20 21:10:57 2010 -0800
@@ -25,9 +25,11 @@
 
 package com.sun.tools.doclets.formats.html;
 
-import com.sun.javadoc.*;
 import java.io.*;
 import java.util.*;
+import com.sun.javadoc.*;
+import com.sun.tools.doclets.formats.html.markup.*;
+import com.sun.tools.doclets.internal.toolkit.*;
 
 /**
  * Abstract class to generate the overview files in
@@ -56,105 +58,127 @@
         packages = configuration.packages;
     }
 
-    protected abstract void printNavigationBarHeader();
-
-    protected abstract void printNavigationBarFooter();
-
-    protected abstract void printOverviewHeader();
-
-    protected abstract void printIndexHeader(String text, String tableSummary);
-
-    protected abstract void printIndexRow(PackageDoc pkg);
-
-    protected abstract void printIndexFooter();
+    /**
+     * Adds the navigation bar header to the documentation tree.
+     *
+     * @param body the document tree to which the navigation bar header will be added
+     */
+    protected abstract void addNavigationBarHeader(Content body);
 
     /**
-     * Generate the contants in the package index file. Call appropriate
+     * Adds the navigation bar footer to the documentation tree.
+     *
+     * @param body the document tree to which the navigation bar footer will be added
+     */
+    protected abstract void addNavigationBarFooter(Content body);
+
+    /**
+     * Adds the overview header to the documentation tree.
+     *
+     * @param body the document tree to which the overview header will be added
+     */
+    protected abstract void addOverviewHeader(Content body);
+
+    /**
+     * Adds the packages list to the documentation tree.
+     *
+     * @param packages an array of packagedoc objects
+     * @param text caption for the table
+     * @param tableSummary summary for the table
+     * @param body the document tree to which the packages list will be added
+     */
+    protected abstract void addPackagesList(PackageDoc[] packages, String text,
+            String tableSummary, Content body);
+
+    /**
+     * Generate and prints the contents in the package index file. Call appropriate
      * methods from the sub-class in order to generate Frame or Non
      * Frame format.
+     *
      * @param title the title of the window.
      * @param includeScript boolean set true if windowtitle script is to be included
      */
-    protected void generatePackageIndexFile(String title, boolean includeScript) throws IOException {
+    protected void buildPackageIndexFile(String title, boolean includeScript) throws IOException {
         String windowOverview = configuration.getText(title);
-        printHtmlHeader(windowOverview,
-            configuration.metakeywords.getOverviewMetaKeywords(title,
-                configuration.doctitle),
-            includeScript);
-        printNavigationBarHeader();
-        printOverviewHeader();
-
-        generateIndex();
-
-        printOverview();
-
-        printNavigationBarFooter();
-        printBodyHtmlEnd();
+        Content body = getBody(includeScript, getWindowTitle(windowOverview));
+        addNavigationBarHeader(body);
+        addOverviewHeader(body);
+        addIndex(body);
+        addOverview(body);
+        addNavigationBarFooter(body);
+        printHtmlDocument(configuration.metakeywords.getOverviewMetaKeywords(title,
+                configuration.doctitle), includeScript, body);
     }
 
     /**
-     * Default to no overview, overwrite to add overview.
+     * Default to no overview, override to add overview.
+     *
+     * @param body the document tree to which the overview will be added
      */
-    protected void printOverview() throws IOException {
+    protected void addOverview(Content body) throws IOException {
     }
 
     /**
-     * Generate the frame or non-frame package index.
+     * Adds the frame or non-frame package index to the documentation tree.
+     *
+     * @param body the document tree to which the index will be added
      */
-    protected void generateIndex() {
-        printIndexContents(packages, "doclet.Package_Summary",
+    protected void addIndex(Content body) {
+        addIndexContents(packages, "doclet.Package_Summary",
                 configuration.getText("doclet.Member_Table_Summary",
                 configuration.getText("doclet.Package_Summary"),
-                configuration.getText("doclet.packages")));
+                configuration.getText("doclet.packages")), body);
     }
 
     /**
-     * Generate code for package index contents. Call appropriate methods from
-     * the sub-classes.
+     * Adds package index contents. Call appropriate methods from
+     * the sub-classes. Adds it to the body HtmlTree
      *
-     * @param packages Array of packages to be documented.
-     * @param text     String which will be used as the heading.
+     * @param packages array of packages to be documented
+     * @param text string which will be used as the heading
+     * @param tableSummary summary for the table
+     * @param body the document tree to which the index contents will be added
      */
-    protected void printIndexContents(PackageDoc[] packages, String text, String tableSummary) {
+    protected void addIndexContents(PackageDoc[] packages, String text,
+            String tableSummary, Content body) {
         if (packages.length > 0) {
             Arrays.sort(packages);
-            printIndexHeader(text, tableSummary);
-            printAllClassesPackagesLink();
-            for(int i = 0; i < packages.length; i++) {
-                if (packages[i] != null) {
-                    printIndexRow(packages[i]);
-                }
-            }
-            printIndexFooter();
+            addAllClassesLink(body);
+            addPackagesList(packages, text, tableSummary, body);
         }
     }
 
     /**
-     * Print the doctitle, if it is specified on the command line.
+     * Adds the doctitle to the documentation tree, if it is specified on the command line.
+     *
+     * @param body the document tree to which the title will be added
      */
-    protected void printConfigurationTitle() {
+    protected void addConfigurationTitle(Content body) {
         if (configuration.doctitle.length() > 0) {
-            center();
-            h1(configuration.doctitle);
-            centerEnd();
+            Content title = new RawHtml(configuration.doctitle);
+            Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING,
+                    HtmlStyle.title, title);
+            Content div = HtmlTree.DIV(HtmlStyle.header, heading);
+            body.addContent(div);
         }
     }
 
     /**
-     * Highlight "Overview" in the strong format, in the navigation bar as this
-     * is the overview page.
+     * Returns highlighted "Overview", in the navigation bar as this is the
+     * overview page.
+     *
+     * @return a Content object to be added to the documentation tree
      */
-    protected void navLinkContents() {
-        navCellRevStart();
-        fontStyle("NavBarFont1Rev");
-        strongText("doclet.Overview");
-        fontEnd();
-        navCellEnd();
+    protected Content getNavLinkContents() {
+        Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, overviewLabel);
+        return li;
     }
 
     /**
      * Do nothing. This will be overridden in PackageIndexFrameWriter.
+     *
+     * @param body the document tree to which the all classes link will be added
      */
-    protected void printAllClassesPackagesLink() {
+    protected void addAllClassesLink(Content body) {
     }
 }
--- a/src/share/classes/com/sun/tools/doclets/formats/html/AbstractTreeWriter.java	Thu Dec 16 19:57:01 2010 -0800
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/AbstractTreeWriter.java	Mon Dec 20 21:10:57 2010 -0800
@@ -25,11 +25,12 @@
 
 package com.sun.tools.doclets.formats.html;
 
-import com.sun.tools.doclets.internal.toolkit.util.*;
-
-import com.sun.javadoc.*;
 import java.io.*;
 import java.util.*;
+import com.sun.tools.doclets.internal.toolkit.util.*;
+import com.sun.tools.doclets.internal.toolkit.*;
+import com.sun.tools.doclets.formats.html.markup.*;
+import com.sun.javadoc.*;
 
 /**
  * Abstract class to print the class hierarchy page for all the Classes. This
@@ -46,6 +47,8 @@
      */
     protected final ClassTree classtree;
 
+    private static final String LI_CIRCLE  = "circle";
+
     /**
      * Constructor initilises classtree variable. This constructor will be used
      * while generating global tree file "overview-tree.html".
@@ -87,55 +90,64 @@
     }
 
     /**
-     * Generate each level of the class tree. For each sub-class or
+     * Add each level of the class tree. For each sub-class or
      * sub-interface indents the next level information.
-     * Recurses itself to generate subclasses info.
-     * To iterate is human, to recurse is divine - L. Peter Deutsch.
+     * Recurses itself to add subclasses info.
      *
-     * @param parent the superclass or superinterface of the list.
-     * @param list list of the sub-classes at this level.
-     * @param isEnum true if we are generating a tree for enums.
+     * @param parent the superclass or superinterface of the list
+     * @param list list of the sub-classes at this level
+     * @param isEnum true if we are generating a tree for enums
+     * @param contentTree the content tree to which the level information will be added
      */
-    protected void generateLevelInfo(ClassDoc parent, List<ClassDoc> list,
-            boolean isEnum) {
-        if (list.size() > 0) {
-            ul();
-            for (int i = 0; i < list.size(); i++) {
+    protected void addLevelInfo(ClassDoc parent, List<ClassDoc> list,
+            boolean isEnum, Content contentTree) {
+        int size = list.size();
+        if (size > 0) {
+            Content ul = new HtmlTree(HtmlTag.UL);
+            for (int i = 0; i < size; i++) {
                 ClassDoc local = list.get(i);
-                printPartialInfo(local);
-                printExtendsImplements(parent, local);
-                generateLevelInfo(local, classtree.subs(local, isEnum),
-                    isEnum);   // Recurse
+                HtmlTree li = new HtmlTree(HtmlTag.LI);
+                li.addAttr(HtmlAttr.TYPE, LI_CIRCLE);
+                addPartialInfo(local, li);
+                addExtendsImplements(parent, local, li);
+                addLevelInfo(local, classtree.subs(local, isEnum),
+                        isEnum, li);   // Recurse
+                ul.addContent(li);
             }
-            ulEnd();
+            contentTree.addContent(ul);
         }
     }
 
     /**
-     * Generate the heading for the tree depending upon tree type if it's a
-     * Class Tree or Interface tree and also print the tree.
+     * Add the heading for the tree depending upon tree type if it's a
+     * Class Tree or Interface tree.
      *
      * @param list List of classes which are at the most base level, all the
-     * other classes in this run will derive from these classes.
-     * @param heading Heading for the tree.
+     * other classes in this run will derive from these classes
+     * @param heading heading for the tree
+     * @param div the content tree to which the tree will be added
      */
-    protected void generateTree(List<ClassDoc> list, String heading) {
+    protected void addTree(List<ClassDoc> list, String heading, Content div) {
         if (list.size() > 0) {
             ClassDoc firstClassDoc = list.get(0);
-            printTreeHeading(heading);
-            generateLevelInfo(!firstClassDoc.isInterface()? firstClassDoc : null,
-                list,
-                list == classtree.baseEnums());
+            Content headingContent = getResource(heading);
+            div.addContent(HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, true,
+                    headingContent));
+            addLevelInfo(!firstClassDoc.isInterface()? firstClassDoc : null,
+                    list, list == classtree.baseEnums(), div);
         }
     }
 
     /**
-     * Print the information regarding the classes which this class extends or
+     * Add information regarding the classes which this class extends or
      * implements.
      *
-     * @param cd The classdoc under consideration.
+     * @param parent the parent class of the class being documented
+     * @param cd the classdoc under consideration
+     * @param contentTree the content tree to which the information will be added
      */
-    protected void printExtendsImplements(ClassDoc parent, ClassDoc cd) {
+    protected void addExtendsImplements(ClassDoc parent, ClassDoc cd,
+            Content contentTree) {
         ClassDoc[] interfaces = cd.interfaces();
         if (interfaces.length > (cd.isInterface()? 1 : 0)) {
             Arrays.sort(interfaces);
@@ -148,53 +160,43 @@
                     }
                     if (counter == 0) {
                         if (cd.isInterface()) {
-                            print(" (" + configuration.getText("doclet.also") + " extends ");
+                            contentTree.addContent(" (");
+                            contentTree.addContent(getResource("doclet.also"));
+                            contentTree.addContent(" extends ");
                         } else {
-                            print(" (implements ");
+                            contentTree.addContent(" (implements ");
                         }
                     } else {
-                        print(", ");
+                        contentTree.addContent(", ");
                     }
-                    printPreQualifiedClassLink(LinkInfoImpl.CONTEXT_TREE,
-                        interfaces[i]);
+                    addPreQualifiedClassLink(LinkInfoImpl.CONTEXT_TREE,
+                            interfaces[i], contentTree);
                     counter++;
                 }
             }
             if (counter > 0) {
-                println(")");
+                contentTree.addContent(")");
             }
         }
     }
 
     /**
-     * Print information about the class kind, if it's a "class" or "interface".
+     * Add information about the class kind, if it's a "class" or "interface".
      *
-     * @param cd classdoc.
+     * @param cd the class being documented
+     * @param contentTree the content tree to which the information will be added
      */
-    protected void printPartialInfo(ClassDoc cd) {
-        li("circle");
-        printPreQualifiedStrongClassLink(LinkInfoImpl.CONTEXT_TREE, cd);
+    protected void addPartialInfo(ClassDoc cd, Content contentTree) {
+        addPreQualifiedStrongClassLink(LinkInfoImpl.CONTEXT_TREE, cd, contentTree);
     }
 
     /**
-     * Print the heading for the tree.
+     * Get the tree label for the navigation bar.
      *
-     * @param heading Heading for the tree.
+     * @return a content tree for the tree label
      */
-    protected void printTreeHeading(String heading) {
-        h2();
-        println(configuration.getText(heading));
-        h2End();
-    }
-
-    /**
-     * Highlight "Tree" word in the navigation bar, since this is the tree page.
-     */
-    protected void navLinkTree() {
-        navCellRevStart();
-        fontStyle("NavBarFont1Rev");
-        strongText("doclet.Tree");
-        fontEnd();
-        navCellEnd();
+    protected Content getNavLinkTree() {
+        Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, treeLabel);
+        return li;
     }
 }
--- a/src/share/classes/com/sun/tools/doclets/formats/html/AllClassesFrameWriter.java	Thu Dec 16 19:57:01 2010 -0800
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/AllClassesFrameWriter.java	Mon Dec 20 21:10:57 2010 -0800
@@ -25,11 +25,14 @@
 
 package com.sun.tools.doclets.formats.html;
 
-import com.sun.tools.doclets.internal.toolkit.util.*;
-import com.sun.javadoc.*;
 import java.io.*;
 import java.util.*;
 
+import com.sun.javadoc.*;
+import com.sun.tools.doclets.internal.toolkit.*;
+import com.sun.tools.doclets.internal.toolkit.util.*;
+import com.sun.tools.doclets.formats.html.markup.*;
+
 /**
  * Generate the file with list of all the classes in this run. This page will be
  * used in the left-hand bottom frame, when "All Classes" link is clicked in
@@ -38,6 +41,7 @@
  *
  * @author Atul M Dambalkar
  * @author Doug Kramer
+ * @author Bhavesh Patel (Modified)
  */
 public class AllClassesFrameWriter extends HtmlDocletWriter {
 
@@ -57,6 +61,11 @@
     protected IndexBuilder indexbuilder;
 
     /**
+     * BR tag to be used within a document tree.
+     */
+    final HtmlTree BR = new HtmlTree(HtmlTag.BR);
+
+    /**
      * Construct AllClassesFrameWriter object. Also initilises the indexbuilder
      * variable in this class.
      * @throws IOException
@@ -84,12 +93,12 @@
         try {
             allclassgen = new AllClassesFrameWriter(configuration,
                                                     filename, indexbuilder);
-            allclassgen.generateAllClassesFile(true);
+            allclassgen.buildAllClassesFile(true);
             allclassgen.close();
             filename = OUTPUT_FILE_NAME_NOFRAMES;
             allclassgen = new AllClassesFrameWriter(configuration,
                                                     filename, indexbuilder);
-            allclassgen.generateAllClassesFile(false);
+            allclassgen.buildAllClassesFile(false);
             allclassgen.close();
         } catch (IOException exc) {
             configuration.standardmessage.
@@ -100,30 +109,34 @@
     }
 
     /**
-     * Print all the classes in table format in the file.
+     * Print all the classes in the file.
      * @param wantFrames True if we want frames.
      */
-    protected void generateAllClassesFile(boolean wantFrames) throws IOException {
+    protected void buildAllClassesFile(boolean wantFrames) throws IOException {
         String label = configuration.getText("doclet.All_Classes");
-
-        printHtmlHeader(label, null, false);
-
-        printAllClassesTableHeader();
-        printAllClasses(wantFrames);
-        printAllClassesTableFooter();
-
-        printBodyHtmlEnd();
+        Content body = getBody(false, getWindowTitle(label));
+        Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING,
+                HtmlStyle.bar, allclassesLabel);
+        body.addContent(heading);
+        Content ul = new HtmlTree(HtmlTag.UL);
+        // Generate the class links and add it to the tdFont tree.
+        addAllClasses(ul, wantFrames);
+        Content div = HtmlTree.DIV(HtmlStyle.indexContainer, ul);
+        body.addContent(div);
+        printHtmlDocument(null, false, body);
     }
 
     /**
-     * Use the sorted index of all the classes and print all the classes.
+     * Use the sorted index of all the classes and add all the classes to the
+     * content list.
      *
+     * @param content HtmlTree content to which all classes information will be added
      * @param wantFrames True if we want frames.
      */
-    protected void printAllClasses(boolean wantFrames) {
+    protected void addAllClasses(Content content, boolean wantFrames) {
         for (int i = 0; i < indexbuilder.elements().length; i++) {
             Character unicode = (Character)((indexbuilder.elements())[i]);
-            generateContents(indexbuilder.getMemberList(unicode), wantFrames);
+            addContents(indexbuilder.getMemberList(unicode), wantFrames, content);
         }
     }
 
@@ -136,46 +149,25 @@
      *
      * @param classlist Sorted list of classes.
      * @param wantFrames True if we want frames.
+     * @param content HtmlTree content to which the links will be added
      */
-    protected void generateContents(List<Doc> classlist, boolean wantFrames) {
+    protected void addContents(List<Doc> classlist, boolean wantFrames,
+            Content content) {
         for (int i = 0; i < classlist.size(); i++) {
             ClassDoc cd = (ClassDoc)classlist.get(i);
             if (!Util.isCoreClass(cd)) {
                 continue;
             }
             String label = italicsClassName(cd, false);
+            Content linkContent;
             if(wantFrames){
-                printLink(new LinkInfoImpl(LinkInfoImpl.ALL_CLASSES_FRAME, cd,
-                    label, "classFrame")
-                );
+                linkContent = new RawHtml(getLink(new LinkInfoImpl(
+                        LinkInfoImpl.ALL_CLASSES_FRAME, cd, label, "classFrame")));
             } else {
-                printLink(new LinkInfoImpl(cd, label));
+                linkContent = new RawHtml(getLink(new LinkInfoImpl(cd, label)));
             }
-            br();
+            Content li = HtmlTree.LI(linkContent);
+            content.addContent(li);
         }
     }
-
-    /**
-     * Print the heading "All Classes" and also print Html table tag.
-     */
-    protected void printAllClassesTableHeader() {
-        fontSizeStyle("+1", "FrameHeadingFont");
-        strongText("doclet.All_Classes");
-        fontEnd();
-        br();
-        table();
-        tr();
-        tdNowrap();
-        fontStyle("FrameItemFont");
-    }
-
-    /**
-     * Print Html closing table tag.
-     */
-    protected void printAllClassesTableFooter() {
-        fontEnd();
-        tdEnd();
-        trEnd();
-        tableEnd();
-    }
 }
--- a/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java	Thu Dec 16 19:57:01 2010 -0800
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java	Mon Dec 20 21:10:57 2010 -0800
@@ -28,6 +28,7 @@
 import java.io.*;
 
 import com.sun.javadoc.*;
+import com.sun.tools.doclets.formats.html.markup.*;
 import com.sun.tools.doclets.internal.toolkit.*;
 
 /**
@@ -54,29 +55,26 @@
     /**
      * {@inheritDoc}
      */
-    public void writeMemberSummaryHeader(ClassDoc classDoc) {
-        writer.println("<!-- =========== ANNOTATION TYPE OPTIONAL MEMBER SUMMARY =========== -->");
-        writer.println();
-        writer.printSummaryHeader(this, classDoc);
+    public Content getMemberSummaryHeader(ClassDoc classDoc,
+            Content memberSummaryTree) {
+        memberSummaryTree.addContent(
+                HtmlConstants.START_OF_ANNOTATION_TYPE_OPTIONAL_MEMBER_SUMMARY);
+        Content memberTree = writer.getMemberTreeHeader();
+        writer.addSummaryHeader(this, classDoc, memberTree);
+        return memberTree;
     }
 
     /**
      * {@inheritDoc}
      */
-    public void writeDefaultValueInfo(MemberDoc member) {
+    public void addDefaultValueInfo(MemberDoc member, Content annotationDocTree) {
         if (((AnnotationTypeElementDoc) member).defaultValue() != null) {
-            writer.printMemberDetailsListStartTag();
-            writer.dd();
-            writer.dl();
-            writer.dt();
-            writer.strong(ConfigurationImpl.getInstance().
-                getText("doclet.Default"));
-            writer.dtEnd();
-            writer.dd();
-            writer.print(((AnnotationTypeElementDoc) member).defaultValue());
-            writer.ddEnd();
-            writer.dlEnd();
-            writer.ddEnd();
+            Content dt = HtmlTree.DT(writer.getResource("doclet.Default"));
+            Content dl = HtmlTree.DL(dt);
+            Content dd = HtmlTree.DD(new StringContent(
+                    ((AnnotationTypeElementDoc) member).defaultValue().toString()));
+            dl.addContent(dd);
+            annotationDocTree.addContent(dl);
         }
     }
 
@@ -90,45 +88,58 @@
     /**
      * {@inheritDoc}
      */
-    public void printSummaryLabel() {
-        writer.printText("doclet.Annotation_Type_Optional_Member_Summary");
+    public void addSummaryLabel(Content memberTree) {
+        Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
+                writer.getResource("doclet.Annotation_Type_Optional_Member_Summary"));
+        memberTree.addContent(label);
     }
 
     /**
      * {@inheritDoc}
      */
-    public void printTableSummary() {
-        writer.tableIndexSummary(configuration().getText("doclet.Member_Table_Summary",
+    public String getTableSummary() {
+        return configuration().getText("doclet.Member_Table_Summary",
                 configuration().getText("doclet.Annotation_Type_Optional_Member_Summary"),
-                configuration().getText("doclet.annotation_type_optional_members")));
+                configuration().getText("doclet.annotation_type_optional_members"));
     }
 
-    public void printSummaryTableHeader(ProgramElementDoc member) {
+    /**
+     * {@inheritDoc}
+     */
+    public String getCaption() {
+        return configuration().getText("doclet.Annotation_Type_Optional_Members");
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String[] getSummaryTableHeader(ProgramElementDoc member) {
         String[] header = new String[] {
             writer.getModifierTypeHeader(),
             configuration().getText("doclet.0_and_1",
                     configuration().getText("doclet.Annotation_Type_Optional_Member"),
                     configuration().getText("doclet.Description"))
         };
-        writer.summaryTableHeader(header, "col");
+        return header;
     }
 
     /**
      * {@inheritDoc}
      */
-    public void printSummaryAnchor(ClassDoc cd) {
-        writer.anchor("annotation_type_optional_element_summary");
+    public void addSummaryAnchor(ClassDoc cd, Content memberTree) {
+        memberTree.addContent(writer.getMarkerAnchor(
+                "annotation_type_optional_element_summary"));
     }
 
     /**
      * {@inheritDoc}
      */
-    protected void printNavSummaryLink(ClassDoc cd, boolean link) {
+    protected Content getNavSummaryLink(ClassDoc cd, boolean link) {
         if (link) {
-            writer.printHyperLink("", "annotation_type_optional_element_summary",
-                    configuration().getText("doclet.navAnnotationTypeOptionalMember"));
+            return writer.getHyperLink("", "annotation_type_optional_element_summary",
+                    writer.getResource("doclet.navAnnotationTypeOptionalMember"));
         } else {
-            writer.printText("doclet.navAnnotationTypeOptionalMember");
+            return writer.getResource("doclet.navAnnotationTypeOptionalMember");
         }
     }
 }
--- a/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java	Thu Dec 16 19:57:01 2010 -0800
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java	Mon Dec 20 21:10:57 2010 -0800
@@ -28,6 +28,7 @@
 import java.io.*;
 
 import com.sun.javadoc.*;
+import com.sun.tools.doclets.formats.html.markup.*;
 import com.sun.tools.doclets.internal.toolkit.*;
 
 /**
@@ -51,122 +52,102 @@
     }
 
     /**
-     * Write the annotation type member summary header for the given class.
-     *
-     * @param classDoc the class the summary belongs to.
+     * {@inheritDoc}
      */
-    public void writeMemberSummaryHeader(ClassDoc classDoc) {
-        writer.println("<!-- =========== ANNOTATION TYPE REQUIRED MEMBER SUMMARY =========== -->");
-        writer.println();
-        writer.printSummaryHeader(this, classDoc);
-    }
-
-    /**
-     * Write the annotation type member summary footer for the given class.
-     *
-     * @param classDoc the class the summary belongs to.
-     */
-    public void writeMemberSummaryFooter(ClassDoc classDoc) {
-        writer.printSummaryFooter(this, classDoc);
+    public Content getMemberSummaryHeader(ClassDoc classDoc,
+            Content memberSummaryTree) {
+        memberSummaryTree.addContent(
+                HtmlConstants.START_OF_ANNOTATION_TYPE_REQUIRED_MEMBER_SUMMARY);
+        Content memberTree = writer.getMemberTreeHeader();
+        writer.addSummaryHeader(this, classDoc, memberTree);
+        return memberTree;
     }
 
     /**
      * {@inheritDoc}
      */
-    public void writeInheritedMemberSummaryHeader(ClassDoc classDoc) {
-        //Not appliable.
+    public void addAnnotationDetailsTreeHeader(ClassDoc classDoc,
+            Content memberDetailsTree) {
+        if (!writer.printedAnnotationHeading) {
+            memberDetailsTree.addContent(writer.getMarkerAnchor(
+                    "annotation_type_element_detail"));
+            Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING,
+                    writer.annotationTypeDetailsLabel);
+            memberDetailsTree.addContent(heading);
+            writer.printedAnnotationHeading = true;
+        }
     }
 
     /**
      * {@inheritDoc}
      */
-    public void writeInheritedMemberSummary(ClassDoc classDoc,
-        ProgramElementDoc member, boolean isFirst, boolean isLast) {
-        //Not appliable.
+    public Content getAnnotationDocTreeHeader(MemberDoc member,
+            Content annotationDetailsTree) {
+        annotationDetailsTree.addContent(
+                writer.getMarkerAnchor(member.name() +
+                ((ExecutableMemberDoc) member).signature()));
+        Content annotationDocTree = writer.getMemberTreeHeader();
+        Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING);
+        heading.addContent(member.name());
+        annotationDocTree.addContent(heading);
+        return annotationDocTree;
     }
 
     /**
      * {@inheritDoc}
      */
-    public void writeInheritedMemberSummaryFooter(ClassDoc classDoc) {
-        //Not appliable.
+    public Content getSignature(MemberDoc member) {
+        Content pre = new HtmlTree(HtmlTag.PRE);
+        writer.addAnnotationInfo(member, pre);
+        addModifiers(member, pre);
+        Content link = new RawHtml(
+                writer.getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER,
+                getType(member))));
+        pre.addContent(link);
+        pre.addContent(writer.getSpace());
+        if (configuration().linksource) {
+            Content memberName = new StringContent(member.name());
+            writer.addSrcLink(member, memberName, pre);
+        } else {
+            addName(member.name(), pre);
+        }
+        return pre;
     }
 
     /**
      * {@inheritDoc}
      */
-    public void writeHeader(ClassDoc classDoc, String header) {
-        writer.println();
-        writer.println("<!-- ============ ANNOTATION TYPE MEMBER DETAIL =========== -->");
-        writer.println();
-        writer.anchor("annotation_type_element_detail");
-        writer.printTableHeadingBackground(header);
-        writer.println();
+    public void addDeprecated(MemberDoc member, Content annotationDocTree) {
+        addDeprecatedInfo(member, annotationDocTree);
     }
 
     /**
      * {@inheritDoc}
      */
-    public void writeMemberHeader(MemberDoc member, boolean isFirst) {
-        if (! isFirst) {
-            writer.printMemberHeader();
-            writer.println("");
-        }
-        writer.anchor(member.name() + ((ExecutableMemberDoc) member).signature());
-        writer.h3();
-        writer.print(member.name());
-        writer.h3End();
+    public void addComments(MemberDoc member, Content annotationDocTree) {
+        addComment(member, annotationDocTree);
     }
 
     /**
      * {@inheritDoc}
      */
-    public void writeSignature(MemberDoc member) {
-        writer.pre();
-        writer.writeAnnotationInfo(member);
-        printModifiers(member);
-        writer.printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER,
-            getType(member)));
-        print(' ');
-        if (configuration().linksource) {
-            writer.printSrcLink(member, member.name());
-        } else {
-            strong(member.name());
-        }
-        writer.preEnd();
-        assert !writer.getMemberDetailsListPrinted();
+    public void addTags(MemberDoc member, Content annotationDocTree) {
+        writer.addTagsInfo(member, annotationDocTree);
     }
 
     /**
      * {@inheritDoc}
      */
-    public void writeComments(MemberDoc member) {
-        printComment(member);
+    public Content getAnnotationDetails(Content annotationDetailsTree) {
+        return getMemberTree(annotationDetailsTree);
     }
 
     /**
-     * Write the tag output for the given member.
-     *
-     * @param member the member being documented.
+     * {@inheritDoc}
      */
-    public void writeTags(MemberDoc member) {
-        writer.printTags(member);
-    }
-
-    /**
-     * Write the annotation type member footer.
-     */
-    public void writeMemberFooter() {
-        printMemberFooter();
-    }
-
-    /**
-     * Write the footer for the annotation type member documentation.
-     *
-     * @param classDoc the class that the annotation type member belong to.
-     */
-    public void writeFooter(ClassDoc classDoc) {
-        //No footer to write for annotation type member documentation
+    public Content getAnnotationDoc(Content annotationDocTree,
+            boolean isLastContent) {
+        return getMemberTree(annotationDocTree, isLastContent);
     }
 
     /**
@@ -179,113 +160,120 @@
     /**
      * {@inheritDoc}
      */
-    public void printSummaryLabel() {
-        writer.printText("doclet.Annotation_Type_Required_Member_Summary");
+    public void addSummaryLabel(Content memberTree) {
+        Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
+                writer.getResource("doclet.Annotation_Type_Required_Member_Summary"));
+        memberTree.addContent(label);
     }
 
     /**
      * {@inheritDoc}
      */
-    public void printTableSummary() {
-        writer.tableIndexSummary(configuration().getText("doclet.Member_Table_Summary",
+    public String getTableSummary() {
+        return configuration().getText("doclet.Member_Table_Summary",
                 configuration().getText("doclet.Annotation_Type_Required_Member_Summary"),
-                configuration().getText("doclet.annotation_type_required_members")));
+                configuration().getText("doclet.annotation_type_required_members"));
     }
 
-    public void printSummaryTableHeader(ProgramElementDoc member) {
+    /**
+     * {@inheritDoc}
+     */
+    public String getCaption() {
+        return configuration().getText("doclet.Annotation_Type_Required_Members");
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String[] getSummaryTableHeader(ProgramElementDoc member) {
         String[] header = new String[] {
             writer.getModifierTypeHeader(),
             configuration().getText("doclet.0_and_1",
                     configuration().getText("doclet.Annotation_Type_Required_Member"),
                     configuration().getText("doclet.Description"))
         };
-        writer.summaryTableHeader(header, "col");
+        return header;
     }
 
     /**
      * {@inheritDoc}
      */
-    public void printSummaryAnchor(ClassDoc cd) {
-        writer.anchor("annotation_type_required_element_summary");
+    public void addSummaryAnchor(ClassDoc cd, Content memberTree) {
+        memberTree.addContent(writer.getMarkerAnchor(
+                "annotation_type_required_element_summary"));
     }
 
     /**
      * {@inheritDoc}
      */
-    public void printInheritedSummaryAnchor(ClassDoc cd) {
-    }   // no such
-
-    /**
-     * {@inheritDoc}
-     */
-    public void printInheritedSummaryLabel(ClassDoc cd) {
-        // no such
+    public void addInheritedSummaryAnchor(ClassDoc cd, Content inheritedTree) {
     }
 
     /**
      * {@inheritDoc}
      */
-    protected void writeSummaryLink(int context, ClassDoc cd, ProgramElementDoc member) {
-        writer.strong();
-        writer.printDocLink(context, (MemberDoc) member, member.name(), false);
-        writer.strongEnd();
+    public void addInheritedSummaryLabel(ClassDoc cd, Content inheritedTree) {
     }
 
     /**
      * {@inheritDoc}
      */
-    protected void writeInheritedSummaryLink(ClassDoc cd,
-            ProgramElementDoc member) {
+    protected void addSummaryLink(int context, ClassDoc cd, ProgramElementDoc member,
+            Content tdSummary) {
+        Content strong = HtmlTree.STRONG(new RawHtml(
+                writer.getDocLink(context, (MemberDoc) member, member.name(), false)));
+        Content code = HtmlTree.CODE(strong);
+        tdSummary.addContent(code);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    protected void addInheritedSummaryLink(ClassDoc cd,
+            ProgramElementDoc member, Content linksTree) {
         //Not applicable.
     }
 
     /**
      * {@inheritDoc}
      */
-    protected void printSummaryType(ProgramElementDoc member) {
+    protected void addSummaryType(ProgramElementDoc member, Content tdSummaryType) {
         MemberDoc m = (MemberDoc)member;
-        printModifierAndType(m, getType(m));
+        addModifierAndType(m, getType(m), tdSummaryType);
     }
 
     /**
      * {@inheritDoc}
      */
-    protected void writeDeprecatedLink(ProgramElementDoc member) {
-        writer.printDocLink(LinkInfoImpl.CONTEXT_MEMBER,
-            (MemberDoc) member, ((MemberDoc)member).qualifiedName(), false);
+    protected Content getDeprecatedLink(ProgramElementDoc member) {
+        return writer.getDocLink(LinkInfoImpl.CONTEXT_MEMBER,
+                (MemberDoc) member, ((MemberDoc)member).qualifiedName());
     }
 
     /**
      * {@inheritDoc}
      */
-    protected void printNavSummaryLink(ClassDoc cd, boolean link) {
+    protected Content getNavSummaryLink(ClassDoc cd, boolean link) {
         if (link) {
-            writer.printHyperLink("", "annotation_type_required_element_summary",
-                    configuration().getText("doclet.navAnnotationTypeRequiredMember"));
+            return writer.getHyperLink("", "annotation_type_required_element_summary",
+                    writer.getResource("doclet.navAnnotationTypeRequiredMember"));
         } else {
-            writer.printText("doclet.navAnnotationTypeRequiredMember");
+            return writer.getResource("doclet.navAnnotationTypeRequiredMember");
         }
     }
 
     /**
      * {@inheritDoc}
      */
-    protected void printNavDetailLink(boolean link) {
+    protected void addNavDetailLink(boolean link, Content liNav) {
         if (link) {
-            writer.printHyperLink("", "annotation_type_element_detail",
-                configuration().getText("doclet.navAnnotationTypeMember"));
+            liNav.addContent(writer.getHyperLink("", "annotation_type_element_detail",
+                    writer.getResource("doclet.navAnnotationTypeMember")));
         } else {
-            writer.printText("doclet.navAnnotationTypeMember");
+            liNav.addContent(writer.getResource("doclet.navAnnotationTypeMember"));
         }
     }
 
-    /**
-     * {@inheritDoc}
-     */
-    public void writeDeprecated(MemberDoc member) {
-        printDeprecated(member);
-    }
-
     private Type getType(MemberDoc member) {
         if (member instanceof FieldDoc) {
             return ((FieldDoc) member).type();
--- a/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeWriterImpl.java	Thu Dec 16 19:57:01 2010 -0800
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeWriterImpl.java	Mon Dec 20 21:10:57 2010 -0800
@@ -29,6 +29,7 @@
 import com.sun.tools.doclets.internal.toolkit.*;
 import com.sun.tools.doclets.internal.toolkit.util.*;
 import com.sun.tools.doclets.internal.toolkit.builders.*;
+import com.sun.tools.doclets.formats.html.markup.*;
 
 /**
  * Generate the Class Information Page.
@@ -40,6 +41,7 @@
  *
  * @author Atul M Dambalkar
  * @author Robert Field
+ * @author Bhavesh Patel (Modified)
  */
 public class AnnotationTypeWriterImpl extends SubWriterHolderWriter
         implements AnnotationTypeWriter {
@@ -69,126 +71,168 @@
     }
 
     /**
-     * Print this package link
+     * Get this package link.
+     *
+     * @return a content tree for the package link
      */
-    protected void navLinkPackage() {
-        navCellStart();
-        printHyperLink("package-summary.html", "",
-            configuration.getText("doclet.Package"), true, "NavBarFont1");
-        navCellEnd();
+    protected Content getNavLinkPackage() {
+        Content linkContent = getHyperLink("package-summary.html", "",
+                packageLabel);
+        Content li = HtmlTree.LI(linkContent);
+        return li;
     }
 
     /**
-     * Print class page indicator
+     * Get the class link.
+     *
+     * @return a content tree for the class link
      */
-    protected void navLinkClass() {
-        navCellRevStart();
-        fontStyle("NavBarFont1Rev");
-        strongText("doclet.Class");
-        fontEnd();
-        navCellEnd();
+    protected Content getNavLinkClass() {
+        Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, classLabel);
+        return li;
     }
 
     /**
-     * Print class use link
+     * Get the class use link.
+     *
+     * @return a content tree for the class use link
      */
-    protected void navLinkClassUse() {
-        navCellStart();
-        printHyperLink("class-use/" + filename, "",
-                       configuration.getText("doclet.navClassUse"), true, "NavBarFont1");
-        navCellEnd();
+    protected Content getNavLinkClassUse() {
+        Content linkContent = getHyperLink("class-use/" + filename, "", useLabel);
+        Content li = HtmlTree.LI(linkContent);
+        return li;
     }
 
     /**
-     * Print previous package link
+     * Get link to previous class.
+     *
+     * @return a content tree for the previous class link
      */
-    protected void navLinkPrevious() {
-        if (prev == null) {
-            printText("doclet.Prev_Class");
-        } else {
-            printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS,
-                prev.asClassDoc(), "",
-                configuration.getText("doclet.Prev_Class"), true));
+    public Content getNavLinkPrevious() {
+        Content li;
+        if (prev != null) {
+            Content prevLink = new RawHtml(getLink(new LinkInfoImpl(
+                    LinkInfoImpl.CONTEXT_CLASS, prev.asClassDoc(), "",
+                    configuration.getText("doclet.Prev_Class"), true)));
+            li = HtmlTree.LI(prevLink);
         }
+        else
+            li = HtmlTree.LI(prevclassLabel);
+        return li;
     }
 
     /**
-     * Print next package link
+     * Get link to next class.
+     *
+     * @return a content tree for the next class link
      */
-    protected void navLinkNext() {
-        if (next == null) {
-            printText("doclet.Next_Class");
-        } else {
-            printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS,
-                next.asClassDoc(), "",
-                configuration.getText("doclet.Next_Class"), true));
+    public Content getNavLinkNext() {
+        Content li;
+        if (next != null) {
+            Content nextLink = new RawHtml(getLink(new LinkInfoImpl(
+                    LinkInfoImpl.CONTEXT_CLASS, next.asClassDoc(), "",
+                    configuration.getText("doclet.Next_Class"), true)));
+            li = HtmlTree.LI(nextLink);
         }
+        else
+            li = HtmlTree.LI(nextclassLabel);
+        return li;
     }
 
     /**
      * {@inheritDoc}
      */
-    public void writeHeader(String header) {
-
+    public Content getHeader(String header) {
         String pkgname = (annotationType.containingPackage() != null)?
             annotationType.containingPackage().name(): "";
         String clname = annotationType.name();
-
-        printHtmlHeader(clname,
-            configuration.metakeywords.getMetaKeywords(annotationType), true);
-        printTop();
-        navLinks(true);
-        hr();
-        println("<!-- ======== START OF CLASS DATA ======== -->");
-        h2();
+        Content bodyTree = getBody(true, getWindowTitle(clname));
+        addTop(bodyTree);
+        addNavLinks(true, bodyTree);
+        bodyTree.addContent(HtmlConstants.START_OF_CLASS_DATA);
+        HtmlTree div = new HtmlTree(HtmlTag.DIV);
+        div.addStyle(HtmlStyle.header);
         if (pkgname.length() > 0) {
-            font("-1"); print(pkgname); fontEnd(); br();
+            Content pkgNameContent = new StringContent(pkgname);
+            Content pkgNamePara = HtmlTree.P(HtmlStyle.subTitle, pkgNameContent);
+            div.addContent(pkgNamePara);
         }
-        print(header + getTypeParameterLinks(new LinkInfoImpl(
-            LinkInfoImpl.CONTEXT_CLASS_HEADER,
-            annotationType, false)));
-        h2End();
+        LinkInfoImpl linkInfo = new LinkInfoImpl(
+                LinkInfoImpl.CONTEXT_CLASS_HEADER, annotationType, false);
+        Content headerContent = new StringContent(header);
+        Content heading = HtmlTree.HEADING(HtmlConstants.CLASS_PAGE_HEADING, true,
+                HtmlStyle.title, headerContent);
+        heading.addContent(new RawHtml(getTypeParameterLinks(linkInfo)));
+        div.addContent(heading);
+        bodyTree.addContent(div);
+        return bodyTree;
     }
 
     /**
      * {@inheritDoc}
      */
-    public void writeFooter() {
-        println("<!-- ========= END OF CLASS DATA ========= -->");
-        hr();
-        navLinks(false);
-        printBottom();
-        printBodyHtmlEnd();
+    public Content getAnnotationContentHeader() {
+        return getContentHeader();
     }
 
     /**
      * {@inheritDoc}
      */
-    public void writeAnnotationTypeSignature(String modifiers) {
-        preNoNewLine();
-        writeAnnotationInfo(annotationType);
-        print(modifiers);
-        String name = annotationType.name() +
-            getTypeParameterLinks(new LinkInfoImpl(
-                LinkInfoImpl.CONTEXT_CLASS_SIGNATURE, annotationType, false));
-        if (configuration().linksource) {
-            printSrcLink(annotationType, name);
-        } else {
-            strong(name);
-        }
-        preEnd();
-        p();
+    public void addFooter(Content contentTree) {
+        contentTree.addContent(HtmlConstants.END_OF_CLASS_DATA);
+        addNavLinks(false, contentTree);
+        addBottom(contentTree);
     }
 
     /**
      * {@inheritDoc}
      */
-    public void writeAnnotationTypeDescription() {
+    public void printDocument(Content contentTree) {
+        printHtmlDocument(configuration.metakeywords.getMetaKeywords(annotationType),
+                true, contentTree);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Content getAnnotationInfoTreeHeader() {
+        return getMemberTreeHeader();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Content getAnnotationInfo(Content annotationInfoTree) {
+        return getMemberTree(HtmlStyle.description, annotationInfoTree);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void addAnnotationTypeSignature(String modifiers, Content annotationInfoTree) {
+        annotationInfoTree.addContent(new HtmlTree(HtmlTag.BR));
+        Content pre = new HtmlTree(HtmlTag.PRE);
+        addAnnotationInfo(annotationType, pre);
+        pre.addContent(modifiers);
+        LinkInfoImpl linkInfo = new LinkInfoImpl(
+                LinkInfoImpl.CONTEXT_CLASS_SIGNATURE, annotationType, false);
+        Content name = new RawHtml (annotationType.name() +
+                getTypeParameterLinks(linkInfo));
+        if (configuration().linksource) {
+            addSrcLink(annotationType, name, pre);
+        } else {
+            pre.addContent(HtmlTree.STRONG(name));
+        }
+        annotationInfoTree.addContent(pre);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void addAnnotationTypeDescription(Content annotationInfoTree) {
         if(!configuration.nocomment) {
-            // generate documentation for the class.
             if (annotationType.inlineTags().length > 0) {
-                printInlineComment(annotationType);
-                p();
+                addInlineComment(annotationType, annotationInfoTree);
             }
         }
     }
@@ -196,148 +240,152 @@
     /**
      * {@inheritDoc}
      */
-    public void writeAnnotationTypeTagInfo() {
-        boolean needHr = annotationType.elements().length > 0;
+    public void addAnnotationTypeTagInfo(Content annotationInfoTree) {
         if(!configuration.nocomment) {
-            // Print Information about all the tags here
-            printTags(annotationType);
-            if (needHr) {
-                hr();
-            }
-            p();
-        } else if (needHr) {
-            hr();
+            addTagsInfo(annotationType, annotationInfoTree);
         }
     }
 
     /**
      * {@inheritDoc}
      */
-    public void writeAnnotationTypeDeprecationInfo() {
-        hr();
+    public void addAnnotationTypeDeprecationInfo(Content annotationInfoTree) {
+        Content hr = new HtmlTree(HtmlTag.HR);
+        annotationInfoTree.addContent(hr);
         Tag[] deprs = annotationType.tags("deprecated");
         if (Util.isDeprecated(annotationType)) {
-            strongText("doclet.Deprecated");
+            Content strong = HtmlTree.STRONG(deprecatedPhrase);
+            Content div = HtmlTree.DIV(HtmlStyle.block, strong);
             if (deprs.length > 0) {
                 Tag[] commentTags = deprs[0].inlineTags();
                 if (commentTags.length > 0) {
-
-                    space();
-                    printInlineDeprecatedComment(annotationType, deprs[0]);
+                    div.addContent(getSpace());
+                    addInlineDeprecatedComment(annotationType, deprs[0], div);
                 }
             }
-            p();
+            annotationInfoTree.addContent(div);
         }
     }
 
-    protected void navLinkTree() {
-        navCellStart();
-        printHyperLink("package-tree.html", "",
-            configuration.getText("doclet.Tree"), true, "NavBarFont1");
-        navCellEnd();
+    /**
+     * {@inheritDoc}
+     */
+    public void addAnnotationDetailsMarker(Content memberDetails) {
+        memberDetails.addContent(HtmlConstants.START_OF_ANNOTATION_TYPE_DETAILS);
     }
 
-    protected void printSummaryDetailLinks() {
+    /**
+     * {@inheritDoc}
+     */
+    protected Content getNavLinkTree() {
+        Content treeLinkContent = getHyperLink("package-tree.html",
+                "", treeLabel, "", "");
+        Content li = HtmlTree.LI(treeLinkContent);
+        return li;
+    }
+
+    /**
+     * Add summary details to the navigation bar.
+     *
+     * @param subDiv the content tree to which the summary detail links will be added
+     */
+    protected void addSummaryDetailLinks(Content subDiv) {
         try {
-            tr();
-            tdVAlignClass("top", "NavBarCell3");
-            font("-2");
-            print("  ");
-            navSummaryLinks();
-            fontEnd();
-            tdEnd();
-
-            tdVAlignClass("top", "NavBarCell3");
-            font("-2");
-            navDetailLinks();
-            fontEnd();
-            tdEnd();
-            trEnd();
+            Content div = HtmlTree.DIV(getNavSummaryLinks());
+            div.addContent(getNavDetailLinks());
+            subDiv.addContent(div);
         } catch (Exception e) {
             e.printStackTrace();
             throw new DocletAbortException();
         }
     }
 
-    protected void navSummaryLinks() throws Exception {
-        printText("doclet.Summary");
-        space();
+    /**
+     * Get summary links for navigation bar.
+     *
+     * @return the content tree for the navigation summary links
+     */
+    protected Content getNavSummaryLinks() throws Exception {
+        Content li = HtmlTree.LI(summaryLabel);
+        li.addContent(getSpace());
+        Content ulNav = HtmlTree.UL(HtmlStyle.subNavList, li);
         MemberSummaryBuilder memberSummaryBuilder = (MemberSummaryBuilder)
-            configuration.getBuilderFactory().getMemberSummaryBuilder(this);
-        writeNavSummaryLink(memberSummaryBuilder,
-            "doclet.navAnnotationTypeRequiredMember",
-            VisibleMemberMap.ANNOTATION_TYPE_MEMBER_REQUIRED);
-        navGap();
-        writeNavSummaryLink(memberSummaryBuilder,
-            "doclet.navAnnotationTypeOptionalMember",
-            VisibleMemberMap.ANNOTATION_TYPE_MEMBER_OPTIONAL);
+                configuration.getBuilderFactory().getMemberSummaryBuilder(this);
+        Content liNavReq = new HtmlTree(HtmlTag.LI);
+        addNavSummaryLink(memberSummaryBuilder,
+                "doclet.navAnnotationTypeRequiredMember",
+                VisibleMemberMap.ANNOTATION_TYPE_MEMBER_REQUIRED, liNavReq);
+        addNavGap(liNavReq);
+        ulNav.addContent(liNavReq);
+        Content liNavOpt = new HtmlTree(HtmlTag.LI);
+        addNavSummaryLink(memberSummaryBuilder,
+                "doclet.navAnnotationTypeOptionalMember",
+                VisibleMemberMap.ANNOTATION_TYPE_MEMBER_OPTIONAL, liNavOpt);
+        ulNav.addContent(liNavOpt);
+        return ulNav;
     }
 
-    private void writeNavSummaryLink(MemberSummaryBuilder builder,
-            String label, int type) {
+    /**
+     * Add the navigation summary link.
+     *
+     * @param builder builder for the member to be documented
+     * @param label the label for the navigation
+     * @param type type to be documented
+     * @param liNav the content tree to which the navigation summary link will be added
+     */
+    protected void addNavSummaryLink(MemberSummaryBuilder builder,
+            String label, int type, Content liNav) {
         AbstractMemberWriter writer = ((AbstractMemberWriter) builder.
-            getMemberSummaryWriter(type));
+                getMemberSummaryWriter(type));
         if (writer == null) {
-              printText(label);
+            liNav.addContent(getResource(label));
         } else {
-            writer.printNavSummaryLink(null,
-                ! builder.getVisibleMemberMap(type).noVisibleMembers());
+            liNav.addContent(writer.getNavSummaryLink(null,
+                    ! builder.getVisibleMemberMap(type).noVisibleMembers()));
         }
     }
 
     /**
-     * Method navDetailLinks
+     * Get detail links for the navigation bar.
      *
-     * @throws   Exception
-     *
+     * @return the content tree for the detail links
      */
-    protected void navDetailLinks() throws Exception {
-        printText("doclet.Detail");
-        space();
+    protected Content getNavDetailLinks() throws Exception {
+        Content li = HtmlTree.LI(detailLabel);
+        li.addContent(getSpace());
+        Content ulNav = HtmlTree.UL(HtmlStyle.subNavList, li);
         MemberSummaryBuilder memberSummaryBuilder = (MemberSummaryBuilder)
-            configuration.getBuilderFactory().getMemberSummaryBuilder(this);
+                configuration.getBuilderFactory().getMemberSummaryBuilder(this);
         AbstractMemberWriter writerOptional =
-            ((AbstractMemberWriter) memberSummaryBuilder.
+                ((AbstractMemberWriter) memberSummaryBuilder.
                 getMemberSummaryWriter(VisibleMemberMap.ANNOTATION_TYPE_MEMBER_OPTIONAL));
         AbstractMemberWriter writerRequired =
-            ((AbstractMemberWriter) memberSummaryBuilder.
+                ((AbstractMemberWriter) memberSummaryBuilder.
                 getMemberSummaryWriter(VisibleMemberMap.ANNOTATION_TYPE_MEMBER_REQUIRED));
         if (writerOptional != null){
-            writerOptional.printNavDetailLink(annotationType.elements().length > 0);
+            Content liNavOpt = new HtmlTree(HtmlTag.LI);
+            writerOptional.addNavDetailLink(annotationType.elements().length > 0, liNavOpt);
+            ulNav.addContent(liNavOpt);
         } else if (writerRequired != null){
-            writerRequired.printNavDetailLink(annotationType.elements().length > 0);
+            Content liNavReq = new HtmlTree(HtmlTag.LI);
+            writerRequired.addNavDetailLink(annotationType.elements().length > 0, liNavReq);
+            ulNav.addContent(liNavReq);
         } else {
-            printText("doclet.navAnnotationTypeMember");
+            Content liNav = HtmlTree.LI(getResource("doclet.navAnnotationTypeMember"));
+            ulNav.addContent(liNav);
         }
-    }
-
-    protected void navGap() {
-        space();
-        print('|');
-        space();
+        return ulNav;
     }
 
     /**
-     * If this is an inner class or interface, write the enclosing class or
-     * interface.
+     * Add gap between navigation bar elements.
+     *
+     * @param liNav the content tree to which the gap will be added
      */
-    public void writeNestedClassInfo() {
-        ClassDoc outerClass = annotationType.containingClass();
-        if (outerClass != null) {
-            dl();
-            dt();
-            if (annotationType.isInterface()) {
-                strongText("doclet.Enclosing_Interface");
-            } else {
-                strongText("doclet.Enclosing_Class");
-            }
-            dtEnd();
-            dd();
-            printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS, outerClass,
-                false));
-            ddEnd();
-            dlEnd();
-        }
+    protected void addNavGap(Content liNav) {
+        liNav.addContent(getSpace());
+        liNav.addContent("|");
+        liNav.addContent(getSpace());
     }
 
     /**
@@ -346,11 +394,4 @@
     public AnnotationTypeDoc getAnnotationTypeDoc() {
         return annotationType;
     }
-
-    /**
-     * {@inheritDoc}
-     */
-    public void completeMemberSummaryBuild() {
-        p();
-    }
 }
--- a/src/share/classes/com/sun/tools/doclets/formats/html/ClassUseWriter.java	Thu Dec 16 19:57:01 2010 -0800
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/ClassUseWriter.java	Mon Dec 20 21:10:57 2010 -0800
@@ -25,10 +25,12 @@
 
 package com.sun.tools.doclets.formats.html;
 
-import com.sun.tools.doclets.internal.toolkit.util.*;
-import com.sun.javadoc.*;
 import java.io.*;
 import java.util.*;
+import com.sun.javadoc.*;
+import com.sun.tools.doclets.internal.toolkit.util.*;
+import com.sun.tools.doclets.formats.html.markup.*;
+import com.sun.tools.doclets.internal.toolkit.*;
 
 /**
  * Generate class usage information.
@@ -207,257 +209,301 @@
     }
 
     /**
-     * Print the class use list.
+     * Generate the class use list.
      */
     protected void generateClassUseFile() throws IOException {
-
-        printClassUseHeader();
-
+        Content body = getClassUseHeader();
+        HtmlTree div = new HtmlTree(HtmlTag.DIV);
+        div.addStyle(HtmlStyle.classUseContainer);
         if (pkgSet.size() > 0) {
-            generateClassUse();
+            addClassUse(div);
         } else {
-            printText("doclet.ClassUse_No.usage.of.0",
-                      classdoc.qualifiedName());
-            p();
+            div.addContent(getResource("doclet.ClassUse_No.usage.of.0",
+                    classdoc.qualifiedName()));
         }
-
-        printClassUseFooter();
-    }
-
-    protected void generateClassUse() throws IOException {
-        if (configuration.packages.length > 1) {
-            generatePackageList();
-            generatePackageAnnotationList();
-        }
-        generateClassList();
-    }
-
-    protected void generatePackageList() throws IOException {
-        tableIndexSummary(useTableSummary);
-        tableCaptionStart();
-        printText("doclet.ClassUse_Packages.that.use.0",
-            getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS_USE_HEADER, classdoc,
-                false)));
-        tableCaptionEnd();
-        summaryTableHeader(packageTableHeader, "col");
-
-        for (Iterator<PackageDoc> it = pkgSet.iterator(); it.hasNext();) {
-            PackageDoc pkg = it.next();
-            generatePackageUse(pkg);
-        }
-        tableEnd();
-        space();
-        p();
-    }
-
-    protected void generatePackageAnnotationList() throws IOException {
-        if ((! classdoc.isAnnotationType()) ||
-               pkgToPackageAnnotations == null ||
-               pkgToPackageAnnotations.size() == 0)
-            return;
-        tableIndexSummary(useTableSummary);
-        tableCaptionStart();
-        printText("doclet.ClassUse_PackageAnnotation",
-            getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS_USE_HEADER, classdoc,
-                false)));
-        tableCaptionEnd();
-        summaryTableHeader(packageTableHeader, "col");
-        for (Iterator<PackageDoc> it = pkgToPackageAnnotations.iterator(); it.hasNext();) {
-            PackageDoc pkg = it.next();
-            trBgcolorStyle("white", "TableRowColor");
-            summaryRow(0);
-            //Just want an anchor here.
-            printPackageLink(pkg, pkg.name(), true);
-            summaryRowEnd();
-            summaryRow(0);
-            printSummaryComment(pkg);
-            space();
-            summaryRowEnd();
-            trEnd();
-        }
-        tableEnd();
-        space();
-        p();
-    }
-
-    protected void generateClassList() throws IOException {
-        for (Iterator<PackageDoc> it = pkgSet.iterator(); it.hasNext();) {
-            PackageDoc pkg = it.next();
-            anchor(pkg.name());
-            tableIndexSummary();
-            tableHeaderStart("#CCCCFF");
-            printText("doclet.ClassUse_Uses.of.0.in.1",
-                getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS_USE_HEADER,
-                    classdoc, false)),
-                getPackageLink(pkg, Util.getPackageName(pkg), false));
-            tableHeaderEnd();
-            tableEnd();
-            space();
-            p();
-            generateClassUse(pkg);
-        }
+        body.addContent(div);
+        addNavLinks(false, body);
+        addBottom(body);
+        printHtmlDocument(null, true, body);
     }
 
     /**
-     * Print the package use list.
+     * Add the class use documentation.
+     *
+     * @param contentTree the content tree to which the class use information will be added
      */
-    protected void generatePackageUse(PackageDoc pkg) throws IOException {
-        trBgcolorStyle("white", "TableRowColor");
-        summaryRow(0);
-        //Just want an anchor here.
-        printHyperLink("", pkg.name(), Util.getPackageName(pkg), true);
-        summaryRowEnd();
-        summaryRow(0);
-        printSummaryComment(pkg);
-        space();
-        summaryRowEnd();
-        trEnd();
+    protected void addClassUse(Content contentTree) throws IOException {
+        HtmlTree ul = new HtmlTree(HtmlTag.UL);
+        ul.addStyle(HtmlStyle.blockList);
+        if (configuration.packages.length > 1) {
+            addPackageList(ul);
+            addPackageAnnotationList(ul);
+        }
+        addClassList(ul);
+        contentTree.addContent(ul);
     }
 
     /**
-     * Print the class use list.
+     * Add the packages list that use the given class.
+     *
+     * @param contentTree the content tree to which the packages list will be added
      */
-    protected void generateClassUse(PackageDoc pkg) throws IOException {
-        String classLink = getLink(new LinkInfoImpl(
-            LinkInfoImpl.CONTEXT_CLASS_USE_HEADER, classdoc, false));
-        String pkgLink = getPackageLink(pkg, Util.getPackageName(pkg), false);
-        classSubWriter.printUseInfo(pkgToClassAnnotations.get(pkg.name()),
-                configuration.getText("doclet.ClassUse_Annotation", classLink,
-                pkgLink), classUseTableSummary);
-        classSubWriter.printUseInfo(pkgToClassTypeParameter.get(pkg.name()),
-                configuration.getText("doclet.ClassUse_TypeParameter", classLink,
-                pkgLink), classUseTableSummary);
-        classSubWriter.printUseInfo(pkgToSubclass.get(pkg.name()),
-                configuration.getText("doclet.ClassUse_Subclass", classLink,
-                pkgLink), subclassUseTableSummary);
-        classSubWriter.printUseInfo(pkgToSubinterface.get(pkg.name()),
-                configuration.getText("doclet.ClassUse_Subinterface", classLink,
-                pkgLink), subinterfaceUseTableSummary);
-        classSubWriter.printUseInfo(pkgToImplementingClass.get(pkg.name()),
-                configuration.getText("doclet.ClassUse_ImplementingClass", classLink,
-                pkgLink), classUseTableSummary);
-        fieldSubWriter.printUseInfo(pkgToField.get(pkg.name()),
-                configuration.getText("doclet.ClassUse_Field", classLink,
-                pkgLink), fieldUseTableSummary);
-        fieldSubWriter.printUseInfo(pkgToFieldAnnotations.get(pkg.name()),
-                configuration.getText("doclet.ClassUse_FieldAnnotations", classLink,
-                pkgLink), fieldUseTableSummary);
-        fieldSubWriter.printUseInfo(pkgToFieldTypeParameter.get(pkg.name()),
-                configuration.getText("doclet.ClassUse_FieldTypeParameter", classLink,
-                pkgLink), fieldUseTableSummary);
-        methodSubWriter.printUseInfo(pkgToMethodAnnotations.get(pkg.name()),
-                configuration.getText("doclet.ClassUse_MethodAnnotations", classLink,
-                pkgLink), methodUseTableSummary);
-        methodSubWriter.printUseInfo(pkgToMethodParameterAnnotations.get(pkg.name()),
-                configuration.getText("doclet.ClassUse_MethodParameterAnnotations", classLink,
-                pkgLink), methodUseTableSummary);
-        methodSubWriter.printUseInfo(pkgToMethodTypeParameter.get(pkg.name()),
-                configuration.getText("doclet.ClassUse_MethodTypeParameter", classLink,
-                pkgLink), methodUseTableSummary);
-        methodSubWriter.printUseInfo(pkgToMethodReturn.get(pkg.name()),
-                configuration.getText("doclet.ClassUse_MethodReturn", classLink,
-                pkgLink), methodUseTableSummary);
-        methodSubWriter.printUseInfo(pkgToMethodReturnTypeParameter.get(pkg.name()),
-                configuration.getText("doclet.ClassUse_MethodReturnTypeParameter", classLink,
-                pkgLink), methodUseTableSummary);
-        methodSubWriter.printUseInfo(pkgToMethodArgs.get(pkg.name()),
-                configuration.getText("doclet.ClassUse_MethodArgs", classLink,
-                pkgLink), methodUseTableSummary);
-        methodSubWriter.printUseInfo(pkgToMethodArgTypeParameter.get(pkg.name()),
-                configuration.getText("doclet.ClassUse_MethodArgsTypeParameters", classLink,
-                pkgLink), methodUseTableSummary);
-        methodSubWriter.printUseInfo(pkgToMethodThrows.get(pkg.name()),
-                configuration.getText("doclet.ClassUse_MethodThrows", classLink,
-                pkgLink), methodUseTableSummary);
-        constrSubWriter.printUseInfo(pkgToConstructorAnnotations.get(pkg.name()),
-                configuration.getText("doclet.ClassUse_ConstructorAnnotations", classLink,
-                pkgLink), constructorUseTableSummary);
-        constrSubWriter.printUseInfo(pkgToConstructorParameterAnnotations.get(pkg.name()),
-                configuration.getText("doclet.ClassUse_ConstructorParameterAnnotations", classLink,
-                pkgLink), constructorUseTableSummary);
-        constrSubWriter.printUseInfo(pkgToConstructorArgs.get(pkg.name()),
-                configuration.getText("doclet.ClassUse_ConstructorArgs", classLink,
-                pkgLink), constructorUseTableSummary);
-        constrSubWriter.printUseInfo(pkgToConstructorArgTypeParameter.get(pkg.name()),
-                configuration.getText("doclet.ClassUse_ConstructorArgsTypeParameters", classLink,
-                pkgLink), constructorUseTableSummary);
-        constrSubWriter.printUseInfo(pkgToConstructorThrows.get(pkg.name()),
-                configuration.getText("doclet.ClassUse_ConstructorThrows", classLink,
-                pkgLink), constructorUseTableSummary);
+    protected void addPackageList(Content contentTree) throws IOException {
+        Content table = HtmlTree.TABLE(0, 3, 0, useTableSummary,
+                getTableCaption(configuration().getText(
+                "doclet.ClassUse_Packages.that.use.0",
+                getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS_USE_HEADER, classdoc,
+                false)))));
+        table.addContent(getSummaryTableHeader(packageTableHeader, "col"));
+        Content tbody = new HtmlTree(HtmlTag.TBODY);
+        Iterator<PackageDoc> it = pkgSet.iterator();
+        for (int i = 0; it.hasNext(); i++) {
+            PackageDoc pkg = it.next();
+            HtmlTree tr = new HtmlTree(HtmlTag.TR);
+            if (i % 2 == 0) {
+                tr.addStyle(HtmlStyle.altColor);
+            } else {
+                tr.addStyle(HtmlStyle.rowColor);
+            }
+            addPackageUse(pkg, tr);
+            tbody.addContent(tr);
+        }
+        table.addContent(tbody);
+        Content li = HtmlTree.LI(HtmlStyle.blockList, table);
+        contentTree.addContent(li);
     }
 
     /**
-     * Print the header for the class use Listing.
+     * Add the package annotation list.
+     *
+     * @param contentTree the content tree to which the package annotation list will be added
      */
-    protected void printClassUseHeader() {
-        String cltype = configuration.getText(classdoc.isInterface()?
-                                    "doclet.Interface":
-                                    "doclet.Class");
-        String clname = classdoc.qualifiedName();
-        printHtmlHeader(configuration.getText("doclet.Window_ClassUse_Header",
-                            cltype, clname), null, true);
-        printTop();
-        navLinks(true);
-        hr();
-        center();
-        h2();
-        strongText("doclet.ClassUse_Title", cltype, clname);
-        h2End();
-        centerEnd();
+    protected void addPackageAnnotationList(Content contentTree) throws IOException {
+        if ((!classdoc.isAnnotationType()) ||
+                pkgToPackageAnnotations == null ||
+                pkgToPackageAnnotations.size() == 0) {
+            return;
+        }
+        Content table = HtmlTree.TABLE(0, 3, 0, useTableSummary,
+                getTableCaption(configuration().getText(
+                "doclet.ClassUse_PackageAnnotation",
+                getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS_USE_HEADER, classdoc,
+                false)))));
+        table.addContent(getSummaryTableHeader(packageTableHeader, "col"));
+        Content tbody = new HtmlTree(HtmlTag.TBODY);
+        Iterator<PackageDoc> it = pkgToPackageAnnotations.iterator();
+        for (int i = 0; it.hasNext(); i++) {
+            PackageDoc pkg = it.next();
+            HtmlTree tr = new HtmlTree(HtmlTag.TR);
+            if (i % 2 == 0) {
+                tr.addStyle(HtmlStyle.altColor);
+            } else {
+                tr.addStyle(HtmlStyle.rowColor);
+            }
+            Content tdFirst = HtmlTree.TD(HtmlStyle.colFirst,
+                    getPackageLink(pkg, new StringContent(pkg.name())));
+            tr.addContent(tdFirst);
+            HtmlTree tdLast = new HtmlTree(HtmlTag.TD);
+            tdLast.addStyle(HtmlStyle.colLast);
+            if (pkg != null) {
+                addSummaryComment(pkg, tdLast);
+            } else {
+                tdLast.addContent(getSpace());
+            }
+            tr.addContent(tdLast);
+            tbody.addContent(tr);
+        }
+        table.addContent(tbody);
+        Content li = HtmlTree.LI(HtmlStyle.blockList, table);
+        contentTree.addContent(li);
     }
 
     /**
-     * Print the footer for the class use Listing.
+     * Add the class list that use the given class.
+     *
+     * @param contentTree the content tree to which the class list will be added
      */
-    protected void printClassUseFooter() {
-        hr();
-        navLinks(false);
-        printBottom();
-        printBodyHtmlEnd();
-    }
-
-
-    /**
-     * Print this package link
-     */
-    protected void navLinkPackage() {
-        navCellStart();
-        printHyperLink("../package-summary.html", "",
-                       configuration.getText("doclet.Package"), true, "NavBarFont1");
-        navCellEnd();
+    protected void addClassList(Content contentTree) throws IOException {
+        HtmlTree ul = new HtmlTree(HtmlTag.UL);
+        ul.addStyle(HtmlStyle.blockList);
+        for (Iterator<PackageDoc> it = pkgSet.iterator(); it.hasNext();) {
+            PackageDoc pkg = it.next();
+            Content li = HtmlTree.LI(HtmlStyle.blockList, getMarkerAnchor(pkg.name()));
+            Content link = new RawHtml(
+                    configuration.getText("doclet.ClassUse_Uses.of.0.in.1",
+                    getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS_USE_HEADER,
+                    classdoc, false)),
+                    getPackageLinkString(pkg, Util.getPackageName(pkg), false)));
+            Content heading = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING, link);
+            li.addContent(heading);
+            addClassUse(pkg, li);
+            ul.addContent(li);
+        }
+        Content li = HtmlTree.LI(HtmlStyle.blockList, ul);
+        contentTree.addContent(li);
     }
 
     /**
-     * Print class page indicator
+     * Add the package use information.
+     *
+     * @param pkg the package that uses the given class
+     * @param contentTree the content tree to which the package use information will be added
      */
-    protected void navLinkClass() {
-        navCellStart();
-        printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS_USE_HEADER, classdoc, "",
-            configuration.getText("doclet.Class"), true, "NavBarFont1"));
-        navCellEnd();
+    protected void addPackageUse(PackageDoc pkg, Content contentTree) throws IOException {
+        Content tdFirst = HtmlTree.TD(HtmlStyle.colFirst,
+                getHyperLink("", pkg.name(), new StringContent(Util.getPackageName(pkg))));
+        contentTree.addContent(tdFirst);
+        HtmlTree tdLast = new HtmlTree(HtmlTag.TD);
+        tdLast.addStyle(HtmlStyle.colLast);
+        if (pkg != null)
+            addSummaryComment(pkg, tdLast);
+        else
+            tdLast.addContent(getSpace());
+        contentTree.addContent(tdLast);
     }
 
     /**
-     * Print class use link
+     * Add the class use information.
+     *
+     * @param pkg the package that uses the given class
+     * @param contentTree the content tree to which the class use information will be added
      */
-    protected void navLinkClassUse() {
-        navCellRevStart();
-        fontStyle("NavBarFont1Rev");
-        strongText("doclet.navClassUse");
-        fontEnd();
-        navCellEnd();
+    protected void addClassUse(PackageDoc pkg, Content contentTree) throws IOException {
+        String classLink = getLink(new LinkInfoImpl(
+            LinkInfoImpl.CONTEXT_CLASS_USE_HEADER, classdoc, false));
+        String pkgLink = getPackageLinkString(pkg, Util.getPackageName(pkg), false);
+        classSubWriter.addUseInfo(pkgToClassAnnotations.get(pkg.name()),
+                configuration.getText("doclet.ClassUse_Annotation", classLink,
+                pkgLink), classUseTableSummary, contentTree);
+        classSubWriter.addUseInfo(pkgToClassTypeParameter.get(pkg.name()),
+                configuration.getText("doclet.ClassUse_TypeParameter", classLink,
+                pkgLink), classUseTableSummary, contentTree);
+        classSubWriter.addUseInfo(pkgToSubclass.get(pkg.name()),
+                configuration.getText("doclet.ClassUse_Subclass", classLink,
+                pkgLink), subclassUseTableSummary, contentTree);
+        classSubWriter.addUseInfo(pkgToSubinterface.get(pkg.name()),
+                configuration.getText("doclet.ClassUse_Subinterface", classLink,
+                pkgLink), subinterfaceUseTableSummary, contentTree);
+        classSubWriter.addUseInfo(pkgToImplementingClass.get(pkg.name()),
+                configuration.getText("doclet.ClassUse_ImplementingClass", classLink,
+                pkgLink), classUseTableSummary, contentTree);
+        fieldSubWriter.addUseInfo(pkgToField.get(pkg.name()),
+                configuration.getText("doclet.ClassUse_Field", classLink,
+                pkgLink), fieldUseTableSummary, contentTree);
+        fieldSubWriter.addUseInfo(pkgToFieldAnnotations.get(pkg.name()),
+                configuration.getText("doclet.ClassUse_FieldAnnotations", classLink,
+                pkgLink), fieldUseTableSummary, contentTree);
+        fieldSubWriter.addUseInfo(pkgToFieldTypeParameter.get(pkg.name()),
+                configuration.getText("doclet.ClassUse_FieldTypeParameter", classLink,
+                pkgLink), fieldUseTableSummary, contentTree);
+        methodSubWriter.addUseInfo(pkgToMethodAnnotations.get(pkg.name()),
+                configuration.getText("doclet.ClassUse_MethodAnnotations", classLink,
+                pkgLink), methodUseTableSummary, contentTree);
+        methodSubWriter.addUseInfo(pkgToMethodParameterAnnotations.get(pkg.name()),
+                configuration.getText("doclet.ClassUse_MethodParameterAnnotations", classLink,
+                pkgLink), methodUseTableSummary, contentTree);
+        methodSubWriter.addUseInfo(pkgToMethodTypeParameter.get(pkg.name()),
+                configuration.getText("doclet.ClassUse_MethodTypeParameter", classLink,
+                pkgLink), methodUseTableSummary, contentTree);
+        methodSubWriter.addUseInfo(pkgToMethodReturn.get(pkg.name()),
+                configuration.getText("doclet.ClassUse_MethodReturn", classLink,
+                pkgLink), methodUseTableSummary, contentTree);
+        methodSubWriter.addUseInfo(pkgToMethodReturnTypeParameter.get(pkg.name()),
+                configuration.getText("doclet.ClassUse_MethodReturnTypeParameter", classLink,
+                pkgLink), methodUseTableSummary, contentTree);
+        methodSubWriter.addUseInfo(pkgToMethodArgs.get(pkg.name()),
+                configuration.getText("doclet.ClassUse_MethodArgs", classLink,
+                pkgLink), methodUseTableSummary, contentTree);
+        methodSubWriter.addUseInfo(pkgToMethodArgTypeParameter.get(pkg.name()),
+                configuration.getText("doclet.ClassUse_MethodArgsTypeParameters", classLink,
+                pkgLink), methodUseTableSummary, contentTree);
+        methodSubWriter.addUseInfo(pkgToMethodThrows.get(pkg.name()),
+                configuration.getText("doclet.ClassUse_MethodThrows", classLink,
+                pkgLink), methodUseTableSummary, contentTree);
+        constrSubWriter.addUseInfo(pkgToConstructorAnnotations.get(pkg.name()),
+                configuration.getText("doclet.ClassUse_ConstructorAnnotations", classLink,
+                pkgLink), constructorUseTableSummary, contentTree);
+        constrSubWriter.addUseInfo(pkgToConstructorParameterAnnotations.get(pkg.name()),
+                configuration.getText("doclet.ClassUse_ConstructorParameterAnnotations", classLink,
+                pkgLink), constructorUseTableSummary, contentTree);
+        constrSubWriter.addUseInfo(pkgToConstructorArgs.get(pkg.name()),
+                configuration.getText("doclet.ClassUse_ConstructorArgs", classLink,
+                pkgLink), constructorUseTableSummary, contentTree);
+        constrSubWriter.addUseInfo(pkgToConstructorArgTypeParameter.get(pkg.name()),
+                configuration.getText("doclet.ClassUse_ConstructorArgsTypeParameters", classLink,
+                pkgLink), constructorUseTableSummary, contentTree);
+        constrSubWriter.addUseInfo(pkgToConstructorThrows.get(pkg.name()),
+                configuration.getText("doclet.ClassUse_ConstructorThrows", classLink,
+                pkgLink), constructorUseTableSummary, contentTree);
     }
 
-    protected void navLinkTree() {
-        navCellStart();
-        if (classdoc.containingPackage().isIncluded()) {
-            printHyperLink("../package-tree.html", "",
-                configuration.getText("doclet.Tree"), true, "NavBarFont1");
-        } else {
-            printHyperLink(relativePath + "overview-tree.html", "",
-                configuration.getText("doclet.Tree"), true, "NavBarFont1");
-        }
-        navCellEnd();
+    /**
+     * Get the header for the class use Listing.
+     *
+     * @return a content tree representing the class use header
+     */
+    protected Content getClassUseHeader() {
+        String cltype = configuration.getText(classdoc.isInterface()?
+            "doclet.Interface":"doclet.Class");
+        String clname = classdoc.qualifiedName();
+        String title = configuration.getText("doclet.Window_ClassUse_Header",
+                cltype, clname);
+        Content bodyTree = getBody(true, getWindowTitle(title));
+        addTop(bodyTree);
+        addNavLinks(true, bodyTree);
+        Content headContent = getResource("doclet.ClassUse_Title", cltype, clname);
+        Content heading = HtmlTree.HEADING(HtmlConstants.CLASS_PAGE_HEADING,
+                true, HtmlStyle.title, headContent);
+        Content div = HtmlTree.DIV(HtmlStyle.header, heading);
+        bodyTree.addContent(div);
+        return bodyTree;
     }
 
+    /**
+     * Get this package link.
+     *
+     * @return a content tree for the package link
+     */
+    protected Content getNavLinkPackage() {
+        Content linkContent = getHyperLink("../package-summary.html", "",
+                packageLabel);
+        Content li = HtmlTree.LI(linkContent);
+        return li;
+    }
+
+    /**
+     * Get class page link.
+     *
+     * @return a content tree for the class page link
+     */
+    protected Content getNavLinkClass() {
+        Content linkContent = new RawHtml(getLink(new LinkInfoImpl(
+                LinkInfoImpl.CONTEXT_CLASS_USE_HEADER, classdoc, "",
+                configuration.getText("doclet.Class"), false)));
+        Content li = HtmlTree.LI(linkContent);
+        return li;
+    }
+
+    /**
+     * Get the use link.
+     *
+     * @return a content tree for the use link
+     */
+    protected Content getNavLinkClassUse() {
+        Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, useLabel);
+        return li;
+    }
+
+    /**
+     * Get the tree link.
+     *
+     * @return a content tree for the tree link
+     */
+    protected Content getNavLinkTree() {
+        Content linkContent = classdoc.containingPackage().isIncluded() ?
+            getHyperLink("../package-tree.html", "", treeLabel) :
+            getHyperLink(relativePath + "overview-tree.html", "", treeLabel);
+        Content li = HtmlTree.LI(linkContent);
+        return li;
+    }
 }
--- a/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java	Thu Dec 16 19:57:01 2010 -0800
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java	Mon Dec 20 21:10:57 2010 -0800
@@ -32,6 +32,7 @@
 import com.sun.tools.doclets.internal.toolkit.util.*;
 import com.sun.tools.doclets.internal.toolkit.builders.*;
 import com.sun.tools.doclets.internal.toolkit.taglets.*;
+import com.sun.tools.doclets.formats.html.markup.*;
 
 /**
  * Generate the Class Information Page.
@@ -43,6 +44,7 @@
  *
  * @author Atul M Dambalkar
  * @author Robert Field
+ * @author Bhavesh Patel (Modified)
  */
 public class ClassWriterImpl extends SubWriterHolderWriter
         implements ClassWriter {
@@ -76,124 +78,173 @@
     }
 
     /**
-     * Print this package link
+     * Get this package link.
+     *
+     * @return a content tree for the package link
      */
-    protected void navLinkPackage() {
-        navCellStart();
-        printHyperLink("package-summary.html", "",
-            configuration.getText("doclet.Package"), true, "NavBarFont1");
-        navCellEnd();
+    protected Content getNavLinkPackage() {
+        Content linkContent = getHyperLink("package-summary.html", "",
+                packageLabel);
+        Content li = HtmlTree.LI(linkContent);
+        return li;
     }
 
     /**
-     * Print class page indicator
+     * Get the class link.
+     *
+     * @return a content tree for the class link
      */
-    protected void navLinkClass() {
-        navCellRevStart();
-        fontStyle("NavBarFont1Rev");
-        strongText("doclet.Class");
-        fontEnd();
-        navCellEnd();
+    protected Content getNavLinkClass() {
+        Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, classLabel);
+        return li;
     }
 
     /**
-     * Print class use link
+     * Get the class use link.
+     *
+     * @return a content tree for the class use link
      */
-    protected void navLinkClassUse() {
-        navCellStart();
-        printHyperLink("class-use/" + filename, "",
-                       configuration.getText("doclet.navClassUse"), true, "NavBarFont1");
-        navCellEnd();
+    protected Content getNavLinkClassUse() {
+        Content linkContent = getHyperLink("class-use/" + filename, "", useLabel);
+        Content li = HtmlTree.LI(linkContent);
+        return li;
     }
 
     /**
-     * Print previous package link
+     * Get link to previous class.
+     *
+     * @return a content tree for the previous class link
      */
-    protected void navLinkPrevious() {
-        if (prev == null) {
-            printText("doclet.Prev_Class");
-        } else {
-            printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS, prev, "",
-                configuration.getText("doclet.Prev_Class"), true));
+    public Content getNavLinkPrevious() {
+        Content li;
+        if (prev != null) {
+            Content prevLink = new RawHtml(getLink(new LinkInfoImpl(
+                    LinkInfoImpl.CONTEXT_CLASS, prev, "",
+                    configuration.getText("doclet.Prev_Class"), true)));
+            li = HtmlTree.LI(prevLink);
         }
+        else
+            li = HtmlTree.LI(prevclassLabel);
+        return li;
     }
 
     /**
-     * Print next package link
+     * Get link to next class.
+     *
+     * @return a content tree for the next class link
      */
-    protected void navLinkNext() {
-        if (next == null) {
-            printText("doclet.Next_Class");
-        } else {
-            printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS, next, "",
-                configuration.getText("doclet.Next_Class"), true));
+    public Content getNavLinkNext() {
+        Content li;
+        if (next != null) {
+            Content nextLink = new RawHtml(getLink(new LinkInfoImpl(
+                    LinkInfoImpl.CONTEXT_CLASS, next, "",
+                    configuration.getText("doclet.Next_Class"), true)));
+            li = HtmlTree.LI(nextLink);
         }
+        else
+            li = HtmlTree.LI(nextclassLabel);
+        return li;
     }
 
     /**
      * {@inheritDoc}
      */
-    public void writeHeader(String header) {
+    public Content getHeader(String header) {
         String pkgname = (classDoc.containingPackage() != null)?
             classDoc.containingPackage().name(): "";
         String clname = classDoc.name();
-        printHtmlHeader(clname,
-            configuration.metakeywords.getMetaKeywords(classDoc), true);
-        printTop();
-        navLinks(true);
-        hr();
-        println("<!-- ======== START OF CLASS DATA ======== -->");
-        h2();
+        Content bodyTree = getBody(true, getWindowTitle(clname));
+        addTop(bodyTree);
+        addNavLinks(true, bodyTree);
+        bodyTree.addContent(HtmlConstants.START_OF_CLASS_DATA);
+        HtmlTree div = new HtmlTree(HtmlTag.DIV);
+        div.addStyle(HtmlStyle.header);
         if (pkgname.length() > 0) {
-            font("-1"); print(pkgname); fontEnd(); br();
+            Content pkgNameContent = new StringContent(pkgname);
+            Content pkgNamePara = HtmlTree.P(HtmlStyle.subTitle, pkgNameContent);
+            div.addContent(pkgNamePara);
         }
         LinkInfoImpl linkInfo = new LinkInfoImpl( LinkInfoImpl.CONTEXT_CLASS_HEADER,
-            classDoc, false);
+                classDoc, false);
         //Let's not link to ourselves in the header.
         linkInfo.linkToSelf = false;
-        print(header + getTypeParameterLinks(linkInfo));
-        h2End();
+        Content headerContent = new StringContent(header);
+        Content heading = HtmlTree.HEADING(HtmlConstants.CLASS_PAGE_HEADING, true,
+                HtmlStyle.title, headerContent);
+        heading.addContent(new RawHtml(getTypeParameterLinks(linkInfo)));
+        div.addContent(heading);
+        bodyTree.addContent(div);
+        return bodyTree;
     }
 
     /**
      * {@inheritDoc}
      */
-    public void writeFooter() {
-        println("<!-- ========= END OF CLASS DATA ========= -->");
-        hr();
-        navLinks(false);
-        printBottom();
-        printBodyHtmlEnd();
+    public Content getClassContentHeader() {
+        return getContentHeader();
     }
 
     /**
      * {@inheritDoc}
      */
-    public void writeClassSignature(String modifiers) {
+    public void addFooter(Content contentTree) {
+        contentTree.addContent(HtmlConstants.END_OF_CLASS_DATA);
+        addNavLinks(false, contentTree);
+        addBottom(contentTree);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void printDocument(Content contentTree) {
+        printHtmlDocument(configuration.metakeywords.getMetaKeywords(classDoc),
+                true, contentTree);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Content getClassInfoTreeHeader() {
+        return getMemberTreeHeader();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Content getClassInfo(Content classInfoTree) {
+        return getMemberTree(HtmlStyle.description, classInfoTree);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void addClassSignature(String modifiers, Content classInfoTree) {
         boolean isInterface = classDoc.isInterface();
-        preNoNewLine();
-        writeAnnotationInfo(classDoc);
-        print(modifiers);
+        classInfoTree.addContent(new HtmlTree(HtmlTag.BR));
+        Content pre = new HtmlTree(HtmlTag.PRE);
+        addAnnotationInfo(classDoc, pre);
+        pre.addContent(modifiers);
         LinkInfoImpl linkInfo = new LinkInfoImpl(
-            LinkInfoImpl.CONTEXT_CLASS_SIGNATURE, classDoc, false);
+                LinkInfoImpl.CONTEXT_CLASS_SIGNATURE, classDoc, false);
         //Let's not link to ourselves in the signature.
         linkInfo.linkToSelf = false;
-        String name = classDoc.name() +
-            getTypeParameterLinks(linkInfo);
+        Content name = new RawHtml (classDoc.name() +
+                getTypeParameterLinks(linkInfo));
         if (configuration().linksource) {
-            printSrcLink(classDoc, name);
+            addSrcLink(classDoc, name, pre);
         } else {
-            strong(name);
+            pre.addContent(HtmlTree.STRONG(name));
         }
         if (!isInterface) {
             Type superclass = Util.getFirstVisibleSuperClass(classDoc,
-                configuration());
+                    configuration());
             if (superclass != null) {
-                println();
-                print("extends ");
-                printLink(new LinkInfoImpl(
-                    LinkInfoImpl.CONTEXT_CLASS_SIGNATURE_PARENT_NAME,
-                    superclass));
+                pre.addContent(DocletConstants.NL);
+                pre.addContent("extends ");
+                Content link = new RawHtml(getLink(new LinkInfoImpl(
+                        LinkInfoImpl.CONTEXT_CLASS_SIGNATURE_PARENT_NAME,
+                        superclass)));
+                pre.addContent(link);
             }
         }
         Type[] implIntfacs = classDoc.interfaceTypes();
@@ -202,34 +253,33 @@
             for (int i = 0; i < implIntfacs.length; i++) {
                 ClassDoc classDoc = implIntfacs[i].asClassDoc();
                 if (! (classDoc.isPublic() ||
-                    Util.isLinkable(classDoc, configuration()))) {
+                        Util.isLinkable(classDoc, configuration()))) {
                     continue;
                 }
                 if (counter == 0) {
-                    println();
-                    print(isInterface? "extends " : "implements ");
+                    pre.addContent(DocletConstants.NL);
+                    pre.addContent(isInterface? "extends " : "implements ");
                 } else {
-                    print(", ");
+                    pre.addContent(", ");
                 }
-                printLink(new LinkInfoImpl(
-                    LinkInfoImpl.CONTEXT_CLASS_SIGNATURE_PARENT_NAME,
-                    implIntfacs[i]));
+                Content link = new RawHtml(getLink(new LinkInfoImpl(
+                        LinkInfoImpl.CONTEXT_CLASS_SIGNATURE_PARENT_NAME,
+                        implIntfacs[i])));
+                pre.addContent(link);
                 counter++;
             }
         }
-        preEnd();
-        p();
+        classInfoTree.addContent(pre);
     }
 
     /**
      * {@inheritDoc}
      */
-    public void writeClassDescription() {
+    public void addClassDescription(Content classInfoTree) {
         if(!configuration.nocomment) {
             // generate documentation for the class.
             if (classDoc.inlineTags().length > 0) {
-                printInlineComment(classDoc);
-                p();
+                addInlineComment(classDoc, classInfoTree);
             }
         }
     }
@@ -237,131 +287,118 @@
     /**
      * {@inheritDoc}
      */
-    public void writeClassTagInfo() {
+    public void addClassTagInfo(Content classInfoTree) {
         if(!configuration.nocomment) {
             // Print Information about all the tags here
-            printTags(classDoc);
-            hr();
-            p();
+            addTagsInfo(classDoc, classInfoTree);
+        }
+    }
+
+    /**
+     * Get the class hierarchy tree for the given class.
+     *
+     * @param type the class to print the hierarchy for
+     * @return a content tree for class inheritence
+     */
+    private Content getClassInheritenceTree(Type type) {
+        Type sup;
+        HtmlTree classTreeUl = new HtmlTree(HtmlTag.UL);
+        classTreeUl.addStyle(HtmlStyle.inheritance);
+        Content liTree = null;
+        do {
+            sup = Util.getFirstVisibleSuperClass(
+                    type instanceof ClassDoc ? (ClassDoc) type : type.asClassDoc(),
+                    configuration());
+            if (sup != null) {
+                HtmlTree ul = new HtmlTree(HtmlTag.UL);
+                ul.addStyle(HtmlStyle.inheritance);
+                ul.addContent(getTreeForClassHelper(type));
+                if (liTree != null)
+                    ul.addContent(liTree);
+                Content li = HtmlTree.LI(ul);
+                liTree = li;
+                type = sup;
+            }
+            else
+                classTreeUl.addContent(getTreeForClassHelper(type));
+        }
+        while (sup != null);
+        if (liTree != null)
+            classTreeUl.addContent(liTree);
+        return classTreeUl;
+    }
+
+    /**
+     * Get the class helper tree for the given class.
+     *
+     * @param type the class to print the helper for
+     * @return a content tree for class helper
+     */
+    private Content getTreeForClassHelper(Type type) {
+        Content li = new HtmlTree(HtmlTag.LI);
+        if (type.equals(classDoc)) {
+            String typeParameters = getTypeParameterLinks(
+                    new LinkInfoImpl(LinkInfoImpl.CONTEXT_TREE,
+                    classDoc, false));
+            if (configuration.shouldExcludeQualifier(
+                    classDoc.containingPackage().name())) {
+                li.addContent(type.asClassDoc().name());
+                li.addContent(new RawHtml(typeParameters));
+            } else {
+                li.addContent(type.asClassDoc().qualifiedName());
+                li.addContent(new RawHtml(typeParameters));
+            }
         } else {
-            hr();
+            Content link = new RawHtml(getLink(new LinkInfoImpl(
+                    LinkInfoImpl.CONTEXT_CLASS_TREE_PARENT,
+                    type instanceof ClassDoc ? (ClassDoc) type : type,
+                    configuration.getClassName(type.asClassDoc()), false)));
+            li.addContent(link);
+        }
+        return li;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void addClassTree(Content classContentTree) {
+        if (!classDoc.isClass()) {
+            return;
+        }
+        classContentTree.addContent(getClassInheritenceTree(classDoc));
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void addTypeParamInfo(Content classInfoTree) {
+        if (classDoc.typeParamTags().length > 0) {
+            TagletOutput output = (new ParamTaglet()).getTagletOutput(classDoc,
+                    getTagletWriterInstance(false));
+            Content typeParam = new RawHtml(output.toString());
+            Content dl = HtmlTree.DL(typeParam);
+            classInfoTree.addContent(dl);
         }
     }
 
     /**
      * {@inheritDoc}
      */
-    public void writeClassDeprecationInfo() {
-        hr();
-        Tag[] deprs = classDoc.tags("deprecated");
-        if (Util.isDeprecated(classDoc)) {
-            strongText("doclet.Deprecated");
-            if (deprs.length > 0) {
-                Tag[] commentTags = deprs[0].inlineTags();
-                if (commentTags.length > 0) {
-                    space();
-                    printInlineDeprecatedComment(classDoc, deprs[0]);
-                }
-            }
-            p();
-        }
-    }
-
-    /**
-     * Generate the indent and get the line image for the class tree.
-     * For user accessibility, the image includes the alt attribute
-     * "extended by".  (This method is not intended for a class
-     * implementing an interface, where "implemented by" would be required.)
-     *
-     * indent  integer indicating the number of spaces to indent
-     */
-    private void writeStep(int indent) {
-        print(spaces(4 * indent - 2));
-        print("<IMG SRC=\"" + relativepathNoSlash + "/resources/inherit.gif\" " +
-              "ALT=\"" + configuration.getText("doclet.extended_by") + " \">");
-    }
-
-    /**
-     * Print the class hierarchy tree for the given class.
-     * @param type the class to print the hierarchy for.
-     * @return return the amount that should be indented in
-     * the next level of the tree.
-     */
-    private int writeTreeForClassHelper(Type type) {
-        Type sup = Util.getFirstVisibleSuperClass(
-            type instanceof ClassDoc ? (ClassDoc) type : type.asClassDoc(),
-            configuration());
-        int indent = 0;
-        if (sup != null) {
-            indent = writeTreeForClassHelper(sup);
-            writeStep(indent);
-        }
-
-        if (type.equals(classDoc)) {
-            String typeParameters = getTypeParameterLinks(
-                new LinkInfoImpl(
-                    LinkInfoImpl.CONTEXT_TREE,
-                    classDoc, false));
-            if (configuration.shouldExcludeQualifier(
-                    classDoc.containingPackage().name())) {
-                strong(type.asClassDoc().name() + typeParameters);
-            } else {
-                strong(type.asClassDoc().qualifiedName() + typeParameters);
-            }
-        } else {
-            print(getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS_TREE_PARENT,
-                    type instanceof ClassDoc ? (ClassDoc) type : type,
-                    configuration.getClassName(type.asClassDoc()), false)));
-        }
-        println();
-        return indent + 1;
-    }
-
-    /**
-     * Print the class hierarchy tree for this class only.
-     */
-    public void writeClassTree() {
-        if (! classDoc.isClass()) {
-            return;
-        }
-        pre();
-        writeTreeForClassHelper(classDoc);
-        preEnd();
-    }
-
-    /**
-     * Write the type parameter information.
-     */
-    public void writeTypeParamInfo() {
-        if (classDoc.typeParamTags().length > 0) {
-            dl();
-            dt();
-            TagletOutput output = (new ParamTaglet()).getTagletOutput(classDoc,
-                getTagletWriterInstance(false));
-            print(output.toString());
-            dtEnd();
-            dlEnd();
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public void writeSubClassInfo() {
+    public void addSubClassInfo(Content classInfoTree) {
         if (classDoc.isClass()) {
             if (classDoc.qualifiedName().equals("java.lang.Object") ||
-                classDoc.qualifiedName().equals("org.omg.CORBA.Object")) {
+                    classDoc.qualifiedName().equals("org.omg.CORBA.Object")) {
                 return;    // Don't generate the list, too huge
             }
             List<ClassDoc> subclasses = classtree.subs(classDoc, false);
             if (subclasses.size() > 0) {
-                dl();
-                dt();
-                strongText("doclet.Subclasses");
-                dtEnd();
-                writeClassLinks(LinkInfoImpl.CONTEXT_SUBCLASSES,
-                    subclasses);
-                dlEnd();
+                Content label = getResource(
+                        "doclet.Subclasses");
+                Content dt = HtmlTree.DT(label);
+                Content dl = HtmlTree.DL(dt);
+                dl.addContent(getClassLinks(LinkInfoImpl.CONTEXT_SUBCLASSES,
+                        subclasses));
+                classInfoTree.addContent(dl);
             }
         }
     }
@@ -369,140 +406,196 @@
     /**
      * {@inheritDoc}
      */
-    public void writeSubInterfacesInfo() {
+    public void addSubInterfacesInfo(Content classInfoTree) {
         if (classDoc.isInterface()) {
             List<ClassDoc> subInterfaces = classtree.allSubs(classDoc, false);
             if (subInterfaces.size() > 0) {
-                dl();
-                dt();
-                strongText("doclet.Subinterfaces");
-                dtEnd();
-                writeClassLinks(LinkInfoImpl.CONTEXT_SUBINTERFACES,
-                    subInterfaces);
-                dlEnd();
+                Content label = getResource(
+                        "doclet.Subinterfaces");
+                Content dt = HtmlTree.DT(label);
+                Content dl = HtmlTree.DL(dt);
+                dl.addContent(getClassLinks(LinkInfoImpl.CONTEXT_SUBINTERFACES,
+                        subInterfaces));
+                classInfoTree.addContent(dl);
             }
         }
     }
 
     /**
-     * If this is the interface which are the classes, that implement this?
-     */
-    public void writeInterfaceUsageInfo () {
-        if (! classDoc.isInterface()) {
-            return;
-        }
-        if (classDoc.qualifiedName().equals("java.lang.Cloneable") ||
-            classDoc.qualifiedName().equals("java.io.Serializable")) {
-            return;   // Don't generate the list, too big
-        }
-        List<ClassDoc> implcl = classtree.implementingclasses(classDoc);
-        if (implcl.size() > 0) {
-            dl();
-            dt();
-            strongText("doclet.Implementing_Classes");
-            dtEnd();
-            writeClassLinks(LinkInfoImpl.CONTEXT_IMPLEMENTED_CLASSES,
-                implcl);
-            dlEnd();
-        }
-    }
-
-    /**
      * {@inheritDoc}
      */
-    public void writeImplementedInterfacesInfo() {
-        //NOTE:  we really should be using ClassDoc.interfaceTypes() here, but
-        //       it doesn't walk up the tree like we want it to.
-        List<Type> interfaceArray = Util.getAllInterfaces(classDoc, configuration);
-        if (classDoc.isClass() && interfaceArray.size() > 0) {
-            dl();
-            dt();
-            strongText("doclet.All_Implemented_Interfaces");
-            dtEnd();
-            writeClassLinks(LinkInfoImpl.CONTEXT_IMPLEMENTED_INTERFACES,
-                interfaceArray);
-            dlEnd();
+    public void addInterfaceUsageInfo (Content classInfoTree) {
+        if (! classDoc.isInterface()) {
+            return;
+        }
+        if (classDoc.qualifiedName().equals("java.lang.Cloneable") ||
+                classDoc.qualifiedName().equals("java.io.Serializable")) {
+            return;   // Don't generate the list, too big
+        }
+        List<ClassDoc> implcl = classtree.implementingclasses(classDoc);
+        if (implcl.size() > 0) {
+            Content label = getResource(
+                    "doclet.Implementing_Classes");
+            Content dt = HtmlTree.DT(label);
+            Content dl = HtmlTree.DL(dt);
+            dl.addContent(getClassLinks(LinkInfoImpl.CONTEXT_IMPLEMENTED_CLASSES,
+                    implcl));
+            classInfoTree.addContent(dl);
         }
     }
 
     /**
      * {@inheritDoc}
      */
-    public void writeSuperInterfacesInfo() {
+    public void addImplementedInterfacesInfo(Content classInfoTree) {
+        //NOTE:  we really should be using ClassDoc.interfaceTypes() here, but
+        //       it doesn't walk up the tree like we want it to.
+        List<Type> interfaceArray = Util.getAllInterfaces(classDoc, configuration);
+        if (classDoc.isClass() && interfaceArray.size() > 0) {
+            Content label = getResource(
+                    "doclet.All_Implemented_Interfaces");
+            Content dt = HtmlTree.DT(label);
+            Content dl = HtmlTree.DL(dt);
+            dl.addContent(getClassLinks(LinkInfoImpl.CONTEXT_IMPLEMENTED_INTERFACES,
+                    interfaceArray));
+            classInfoTree.addContent(dl);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void addSuperInterfacesInfo(Content classInfoTree) {
         //NOTE:  we really should be using ClassDoc.interfaceTypes() here, but
         //       it doesn't walk up the tree like we want it to.
         List<Type> interfaceArray = Util.getAllInterfaces(classDoc, configuration);
         if (classDoc.isInterface() && interfaceArray.size() > 0) {
-            dl();
-            dt();
-            strongText("doclet.All_Superinterfaces");
-            dtEnd();
-            writeClassLinks(LinkInfoImpl.CONTEXT_SUPER_INTERFACES,
-                interfaceArray);
-            dlEnd();
+            Content label = getResource(
+                    "doclet.All_Superinterfaces");
+            Content dt = HtmlTree.DT(label);
+            Content dl = HtmlTree.DL(dt);
+            dl.addContent(getClassLinks(LinkInfoImpl.CONTEXT_SUPER_INTERFACES,
+                    interfaceArray));
+            classInfoTree.addContent(dl);
         }
     }
 
     /**
-     * Generate links to the given classes.
+     * {@inheritDoc}
      */
-    private void writeClassLinks(int context, List<?> list) {
+    public void addNestedClassInfo(Content classInfoTree) {
+        ClassDoc outerClass = classDoc.containingClass();
+        if (outerClass != null) {
+            Content label;
+            if (outerClass.isInterface()) {
+                label = getResource(
+                        "doclet.Enclosing_Interface");
+            } else {
+                label = getResource(
+                        "doclet.Enclosing_Class");
+            }
+            Content dt = HtmlTree.DT(label);
+            Content dl = HtmlTree.DL(dt);
+            Content dd = new HtmlTree(HtmlTag.DD);
+            dd.addContent(new RawHtml(getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS, outerClass,
+                    false))));
+            dl.addContent(dd);
+            classInfoTree.addContent(dl);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void addClassDeprecationInfo(Content classInfoTree) {
+        Content hr = new HtmlTree(HtmlTag.HR);
+        classInfoTree.addContent(hr);
+        Tag[] deprs = classDoc.tags("deprecated");
+        if (Util.isDeprecated(classDoc)) {
+            Content strong = HtmlTree.STRONG(deprecatedPhrase);
+            Content div = HtmlTree.DIV(HtmlStyle.block, strong);
+            if (deprs.length > 0) {
+                Tag[] commentTags = deprs[0].inlineTags();
+                if (commentTags.length > 0) {
+                    div.addContent(getSpace());
+                    addInlineDeprecatedComment(classDoc, deprs[0], div);
+                }
+            }
+            classInfoTree.addContent(div);
+        }
+    }
+
+    /**
+     * Get links to the given classes.
+     *
+     * @param context the id of the context where the link will be printed
+     * @param list the list of classes
+     * @return a content tree for the class list
+     */
+    private Content getClassLinks(int context, List<?> list) {
         Object[] typeList = list.toArray();
-        //Sort the list to be printed.
-        print(' ');
-        dd();
+        Content dd = new HtmlTree(HtmlTag.DD);
         for (int i = 0; i < list.size(); i++) {
             if (i > 0) {
-                print(", ");
+                Content separator = new StringContent(", ");
+                dd.addContent(separator);
             }
             if (typeList[i] instanceof ClassDoc) {
-                printLink(new LinkInfoImpl(context, (ClassDoc)(typeList[i])));
-
+                Content link = new RawHtml(getLink(
+                        new LinkInfoImpl(context, (ClassDoc)(typeList[i]))));
+                dd.addContent(link);
             } else {
-                printLink(new LinkInfoImpl(context, (Type)(typeList[i])));
+                Content link = new RawHtml(getLink(
+                        new LinkInfoImpl(context, (Type)(typeList[i]))));
+                dd.addContent(link);
             }
         }
-        ddEnd();
+        return dd;
     }
 
-    protected void navLinkTree() {
-        navCellStart();
-        printHyperLink("package-tree.html", "",
-            configuration.getText("doclet.Tree"), true, "NavBarFont1");
-        navCellEnd();
+    /**
+     * {@inheritDoc}
+     */
+    protected Content getNavLinkTree() {
+        Content treeLinkContent = getHyperLink("package-tree.html",
+                "", treeLabel, "", "");
+        Content li = HtmlTree.LI(treeLinkContent);
+        return li;
     }
 
-    protected void printSummaryDetailLinks() {
+    /**
+     * Add summary details to the navigation bar.
+     *
+     * @param subDiv the content tree to which the summary detail links will be added
+     */
+    protected void addSummaryDetailLinks(Content subDiv) {
         try {
-            tr();
-            tdVAlignClass("top", "NavBarCell3");
-            font("-2");
-            print("  ");
-            navSummaryLinks();
-            fontEnd();
-            tdEnd();
-            tdVAlignClass("top", "NavBarCell3");
-            font("-2");
-            navDetailLinks();
-            fontEnd();
-            tdEnd();
-            trEnd();
+            Content div = HtmlTree.DIV(getNavSummaryLinks());
+            div.addContent(getNavDetailLinks());
+            subDiv.addContent(div);
         } catch (Exception e) {
             e.printStackTrace();
             throw new DocletAbortException();
         }
     }
 
-    protected void navSummaryLinks() throws Exception {
-        printText("doclet.Summary");
-        space();
+    /**
+     * Get summary links for navigation bar.
+     *
+     * @return the content tree for the navigation summary links
+     */
+    protected Content getNavSummaryLinks() throws Exception {
+        Content li = HtmlTree.LI(summaryLabel);
+        li.addContent(getSpace());
+        Content ulNav = HtmlTree.UL(HtmlStyle.subNavList, li);
         MemberSummaryBuilder memberSummaryBuilder = (MemberSummaryBuilder)
-            configuration.getBuilderFactory().getMemberSummaryBuilder(this);
+                configuration.getBuilderFactory().getMemberSummaryBuilder(this);
         String[] navLinkLabels =  new String[] {
             "doclet.navNested", "doclet.navEnum", "doclet.navField", "doclet.navConstructor",
-                "doclet.navMethod"
+            "doclet.navMethod"
         };
         for (int i = 0; i < navLinkLabels.length; i++ ) {
+            Content liNav = new HtmlTree(HtmlTag.LI);
             if (i == VisibleMemberMap.ENUM_CONSTANTS && ! classDoc.isEnum()) {
                 continue;
             }
@@ -511,38 +604,41 @@
             }
             AbstractMemberWriter writer =
                 ((AbstractMemberWriter) memberSummaryBuilder.
-                    getMemberSummaryWriter(i));
+                getMemberSummaryWriter(i));
             if (writer == null) {
-                printText(navLinkLabels[i]);
+                liNav.addContent(getResource(navLinkLabels[i]));
             } else {
-                writer.navSummaryLink(
-                    memberSummaryBuilder.members(i),
-                    memberSummaryBuilder.getVisibleMemberMap(i));
+                writer.addNavSummaryLink(
+                        memberSummaryBuilder.members(i),
+                        memberSummaryBuilder.getVisibleMemberMap(i), liNav);
             }
             if (i < navLinkLabels.length-1) {
-                navGap();
+                addNavGap(liNav);
             }
+            ulNav.addContent(liNav);
         }
+        return ulNav;
     }
 
     /**
-     * Method navDetailLinks
+     * Get detail links for the navigation bar.
      *
-     * @throws   Exception
-     *
+     * @return the content tree for the detail links
      */
-    protected void navDetailLinks() throws Exception {
-        printText("doclet.Detail");
-        space();
+    protected Content getNavDetailLinks() throws Exception {
+        Content li = HtmlTree.LI(detailLabel);
+        li.addContent(getSpace());
+        Content ulNav = HtmlTree.UL(HtmlStyle.subNavList, li);
         MemberSummaryBuilder memberSummaryBuilder = (MemberSummaryBuilder)
-            configuration.getBuilderFactory().getMemberSummaryBuilder(this);
+                configuration.getBuilderFactory().getMemberSummaryBuilder(this);
         String[] navLinkLabels =  new String[] {
             "doclet.navNested", "doclet.navEnum", "doclet.navField", "doclet.navConstructor",
-                "doclet.navMethod"
+            "doclet.navMethod"
         };
         for (int i = 1; i < navLinkLabels.length; i++ ) {
+            Content liNav = new HtmlTree(HtmlTag.LI);
             AbstractMemberWriter writer =
-                ((AbstractMemberWriter) memberSummaryBuilder.
+                    ((AbstractMemberWriter) memberSummaryBuilder.
                     getMemberSummaryWriter(i));
             if (i == VisibleMemberMap.ENUM_CONSTANTS && ! classDoc.isEnum()) {
                 continue;
@@ -551,43 +647,27 @@
                 continue;
             }
             if (writer == null) {
-                printText(navLinkLabels[i]);
+                liNav.addContent(getResource(navLinkLabels[i]));
             } else {
-                writer.navDetailLink(memberSummaryBuilder.members(i));
+                writer.addNavDetailLink(memberSummaryBuilder.members(i), liNav);
             }
             if (i < navLinkLabels.length - 1) {
-                navGap();
+                addNavGap(liNav);
             }
+            ulNav.addContent(liNav);
         }
-    }
-
-    protected void navGap() {
-        space();
-        print('|');
-        space();
+        return ulNav;
     }
 
     /**
-     * If this is an inner class or interface, write the enclosing class or
-     * interface.
+     * Add gap between navigation bar elements.
+     *
+     * @param liNav the content tree to which the gap will be added
      */
-    public void writeNestedClassInfo() {
-        ClassDoc outerClass = classDoc.containingClass();
-        if (outerClass != null) {
-            dl();
-            dt();
-            if (outerClass.isInterface()) {
-                strongText("doclet.Enclosing_Interface");
-            } else {
-                strongText("doclet.Enclosing_Class");
-            }
-            dtEnd();
-            dd();
-            printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS, outerClass,
-                false));
-            ddEnd();
-            dlEnd();
-        }
+    protected void addNavGap(Content liNav) {
+        liNav.addContent(getSpace());
+        liNav.addContent("|");
+        liNav.addContent(getSpace());
     }
 
     /**
@@ -598,11 +678,4 @@
     public ClassDoc getClassDoc() {
         return classDoc;
     }
-
-    /**
-     * {@inheritDoc}
-     */
-    public void completeMemberSummaryBuild() {
-        p();
-    }
 }
--- a/src/share/classes/com/sun/tools/doclets/formats/html/ConstantsSummaryWriterImpl.java	Thu Dec 16 19:57:01 2010 -0800
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/ConstantsSummaryWriterImpl.java	Mon Dec 20 21:10:57 2010 -0800
@@ -25,11 +25,12 @@
 
 package com.sun.tools.doclets.formats.html;
 
+import java.io.*;
+import java.util.*;
+import com.sun.javadoc.*;
 import com.sun.tools.doclets.internal.toolkit.*;
 import com.sun.tools.doclets.internal.toolkit.util.*;
-import com.sun.javadoc.*;
-import java.io.*;
-import java.util.*;
+import com.sun.tools.doclets.formats.html.markup.*;
 
 /**
  * Write the Constants Summary Page in HTML format.
@@ -76,67 +77,106 @@
     /**
      * {@inheritDoc}
      */
-    public void writeHeader() {
-        printHtmlHeader(configuration.getText("doclet.Constants_Summary"),
-            null, true);
-        printTop();
-        navLinks(true);
-        hr();
-
-        center();
-        h1(); printText("doclet.Constants_Summary"); h1End();
-        centerEnd();
-
-        hr(4, "noshade");
+    public Content getHeader() {
+        String label = configuration.getText("doclet.Constants_Summary");
+        Content bodyTree = getBody(true, getWindowTitle(label));
+        addTop(bodyTree);
+        addNavLinks(true, bodyTree);
+        return bodyTree;
     }
 
     /**
      * {@inheritDoc}
      */
-    public void writeFooter() {
-        hr();
-        navLinks(false);
-        printBottom();
-        printBodyHtmlEnd();
+    public Content getContentsHeader() {
+        return new HtmlTree(HtmlTag.UL);
     }
 
     /**
      * {@inheritDoc}
      */
-    public void writeContentsHeader() {
-        strong(configuration.getText("doclet.Contents"));
-        ul();
+    public void addLinkToPackageContent(PackageDoc pkg, String parsedPackageName,
+            Set<String> printedPackageHeaders, Content contentListTree) {
+        String packageName = pkg.name();
+        //add link to summary
+        Content link;
+        if (packageName.length() == 0) {
+            link = getHyperLink("#" + DocletConstants.UNNAMED_PACKAGE_ANCHOR,
+                    "", defaultPackageLabel, "", "");
+        } else {
+            Content packageNameContent = getPackageLabel(parsedPackageName);
+            packageNameContent.addContent(".*");
+            link = getHyperLink("#" + parsedPackageName,
+                    "", packageNameContent, "", "");
+            printedPackageHeaders.add(parsedPackageName);
+        }
+        contentListTree.addContent(HtmlTree.LI(link));
     }
 
     /**
      * {@inheritDoc}
      */
-    public void writeContentsFooter() {
-        ulEnd();
-        println();
+    public Content getContentsList(Content contentListTree) {
+        Content titleContent = getResource(
+                "doclet.Constants_Summary");
+        Content pHeading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
+                HtmlStyle.title, titleContent);
+        Content div = HtmlTree.DIV(HtmlStyle.header, pHeading);
+        Content headingContent = getResource(
+                "doclet.Contents");
+        div.addContent(HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, true,
+                headingContent));
+        div.addContent(contentListTree);
+        return div;
     }
 
     /**
      * {@inheritDoc}
      */
-    public void writeLinkToPackageContent(PackageDoc pkg, String parsedPackageName, Set<String> printedPackageHeaders) {
-        String packageName = pkg.name();
-        //add link to summary
-        li();
-        if (packageName.length() == 0) {
-            printHyperLink("#" + DocletConstants.UNNAMED_PACKAGE_ANCHOR,
-                           DocletConstants.DEFAULT_PACKAGE_NAME);
-        } else {
-            printHyperLink("#" + parsedPackageName, parsedPackageName + ".*");
-            printedPackageHeaders.add(parsedPackageName);
-        }
-        println();
+    public Content getConstantSummaries() {
+        HtmlTree summariesDiv = new HtmlTree(HtmlTag.DIV);
+        summariesDiv.addStyle(HtmlStyle.constantValuesContainer);
+        return summariesDiv;
     }
 
     /**
      * {@inheritDoc}
      */
-    public void writeConstantMembersHeader(ClassDoc cd) {
+    public void addPackageName(PackageDoc pkg, String parsedPackageName,
+            Content summariesTree) {
+        Content pkgNameContent;
+        if (parsedPackageName.length() == 0) {
+            summariesTree.addContent(getMarkerAnchor(
+                    DocletConstants.UNNAMED_PACKAGE_ANCHOR));
+            pkgNameContent = defaultPackageLabel;
+        } else {
+            summariesTree.addContent(getMarkerAnchor(
+                    parsedPackageName));
+            pkgNameContent = getPackageLabel(parsedPackageName);
+        }
+        Content headingContent = new StringContent(".*");
+        Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true,
+                pkgNameContent);
+        heading.addContent(headingContent);
+        summariesTree.addContent(heading);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Content getClassConstantHeader() {
+        HtmlTree ul = new HtmlTree(HtmlTag.UL);
+        ul.addStyle(HtmlStyle.blockList);
+        return ul;
+    }
+
+    /**
+     * Get the table caption and header for the constant summary table
+     *
+     * @param cd classdoc to be documented
+     * @return constant members header content
+     */
+    public Content getConstantMembersHeader(ClassDoc cd) {
         //generate links backward only to public classes.
         String classlink = (cd.isPublic() || cd.isProtected())?
             getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CONSTANT_SUMMARY, cd,
@@ -144,112 +184,120 @@
             cd.qualifiedName();
         String name = cd.containingPackage().name();
         if (name.length() > 0) {
-            writeClassName(name + "." + classlink);
+            return getClassName(name + "." + classlink);
         } else {
-            writeClassName(classlink);
+            return getClassName(classlink);
         }
     }
 
     /**
+     * Get the class name in the table caption and the table header.
+     *
+     * @param classStr the class name to print.
+     * @return the table caption and header
+     */
+    protected Content getClassName(String classStr) {
+        Content table = HtmlTree.TABLE(0, 3, 0, constantsTableSummary,
+                getTableCaption(classStr));
+        table.addContent(getSummaryTableHeader(constantsTableHeader, "col"));
+        return table;
+    }
+
+    /**
      * {@inheritDoc}
      */
-    public void writeConstantMembersFooter(ClassDoc cd) {
-        tableFooter(false);
-        p();
+    public void addConstantMembers(ClassDoc cd, List<FieldDoc> fields,
+            Content classConstantTree) {
+        currentClassDoc = cd;
+        Content tbody = new HtmlTree(HtmlTag.TBODY);
+        for (int i = 0; i < fields.size(); ++i) {
+            HtmlTree tr = new HtmlTree(HtmlTag.TR);
+            if (i%2 == 0)
+                tr.addStyle(HtmlStyle.altColor);
+            else
+                tr.addStyle(HtmlStyle.rowColor);
+            addConstantMember(fields.get(i), tr);
+            tbody.addContent(tr);
+        }
+        Content table = getConstantMembersHeader(cd);
+        table.addContent(tbody);
+        Content li = HtmlTree.LI(HtmlStyle.blockList, table);
+        classConstantTree.addContent(li);
     }
 
     /**
-     * Print the class name in the table heading.
-     * @param classStr the heading to print.
+     * Add the row for the constant summary table.
+     *
+     * @param member the field to be documented.
+     * @param trTree an htmltree object for the table row
      */
-    protected void writeClassName(String classStr) {
-        table(1, 3, 0, constantsTableSummary);
-        tableSubCaptionStart();
-        write(classStr);
-        tableCaptionEnd();
-        summaryTableHeader(constantsTableHeader, "col");
+    private void addConstantMember(FieldDoc member, HtmlTree trTree) {
+        trTree.addContent(getTypeColumn(member));
+        trTree.addContent(getNameColumn(member));
+        trTree.addContent(getValue(member));
     }
 
-    private void tableFooter(boolean isHeader) {
-        fontEnd();
-        if (isHeader) {
-            thEnd();
-        } else {
-            tdEnd();
+    /**
+     * Get the type column for the constant summary table row.
+     *
+     * @param member the field to be documented.
+     * @return the type column of the constant table row
+     */
+    private Content getTypeColumn(FieldDoc member) {
+        Content anchor = getMarkerAnchor(currentClassDoc.qualifiedName() +
+                "." + member.name());
+        Content tdType = HtmlTree.TD(HtmlStyle.colFirst, anchor);
+        Content code = new HtmlTree(HtmlTag.CODE);
+        StringTokenizer mods = new StringTokenizer(member.modifiers());
+        while(mods.hasMoreTokens()) {
+            Content modifier = new StringContent(mods.nextToken());
+            code.addContent(modifier);
+            code.addContent(getSpace());
         }
-        trEnd();
-        tableEnd();
-        p();
+        Content type = new RawHtml(getLink(new LinkInfoImpl(
+                LinkInfoImpl.CONTEXT_CONSTANT_SUMMARY, member.type())));
+        code.addContent(type);
+        tdType.addContent(code);
+        return tdType;
+    }
+
+    /**
+     * Get the name column for the constant summary table row.
+     *
+     * @param member the field to be documented.
+     * @return the name column of the constant table row
+     */
+    private Content getNameColumn(FieldDoc member) {
+        Content nameContent = new RawHtml(getDocLink(
+                LinkInfoImpl.CONTEXT_CONSTANT_SUMMARY, member, member.name(), false));
+        Content code = HtmlTree.CODE(nameContent);
+        return HtmlTree.TD(code);
+    }
+
+    /**
+     * Get the value column for the constant summary table row.
+     *
+     * @param member the field to be documented.
+     * @return the value column of the constant table row
+     */
+    private Content getValue(FieldDoc member) {
+        Content valueContent = new StringContent(member.constantValueExpression());
+        Content code = HtmlTree.CODE(valueContent);
+        return HtmlTree.TD(HtmlStyle.colLast, code);
     }
 
     /**
      * {@inheritDoc}
      */
-    public void writePackageName(PackageDoc pkg, String parsedPackageName) {
-        String pkgname;
-        if (parsedPackageName.length() == 0) {
-            anchor(DocletConstants.UNNAMED_PACKAGE_ANCHOR);
-            pkgname = DocletConstants.DEFAULT_PACKAGE_NAME;
-        } else {
-            anchor(parsedPackageName);
-            pkgname = parsedPackageName;
-        }
-        table(1, "100%", 3, 0);
-        trBgcolorStyle("#CCCCFF", "TableHeadingColor");
-        thAlign("left");
-        font("+2");
-        write(pkgname + ".*");
-        tableFooter(true);
+    public void addFooter(Content contentTree) {
+        addNavLinks(false, contentTree);
+        addBottom(contentTree);
     }
 
     /**
      * {@inheritDoc}
      */
-    public void writeConstantMembers(ClassDoc cd, List<FieldDoc> fields) {
-        currentClassDoc = cd;
-        for (int i = 0; i < fields.size(); ++i) {
-            writeConstantMember(fields.get(i));
-        }
-    }
-
-    private void writeConstantMember(FieldDoc member) {
-        trBgcolorStyle("white", "TableRowColor");
-        anchor(currentClassDoc.qualifiedName() + "." + member.name());
-        writeTypeColumn(member);
-        writeNameColumn(member);
-        writeValue(member);
-        trEnd();
-    }
-
-    private void writeTypeColumn(FieldDoc member) {
-        tdAlign("right");
-        font("-1");
-        code();
-        StringTokenizer mods = new StringTokenizer(member.modifiers());
-        while(mods.hasMoreTokens()) {
-            print(mods.nextToken() + "&nbsp;");
-        }
-        printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CONSTANT_SUMMARY,
-            member.type()));
-        codeEnd();
-        fontEnd();
-        tdEnd();
-    }
-
-    private void writeNameColumn(FieldDoc member) {
-        tdAlign("left");
-        code();
-        printDocLink(LinkInfoImpl.CONTEXT_CONSTANT_SUMMARY, member,
-            member.name(), false);
-        codeEnd();
-        tdEnd();
-    }
-
-    private void writeValue(FieldDoc member) {
-        tdAlign("right");
-        code();
-        print(Util.escapeHtmlChars(member.constantValueExpression()));
-        codeEnd();
-        tdEnd();
+    public void printDocument(Content contentTree) {
+        printHtmlDocument(null, true, contentTree);
     }
 }
--- a/src/share/classes/com/sun/tools/doclets/formats/html/ConstructorWriterImpl.java	Thu Dec 16 19:57:01 2010 -0800
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/ConstructorWriterImpl.java	Mon Dec 20 21:10:57 2010 -0800
@@ -29,6 +29,7 @@
 import java.util.*;
 
 import com.sun.javadoc.*;
+import com.sun.tools.doclets.formats.html.markup.*;
 import com.sun.tools.doclets.internal.toolkit.*;
 import com.sun.tools.doclets.internal.toolkit.util.*;
 
@@ -43,7 +44,6 @@
     implements ConstructorWriter, MemberSummaryWriter {
 
     private boolean foundNonPubConstructor = false;
-    private boolean printedSummaryHeader = false;
 
     /**
      * Construct a new ConstructorWriterImpl.
@@ -75,125 +75,112 @@
     }
 
     /**
-     * Write the constructors summary header for the given class.
-     *
-     * @param classDoc the class the summary belongs to.
+     * {@inheritDoc}
      */
-    public void writeMemberSummaryHeader(ClassDoc classDoc) {
-        printedSummaryHeader = true;
-        writer.println();
-        writer.println("<!-- ======== CONSTRUCTOR SUMMARY ======== -->");
-        writer.println();
-        writer.printSummaryHeader(this, classDoc);
+    public Content getMemberSummaryHeader(ClassDoc classDoc,
+            Content memberSummaryTree) {
+        memberSummaryTree.addContent(HtmlConstants.START_OF_CONSTRUCTOR_SUMMARY);
+        Content memberTree = writer.getMemberTreeHeader();
+        writer.addSummaryHeader(this, classDoc, memberTree);
+        return memberTree;
     }
 
     /**
-     * Write the constructors summary footer for the given class.
-     *
-     * @param classDoc the class the summary belongs to.
+     * {@inheritDoc}
      */
-    public void writeMemberSummaryFooter(ClassDoc classDoc) {
-        writer.printSummaryFooter(this, classDoc);
+    public Content getConstructorDetailsTreeHeader(ClassDoc classDoc,
+            Content memberDetailsTree) {
+        memberDetailsTree.addContent(HtmlConstants.START_OF_CONSTRUCTOR_DETAILS);
+        Content constructorDetailsTree = writer.getMemberTreeHeader();
+        constructorDetailsTree.addContent(writer.getMarkerAnchor("constructor_detail"));
+        Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING,
+                writer.constructorDetailsLabel);
+        constructorDetailsTree.addContent(heading);
+        return constructorDetailsTree;
     }
 
     /**
-     * Write the header for the constructor documentation.
-     *
-     * @param classDoc the class that the constructors belong to.
+     * {@inheritDoc}
      */
-    public void writeHeader(ClassDoc classDoc, String header) {
-        writer.println();
-        writer.println("<!-- ========= CONSTRUCTOR DETAIL ======== -->");
-        writer.println();
-        writer.anchor("constructor_detail");
-        writer.printTableHeadingBackground(header);
+    public Content getConstructorDocTreeHeader(ConstructorDoc constructor,
+            Content constructorDetailsTree) {
+        String erasureAnchor;
+        if ((erasureAnchor = getErasureAnchor(constructor)) != null) {
+            constructorDetailsTree.addContent(writer.getMarkerAnchor((erasureAnchor)));
+        }
+        constructorDetailsTree.addContent(
+                writer.getMarkerAnchor(writer.getAnchor(constructor)));
+        Content constructorDocTree = writer.getMemberTreeHeader();
+        Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING);
+        heading.addContent(constructor.name());
+        constructorDocTree.addContent(heading);
+        return constructorDocTree;
     }
 
     /**
-     * Write the constructor header for the given constructor.
-     *
-     * @param constructor the constructor being documented.
-     * @param isFirst the flag to indicate whether or not the constructor is the
-     *        first to be documented.
+     * {@inheritDoc}
      */
-    public void writeConstructorHeader(ConstructorDoc constructor, boolean isFirst) {
-        if (! isFirst) {
-            writer.printMemberHeader();
+    public Content getSignature(ConstructorDoc constructor) {
+        writer.displayLength = 0;
+        Content pre = new HtmlTree(HtmlTag.PRE);
+        writer.addAnnotationInfo(constructor, pre);
+        addModifiers(constructor, pre);
+        if (configuration().linksource) {
+            Content constructorName = new StringContent(constructor.name());
+            writer.addSrcLink(constructor, constructorName, pre);
+        } else {
+            addName(constructor.name(), pre);
         }
-        writer.println();
-        String erasureAnchor;
-        if ((erasureAnchor = getErasureAnchor(constructor)) != null) {
-            writer.anchor(erasureAnchor);
-        }
-        writer.anchor(constructor);
-        writer.h3();
-        writer.print(constructor.name());
-        writer.h3End();
+        addParameters(constructor, pre);
+        addExceptions(constructor, pre);
+        return pre;
     }
 
     /**
-     * Write the signature for the given constructor.
-     *
-     * @param constructor the constructor being documented.
+     * {@inheritDoc}
      */
-    public void writeSignature(ConstructorDoc constructor) {
-        writer.displayLength = 0;
-        writer.pre();
-        writer.writeAnnotationInfo(constructor);
-        printModifiers(constructor);
-        //printReturnType((ConstructorDoc)constructor);
-        if (configuration().linksource) {
-            writer.printSrcLink(constructor, constructor.name());
-        } else {
-            strong(constructor.name());
-        }
-        writeParameters(constructor);
-        writeExceptions(constructor);
-        writer.preEnd();
-        assert !writer.getMemberDetailsListPrinted();
+    @Override
+    public void setSummaryColumnStyle(HtmlTree tdTree) {
+        if (foundNonPubConstructor)
+            tdTree.addStyle(HtmlStyle.colLast);
+        else
+            tdTree.addStyle(HtmlStyle.colOne);
     }
 
     /**
-     * Write the deprecated output for the given constructor.
-     *
-     * @param constructor the constructor being documented.
+     * {@inheritDoc}
      */
-    public void writeDeprecated(ConstructorDoc constructor) {
-        printDeprecated(constructor);
+    public void addDeprecated(ConstructorDoc constructor, Content constructorDocTree) {
+        addDeprecatedInfo(constructor, constructorDocTree);
     }
 
     /**
-     * Write the comments for the given constructor.
-     *
-     * @param constructor the constructor being documented.
+     * {@inheritDoc}
      */
-    public void writeComments(ConstructorDoc constructor) {
-        printComment(constructor);
+    public void addComments(ConstructorDoc constructor, Content constructorDocTree) {
+        addComment(constructor, constructorDocTree);
     }
 
     /**
-     * Write the tag output for the given constructor.
-     *
-     * @param constructor the constructor being documented.
+     * {@inheritDoc}
      */
-    public void writeTags(ConstructorDoc constructor) {
-        writer.printTags(constructor);
+    public void addTags(ConstructorDoc constructor, Content constructorDocTree) {
+        writer.addTagsInfo(constructor, constructorDocTree);
     }
 
     /**
-     * Write the constructor footer.
+     * {@inheritDoc}
      */
-    public void writeConstructorFooter() {
-        printMemberFooter();
+    public Content getConstructorDetails(Content constructorDetailsTree) {
+        return getMemberTree(constructorDetailsTree);
     }
 
     /**
-     * Write the footer for the constructor documentation.
-     *
-     * @param classDoc the class that the constructors belong to.
+     * {@inheritDoc}
      */
-    public void writeFooter(ClassDoc classDoc) {
-        //No footer to write for constructor documentation
+    public Content getConstructorDoc(Content constructorDocTree,
+            boolean isLastContent) {
+        return getMemberTree(constructorDocTree, isLastContent);
     }
 
     /**
@@ -212,17 +199,35 @@
         this.foundNonPubConstructor = foundNonPubConstructor;
     }
 
-    public void printSummaryLabel() {
-        writer.printText("doclet.Constructor_Summary");
+    /**
+     * {@inheritDoc}
+     */
+    public void addSummaryLabel(Content memberTree) {
+        Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
+                writer.getResource("doclet.Constructor_Summary"));
+        memberTree.addContent(label);
     }
 
-    public void printTableSummary() {
-        writer.tableIndexSummary(configuration().getText("doclet.Member_Table_Summary",
+    /**
+     * {@inheritDoc}
+     */
+    public String getTableSummary() {
+        return configuration().getText("doclet.Member_Table_Summary",
                 configuration().getText("doclet.Constructor_Summary"),
-                configuration().getText("doclet.constructors")));
+                configuration().getText("doclet.constructors"));
     }
 
-    public void printSummaryTableHeader(ProgramElementDoc member) {
+    /**
+     * {@inheritDoc}
+     */
+    public String getCaption() {
+        return configuration().getText("doclet.Constructors");
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String[] getSummaryTableHeader(ProgramElementDoc member) {
         String[] header;
         if (foundNonPubConstructor) {
             header = new String[] {
@@ -239,87 +244,73 @@
                         configuration().getText("doclet.Description"))
             };
         }
-        writer.summaryTableHeader(header, "col");
+        return header;
     }
 
-    public void printSummaryAnchor(ClassDoc cd) {
-        writer.anchor("constructor_summary");
+    /**
+     * {@inheritDoc}
+     */
+    public void addSummaryAnchor(ClassDoc cd, Content memberTree) {
+        memberTree.addContent(writer.getMarkerAnchor("constructor_summary"));
     }
 
-    public void printInheritedSummaryAnchor(ClassDoc cd) {
-    }   // no such
+    /**
+     * {@inheritDoc}
+     */
+    public void addInheritedSummaryAnchor(ClassDoc cd, Content inheritedTree) {
+    }
 
-    public void printInheritedSummaryLabel(ClassDoc cd) {
-        // no such
+    /**
+     * {@inheritDoc}
+     */
+    public void addInheritedSummaryLabel(ClassDoc cd, Content inheritedTree) {
     }
 
     public int getMemberKind() {
         return VisibleMemberMap.CONSTRUCTORS;
     }
 
-    protected void navSummaryLink(List<?> members) {
-        printNavSummaryLink(classdoc,
-                members.size() > 0? true: false);
-    }
-
-    protected void printNavSummaryLink(ClassDoc cd, boolean link) {
+    /**
+     * {@inheritDoc}
+     */
+    protected Content getNavSummaryLink(ClassDoc cd, boolean link) {
         if (link) {
-            writer.printHyperLink("", "constructor_summary",
-                    ConfigurationImpl.getInstance().getText("doclet.navConstructor"));
+            return writer.getHyperLink("", "constructor_summary",
+                    writer.getResource("doclet.navConstructor"));
         } else {
-            writer.printText("doclet.navConstructor");
-        }
-    }
-
-    protected void printNavDetailLink(boolean link) {
-        if (link) {
-            writer.printHyperLink("", "constructor_detail",
-                    ConfigurationImpl.getInstance().getText("doclet.navConstructor"));
-        } else {
-            writer.printText("doclet.navConstructor");
-        }
-    }
-
-    protected void printSummaryType(ProgramElementDoc member) {
-        if (foundNonPubConstructor) {
-            writer.printTypeSummaryHeader();
-            if (member.isProtected()) {
-                print("protected ");
-            } else if (member.isPrivate()) {
-                print("private ");
-            } else if (member.isPublic()) {
-                writer.space();
-            } else {
-                writer.printText("doclet.Package_private");
-            }
-            writer.printTypeSummaryFooter();
-        }
-    }
-
-    /**
-     * Write the inherited member summary header for the given class.
-     *
-     * @param classDoc the class the summary belongs to.
-     */
-    public void writeInheritedMemberSummaryHeader(ClassDoc classDoc) {
-        if(! printedSummaryHeader){
-            //We don't want inherited summary to not be under heading.
-            writeMemberSummaryHeader(classDoc);
-            writeMemberSummaryFooter(classDoc);
-            printedSummaryHeader = true;
+            return writer.getResource("doclet.navConstructor");
         }
     }
 
     /**
      * {@inheritDoc}
      */
-    public void writeInheritedMemberSummary(ClassDoc classDoc,
-        ProgramElementDoc member, boolean isFirst, boolean isLast) {}
+    protected void addNavDetailLink(boolean link, Content liNav) {
+        if (link) {
+            liNav.addContent(writer.getHyperLink("", "constructor_detail",
+                    writer.getResource("doclet.navConstructor")));
+        } else {
+            liNav.addContent(writer.getResource("doclet.navConstructor"));
+        }
+    }
 
     /**
-     * Write the inherited member summary footer for the given class.
-     *
-     * @param classDoc the class the summary belongs to.
+     * {@inheritDoc}
      */
-    public void writeInheritedMemberSummaryFooter(ClassDoc classDoc) {}
+    protected void addSummaryType(ProgramElementDoc member, Content tdSummaryType) {
+        if (foundNonPubConstructor) {
+            Content code = new HtmlTree(HtmlTag.CODE);
+            if (member.isProtected()) {
+                code.addContent("protected ");
+            } else if (member.isPrivate()) {
+                code.addContent("private ");
+            } else if (member.isPublic()) {
+                code.addContent(writer.getSpace());
+            } else {
+                code.addContent(
+                        configuration().getText("doclet.Package_private"));
+            }
+            tdSummaryType.addContent(code);
+        }
+    }
 }
--- a/src/share/classes/com/sun/tools/doclets/formats/html/DeprecatedListWriter.java	Thu Dec 16 19:57:01 2010 -0800
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/DeprecatedListWriter.java	Mon Dec 20 21:10:57 2010 -0800
@@ -25,9 +25,11 @@
 
 package com.sun.tools.doclets.formats.html;
 
+import java.io.*;
+import com.sun.tools.doclets.internal.toolkit.*;
 import com.sun.tools.doclets.internal.toolkit.util.DeprecatedAPIListBuilder;
 import com.sun.tools.doclets.internal.toolkit.util.*;
-import java.io.*;
+import com.sun.tools.doclets.formats.html.markup.*;
 
 /**
  * Generate File to list all the deprecated classes and class members with the
@@ -125,28 +127,21 @@
     }
 
     /**
-     * Print the deprecated API list. Separately print all class kinds and
-     * member kinds.
+     * Generate the deprecated API list.
      *
      * @param deprapi list of deprecated API built already.
      */
     protected void generateDeprecatedListFile(DeprecatedAPIListBuilder deprapi)
-             throws IOException {
-        writeHeader();
-
-        strong(configuration.getText("doclet.Contents"));
-        ul();
-        for (int i = 0; i < DeprecatedAPIListBuilder.NUM_TYPES; i++) {
-            writeIndexLink(deprapi, i);
-        }
-        ulEnd();
-        println();
-
+            throws IOException {
+        Content body = getHeader();
+        body.addContent(getContentsList(deprapi));
         String memberTableSummary;
         String[] memberTableHeader = new String[1];
+        HtmlTree div = new HtmlTree(HtmlTag.DIV);
+        div.addStyle(HtmlStyle.contentContainer);
         for (int i = 0; i < DeprecatedAPIListBuilder.NUM_TYPES; i++) {
             if (deprapi.hasDocumentation(i)) {
-                writeAnchor(deprapi, i);
+                addAnchor(deprapi, i, div);
                 memberTableSummary =
                         configuration.getText("doclet.Member_Table_Summary",
                         configuration.getText(HEADING_KEYS[i]),
@@ -154,66 +149,87 @@
                 memberTableHeader[0] = configuration.getText("doclet.0_and_1",
                         configuration.getText(HEADER_KEYS[i]),
                         configuration.getText("doclet.Description"));
-                writers[i].printDeprecatedAPI(deprapi.getList(i),
-                    HEADING_KEYS[i], memberTableSummary, memberTableHeader);
+                writers[i].addDeprecatedAPI(deprapi.getList(i),
+                        HEADING_KEYS[i], memberTableSummary, memberTableHeader, div);
             }
         }
-        printDeprecatedFooter();
+        body.addContent(div);
+        addNavLinks(false, body);
+        addBottom(body);
+        printHtmlDocument(null, true, body);
     }
 
-    private void writeIndexLink(DeprecatedAPIListBuilder builder,
-            int type) {
+    /**
+     * Add the index link.
+     *
+     * @param builder the deprecated list builder
+     * @param type the type of list being documented
+     * @param contentTree the content tree to which the index link will be added
+     */
+    private void addIndexLink(DeprecatedAPIListBuilder builder,
+            int type, Content contentTree) {
         if (builder.hasDocumentation(type)) {
-            li();
-            printHyperLink("#" + ANCHORS[type],
-                configuration.getText(HEADING_KEYS[type]));
-            println();
-        }
-    }
-
-    private void writeAnchor(DeprecatedAPIListBuilder builder, int type) {
-        if (builder.hasDocumentation(type)) {
-            anchor(ANCHORS[type]);
+            Content li = HtmlTree.LI(getHyperLink("#" + ANCHORS[type],
+                    getResource(HEADING_KEYS[type])));
+            contentTree.addContent(li);
         }
     }
 
     /**
-     * Print the navigation bar and header for the deprecated API Listing.
+     * Get the contents list.
+     *
+     * @param deprapi the deprecated list builder
+     * @return a content tree for the contents list
      */
-    protected void writeHeader() {
-        printHtmlHeader(configuration.getText("doclet.Window_Deprecated_List"),
-            null, true);
-        printTop();
-        navLinks(true);
-        hr();
-        center();
-        h2();
-        strongText("doclet.Deprecated_API");
-        h2End();
-        centerEnd();
-
-        hr(4, "noshade");
+    public Content getContentsList(DeprecatedAPIListBuilder deprapi) {
+        Content headContent = getResource("doclet.Deprecated_API");
+        Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
+                HtmlStyle.title, headContent);
+        Content div = HtmlTree.DIV(HtmlStyle.header, heading);
+        Content headingContent = getResource("doclet.Contents");
+        div.addContent(HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, true,
+                headingContent));
+        Content ul = new HtmlTree(HtmlTag.UL);
+        for (int i = 0; i < DeprecatedAPIListBuilder.NUM_TYPES; i++) {
+            addIndexLink(deprapi, i, ul);
+        }
+        div.addContent(ul);
+        return div;
     }
 
     /**
-     * Print the navigation bar and the footer for the deprecated API Listing.
+     * Add the anchor.
+     *
+     * @param builder the deprecated list builder
+     * @param type the type of list being documented
+     * @param contentTree the content tree to which the anchor will be added
      */
-    protected void printDeprecatedFooter() {
-        hr();
-        navLinks(false);
-        printBottom();
-        printBodyHtmlEnd();
+    private void addAnchor(DeprecatedAPIListBuilder builder, int type, Content htmlTree) {
+        if (builder.hasDocumentation(type)) {
+            htmlTree.addContent(getMarkerAnchor(ANCHORS[type]));
+        }
     }
 
     /**
-     * Highlight the word "Deprecated" in the navigation bar as this is the same
-     * page.
+     * Get the header for the deprecated API Listing.
+     *
+     * @return a content tree for the header
      */
-    protected void navLinkDeprecated() {
-        navCellRevStart();
-        fontStyle("NavBarFont1Rev");
-        strongText("doclet.navDeprecated");
-        fontEnd();
-        navCellEnd();
+    public Content getHeader() {
+        String title = configuration.getText("doclet.Window_Deprecated_List");
+        Content bodyTree = getBody(true, getWindowTitle(title));
+        addTop(bodyTree);
+        addNavLinks(true, bodyTree);
+        return bodyTree;
+    }
+
+    /**
+     * Get the deprecated label.
+     *
+     * @return a content tree for the deprecated label
+     */
+    protected Content getNavLinkDeprecated() {
+        Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, deprecatedLabel);
+        return li;
     }
 }
--- a/src/share/classes/com/sun/tools/doclets/formats/html/EnumConstantWriterImpl.java	Thu Dec 16 19:57:01 2010 -0800
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/EnumConstantWriterImpl.java	Mon Dec 20 21:10:57 2010 -0800
@@ -28,6 +28,7 @@
 import java.io.*;
 
 import com.sun.javadoc.*;
+import com.sun.tools.doclets.formats.html.markup.*;
 import com.sun.tools.doclets.internal.toolkit.*;
 import com.sun.tools.doclets.internal.toolkit.util.*;
 
@@ -40,8 +41,6 @@
 public class EnumConstantWriterImpl extends AbstractMemberWriter
     implements EnumConstantWriter, MemberSummaryWriter {
 
-    private boolean printedSummaryHeader = false;
-
     public EnumConstantWriterImpl(SubWriterHolderWriter writer,
         ClassDoc classdoc) {
         super(writer, classdoc);
@@ -52,136 +51,98 @@
     }
 
     /**
-     * Write the enum constant summary header for the given class.
-     *
-     * @param classDoc the class the summary belongs to.
+     * {@inheritDoc}
      */
-    public void writeMemberSummaryHeader(ClassDoc classDoc) {
-        printedSummaryHeader = true;
-        writer.println("<!-- =========== ENUM CONSTANT SUMMARY =========== -->");
-        writer.println();
-        writer.printSummaryHeader(this, classDoc);
-    }
-
-    /**
-     * Write the enum constant summary footer for the given class.
-     *
-     * @param classDoc the class the summary belongs to.
-     */
-    public void writeMemberSummaryFooter(ClassDoc classDoc) {
-        writer.printSummaryFooter(this, classDoc);
-    }
-
-    /**
-     * Write the inherited enum constant summary header for the given class.
-     *
-     * @param classDoc the class the summary belongs to.
-     */
-    public void writeInheritedMemberSummaryHeader(ClassDoc classDoc) {
-        if(! printedSummaryHeader){
-            //We don't want inherited summary to not be under heading.
-            writeMemberSummaryHeader(classDoc);
-            writeMemberSummaryFooter(classDoc);
-            printedSummaryHeader = true;
-        }
-        writer.printInheritedSummaryHeader(this, classDoc);
+    public Content getMemberSummaryHeader(ClassDoc classDoc,
+            Content memberSummaryTree) {
+        memberSummaryTree.addContent(HtmlConstants.START_OF_ENUM_CONSTANT_SUMMARY);
+        Content memberTree = writer.getMemberTreeHeader();
+        writer.addSummaryHeader(this, classDoc, memberTree);
+        return memberTree;
     }
 
     /**
      * {@inheritDoc}
      */
-    public void writeInheritedMemberSummary(ClassDoc classDoc,
-        ProgramElementDoc enumConstant, boolean isFirst, boolean isLast) {
-        writer.printInheritedSummaryMember(this, classDoc, enumConstant, isFirst);
-    }
-
-    /**
-     * Write the inherited enum constant summary footer for the given class.
-     *
-     * @param classDoc the class the summary belongs to.
-     */
-    public void writeInheritedMemberSummaryFooter(ClassDoc classDoc) {
-        writer.printInheritedSummaryFooter(this, classDoc);
+    public Content getEnumConstantsDetailsTreeHeader(ClassDoc classDoc,
+            Content memberDetailsTree) {
+        memberDetailsTree.addContent(HtmlConstants.START_OF_ENUM_CONSTANT_DETAILS);
+        Content enumConstantsDetailsTree = writer.getMemberTreeHeader();
+        enumConstantsDetailsTree.addContent(writer.getMarkerAnchor("enum_constant_detail"));
+        Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING,
+                writer.enumConstantsDetailsLabel);
+        enumConstantsDetailsTree.addContent(heading);
+        return enumConstantsDetailsTree;
     }
 
     /**
      * {@inheritDoc}
      */
-    public void writeHeader(ClassDoc classDoc, String header) {
-        writer.println();
-        writer.println("<!-- ============ ENUM CONSTANT DETAIL =========== -->");
-        writer.println();
-        writer.anchor("enum_constant_detail");
-        writer.printTableHeadingBackground(header);
-        writer.println();
+    public Content getEnumConstantsTreeHeader(FieldDoc enumConstant,
+            Content enumConstantsDetailsTree) {
+        enumConstantsDetailsTree.addContent(
+                writer.getMarkerAnchor(enumConstant.name()));
+        Content enumConstantsTree = writer.getMemberTreeHeader();
+        Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING);
+        heading.addContent(enumConstant.name());
+        enumConstantsTree.addContent(heading);
+        return enumConstantsTree;
     }
 
     /**
      * {@inheritDoc}
      */
-    public void writeEnumConstantHeader(FieldDoc enumConstant, boolean isFirst) {
-        if (! isFirst) {
-            writer.printMemberHeader();
-            writer.println("");
+    public Content getSignature(FieldDoc enumConstant) {
+        Content pre = new HtmlTree(HtmlTag.PRE);
+        writer.addAnnotationInfo(enumConstant, pre);
+        addModifiers(enumConstant, pre);
+        Content enumConstantLink = new RawHtml(writer.getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER,
+                enumConstant.type())));
+        pre.addContent(enumConstantLink);
+        pre.addContent(" ");
+        if (configuration().linksource) {
+            Content enumConstantName = new StringContent(enumConstant.name());
+            writer.addSrcLink(enumConstant, enumConstantName, pre);
+        } else {
+            addName(enumConstant.name(), pre);
         }
-        writer.anchor(enumConstant.name());
-        writer.h3();
-        writer.print(enumConstant.name());
-        writer.h3End();
+        return pre;
     }
 
     /**
      * {@inheritDoc}
      */
-    public void writeSignature(FieldDoc enumConstant) {
-        writer.pre();
-        writer.writeAnnotationInfo(enumConstant);
-        printModifiers(enumConstant);
-        writer.printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER,
-            enumConstant.type()));
-        print(' ');
-        if (configuration().linksource) {
-            writer.printSrcLink(enumConstant, enumConstant.name());
-        } else {
-            strong(enumConstant.name());
-        }
-        writer.preEnd();
-        assert !writer.getMemberDetailsListPrinted();
+    public void addDeprecated(FieldDoc enumConstant, Content enumConstantsTree) {
+        addDeprecatedInfo(enumConstant, enumConstantsTree);
     }
 
     /**
      * {@inheritDoc}
      */
-    public void writeDeprecated(FieldDoc enumConstant) {
-        printDeprecated(enumConstant);
+    public void addComments(FieldDoc enumConstant, Content enumConstantsTree) {
+        addComment(enumConstant, enumConstantsTree);
     }
 
     /**
      * {@inheritDoc}
      */
-    public void writeComments(FieldDoc enumConstant) {
-        printComment(enumConstant);
+    public void addTags(FieldDoc enumConstant, Content enumConstantsTree) {
+        writer.addTagsInfo(enumConstant, enumConstantsTree);
     }
 
     /**
      * {@inheritDoc}
      */
-    public void writeTags(FieldDoc enumConstant) {
-        writer.printTags(enumConstant);
+    public Content getEnumConstantsDetails(Content enumConstantsDetailsTree) {
+        return getMemberTree(enumConstantsDetailsTree);
     }
 
     /**
      * {@inheritDoc}
      */
-    public void writeEnumConstantFooter() {
-        printMemberFooter();
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public void writeFooter(ClassDoc classDoc) {
-        //No footer to write for enum constant documentation
+    public Content getEnumConstants(Content enumConstantsTree,
+            boolean isLastContent) {
+        return getMemberTree(enumConstantsTree, isLastContent);
     }
 
     /**
@@ -195,75 +156,127 @@
         return VisibleMemberMap.ENUM_CONSTANTS;
     }
 
-    public void printSummaryLabel() {
-        writer.printText("doclet.Enum_Constant_Summary");
+    /**
+     * {@inheritDoc}
+     */
+    public void addSummaryLabel(Content memberTree) {
+        Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
+                writer.getResource("doclet.Enum_Constant_Summary"));
+        memberTree.addContent(label);
     }
 
-    public void printTableSummary() {
-        writer.tableIndexSummary(configuration().getText("doclet.Member_Table_Summary",
+    /**
+     * {@inheritDoc}
+     */
+    public String getTableSummary() {
+        return configuration().getText("doclet.Member_Table_Summary",
                 configuration().getText("doclet.Enum_Constant_Summary"),
-                configuration().getText("doclet.enum_constants")));
+                configuration().getText("doclet.enum_constants"));
     }
 
-    public void printSummaryTableHeader(ProgramElementDoc member) {
+    /**
+     * {@inheritDoc}
+     */
+    public String getCaption() {
+        return configuration().getText("doclet.Enum_Constants");
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String[] getSummaryTableHeader(ProgramElementDoc member) {
         String[] header = new String[] {
             configuration().getText("doclet.0_and_1",
                     configuration().getText("doclet.Enum_Constant"),
                     configuration().getText("doclet.Description"))
         };
-        writer.summaryTableHeader(header, "col");
+        return header;
     }
 
-    public void printSummaryAnchor(ClassDoc cd) {
-        writer.anchor("enum_constant_summary");
+    /**
+     * {@inheritDoc}
+     */
+    public void addSummaryAnchor(ClassDoc cd, Content memberTree) {
+        memberTree.addContent(writer.getMarkerAnchor("enum_constant_summary"));
     }
 
-    public void printInheritedSummaryAnchor(ClassDoc cd) {
-    }   // no such
-
-    public void printInheritedSummaryLabel(ClassDoc cd) {
-        // no such
+    /**
+     * {@inheritDoc}
+     */
+    public void addInheritedSummaryAnchor(ClassDoc cd, Content inheritedTree) {
     }
 
-    protected void writeSummaryLink(int context, ClassDoc cd, ProgramElementDoc member) {
-        writer.strong();
-        writer.printDocLink(context, (MemberDoc) member, member.name(), false);
-        writer.strongEnd();
+    /**
+     * {@inheritDoc}
+     */
+    public void addInheritedSummaryLabel(ClassDoc cd, Content inheritedTree) {
     }
 
-    protected void writeInheritedSummaryLink(ClassDoc cd,
-            ProgramElementDoc member) {
-        writer.printDocLink(LinkInfoImpl.CONTEXT_MEMBER, (MemberDoc)member,
-            member.name(), false);
+    /**
+     * {@inheritDoc}
+     */
+    protected void addSummaryLink(int context, ClassDoc cd, ProgramElementDoc member,
+            Content tdSummary) {
+        Content strong = HtmlTree.STRONG(new RawHtml(
+                writer.getDocLink(context, (MemberDoc) member, member.name(), false)));
+        Content code = HtmlTree.CODE(strong);
+        tdSummary.addContent(code);
     }
 
-    protected void printSummaryType(ProgramElementDoc member) {
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void setSummaryColumnStyle(HtmlTree tdTree) {
+        tdTree.addStyle(HtmlStyle.colOne);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    protected void addInheritedSummaryLink(ClassDoc cd,
+            ProgramElementDoc member, Content linksTree) {
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    protected void addSummaryType(ProgramElementDoc member, Content tdSummaryType) {
         //Not applicable.
     }
 
-    protected void writeDeprecatedLink(ProgramElementDoc member) {
-        writer.printDocLink(LinkInfoImpl.CONTEXT_MEMBER,
-            (MemberDoc) member, ((FieldDoc)member).qualifiedName(), false);
+    /**
+     * {@inheritDoc}
+     */
+    protected Content getDeprecatedLink(ProgramElementDoc member) {
+        return writer.getDocLink(LinkInfoImpl.CONTEXT_MEMBER,
+                (MemberDoc) member, ((FieldDoc)member).qualifiedName());
     }
 
-    protected void printNavSummaryLink(ClassDoc cd, boolean link) {
+    /**
+     * {@inheritDoc}
+     */
+    protected Content getNavSummaryLink(ClassDoc cd, boolean link) {
         if (link) {
-            writer.printHyperLink("", (cd == null)?
-                        "enum_constant_summary":
-                        "enum_constants_inherited_from_class_" +
-                        configuration().getClassName(cd),
-                    configuration().getText("doclet.navEnum"));
+            return writer.getHyperLink("", (cd == null)?
+                "enum_constant_summary":
+                "enum_constants_inherited_from_class_" +
+                configuration().getClassName(cd),
+                writer.getResource("doclet.navEnum"));
         } else {
-            writer.printText("doclet.navEnum");
+            return writer.getResource("doclet.navEnum");
         }
     }
 
-    protected void printNavDetailLink(boolean link) {
+    /**
+     * {@inheritDoc}
+     */
+    protected void addNavDetailLink(boolean link, Content liNav) {
         if (link) {
-            writer.printHyperLink("", "enum_constant_detail",
-                configuration().getText("doclet.navEnum"));
+            liNav.addContent(writer.getHyperLink("", "enum_constant_detail",
+                    writer.getResource("doclet.navEnum")));
         } else {
-            writer.printText("doclet.navEnum");
+            liNav.addContent(writer.getResource("doclet.navEnum"));
         }
     }
 }
--- a/src/share/classes/com/sun/tools/doclets/formats/html/FieldWriterImpl.java	Thu Dec 16 19:57:01 2010 -0800
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/FieldWriterImpl.java	Mon Dec 20 21:10:57 2010 -0800
@@ -28,6 +28,7 @@
 import java.io.*;
 
 import com.sun.javadoc.*;
+import com.sun.tools.doclets.formats.html.markup.*;
 import com.sun.tools.doclets.internal.toolkit.*;
 import com.sun.tools.doclets.internal.toolkit.util.*;
 
@@ -42,8 +43,6 @@
 public class FieldWriterImpl extends AbstractMemberWriter
     implements FieldWriter, MemberSummaryWriter {
 
-    private boolean printedSummaryHeader = false;
-
     public FieldWriterImpl(SubWriterHolderWriter writer, ClassDoc classdoc) {
         super(writer, classdoc);
     }
@@ -53,177 +52,118 @@
     }
 
     /**
-     * Write the fields summary header for the given class.
-     *
-     * @param classDoc the class the summary belongs to.
+     * {@inheritDoc}
      */
-    public void writeMemberSummaryHeader(ClassDoc classDoc) {
-        printedSummaryHeader = true;
-        writer.println("<!-- =========== FIELD SUMMARY =========== -->");
-        writer.println();
-        writer.printSummaryHeader(this, classDoc);
-    }
-
-    /**
-     * Write the fields summary footer for the given class.
-     *
-     * @param classDoc the class the summary belongs to.
-     */
-    public void writeMemberSummaryFooter(ClassDoc classDoc) {
-        writer.tableEnd();
-        writer.space();
-    }
-
-    /**
-     * Write the inherited fields summary header for the given class.
-     *
-     * @param classDoc the class the summary belongs to.
-     */
-    public void writeInheritedMemberSummaryHeader(ClassDoc classDoc) {
-        if(! printedSummaryHeader){
-            //We don't want inherited summary to not be under heading.
-            writeMemberSummaryHeader(classDoc);
-            writeMemberSummaryFooter(classDoc);
-            printedSummaryHeader = true;
-        }
-        writer.printInheritedSummaryHeader(this, classDoc);
+    public Content getMemberSummaryHeader(ClassDoc classDoc,
+            Content memberSummaryTree) {
+        memberSummaryTree.addContent(HtmlConstants.START_OF_FIELD_SUMMARY);
+        Content memberTree = writer.getMemberTreeHeader();
+        writer.addSummaryHeader(this, classDoc, memberTree);
+        return memberTree;
     }
 
     /**
      * {@inheritDoc}
      */
-    public void writeInheritedMemberSummary(ClassDoc classDoc,
-        ProgramElementDoc field, boolean isFirst, boolean isLast) {
-        writer.printInheritedSummaryMember(this, classDoc, field, isFirst);
+    public Content getFieldDetailsTreeHeader(ClassDoc classDoc,
+            Content memberDetailsTree) {
+        memberDetailsTree.addContent(HtmlConstants.START_OF_FIELD_DETAILS);
+        Content fieldDetailsTree = writer.getMemberTreeHeader();
+        fieldDetailsTree.addContent(writer.getMarkerAnchor("field_detail"));
+        Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING,
+                writer.fieldDetailsLabel);
+        fieldDetailsTree.addContent(heading);
+        return fieldDetailsTree;
     }
 
     /**
-     * Write the inherited fields summary footer for the given class.
-     *
-     * @param classDoc the class the summary belongs to.
+     * {@inheritDoc}
      */
-    public void writeInheritedMemberSummaryFooter(ClassDoc classDoc) {
-        writer.printInheritedSummaryFooter(this, classDoc);
+    public Content getFieldDocTreeHeader(FieldDoc field,
+            Content fieldDetailsTree) {
+        fieldDetailsTree.addContent(
+                writer.getMarkerAnchor(field.name()));
+        Content fieldDocTree = writer.getMemberTreeHeader();
+        Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING);
+        heading.addContent(field.name());
+        fieldDocTree.addContent(heading);
+        return fieldDocTree;
     }
 
     /**
-     * Write the header for the field documentation.
-     *
-     * @param classDoc the class that the fields belong to.
+     * {@inheritDoc}
      */
-    public void writeHeader(ClassDoc classDoc, String header) {
-        writer.println();
-        writer.println("<!-- ============ FIELD DETAIL =========== -->");
-        writer.println();
-        writer.anchor("field_detail");
-        writer.printTableHeadingBackground(header);
-        writer.println();
+    public Content getSignature(FieldDoc field) {
+        Content pre = new HtmlTree(HtmlTag.PRE);
+        writer.addAnnotationInfo(field, pre);
+        addModifiers(field, pre);
+        Content fieldlink = new RawHtml(writer.getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER,
+                field.type())));
+        pre.addContent(fieldlink);
+        pre.addContent(" ");
+        if (configuration().linksource) {
+            Content fieldName = new StringContent(field.name());
+            writer.addSrcLink(field, fieldName, pre);
+        } else {
+            addName(field.name(), pre);
+        }
+        return pre;
     }
 
     /**
-     * Write the field header for the given field.
-     *
-     * @param field the field being documented.
-     * @param isFirst the flag to indicate whether or not the field is the
-     *        first to be documented.
+     * {@inheritDoc}
      */
-    public void writeFieldHeader(FieldDoc field, boolean isFirst) {
-        if (! isFirst) {
-            writer.printMemberHeader();
-            writer.println("");
-        }
-        writer.anchor(field.name());
-        writer.h3();
-        writer.print(field.name());
-        writer.h3End();
+    public void addDeprecated(FieldDoc field, Content fieldDocTree) {
+        addDeprecatedInfo(field, fieldDocTree);
     }
 
     /**
-     * Write the signature for the given field.
-     *
-     * @param field the field being documented.
+     * {@inheritDoc}
      */
-    public void writeSignature(FieldDoc field) {
-        writer.pre();
-        writer.writeAnnotationInfo(field);
-        printModifiers(field);
-        writer.printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER,
-            field.type()));
-        print(' ');
-        if (configuration().linksource) {
-            writer.printSrcLink(field, field.name());
-        } else {
-            strong(field.name());
-        }
-        writer.preEnd();
-        assert !writer.getMemberDetailsListPrinted();
-    }
-
-    /**
-     * Write the deprecated output for the given field.
-     *
-     * @param field the field being documented.
-     */
-    public void writeDeprecated(FieldDoc field) {
-        printDeprecated(field);
-    }
-
-    /**
-     * Write the comments for the given field.
-     *
-     * @param field the field being documented.
-     */
-    public void writeComments(FieldDoc field) {
+    public void addComments(FieldDoc field, Content fieldDocTree) {
         ClassDoc holder = field.containingClass();
         if (field.inlineTags().length > 0) {
-            writer.printMemberDetailsListStartTag();
             if (holder.equals(classdoc) ||
-                (! (holder.isPublic() || Util.isLinkable(holder, configuration())))) {
-                writer.dd();
-                writer.printInlineComment(field);
-                writer.ddEnd();
+                    (! (holder.isPublic() || Util.isLinkable(holder, configuration())))) {
+                writer.addInlineComment(field, fieldDocTree);
             } else {
-                String classlink = writer.codeText(
-                    writer.getDocLink(LinkInfoImpl.CONTEXT_FIELD_DOC_COPY,
+                Content link = new RawHtml(
+                        writer.getDocLink(LinkInfoImpl.CONTEXT_FIELD_DOC_COPY,
                         holder, field,
                         holder.isIncluded() ?
                             holder.typeName() : holder.qualifiedTypeName(),
-                        false));
-                writer.dd();
-                writer.strong(configuration().getText(holder.isClass()?
-                   "doclet.Description_From_Class" :
-                    "doclet.Description_From_Interface", classlink));
-                writer.ddEnd();
-                writer.dd();
-                writer.printInlineComment(field);
-                writer.ddEnd();
+                            false));
+                Content codeLink = HtmlTree.CODE(link);
+                Content strong = HtmlTree.STRONG(holder.isClass()?
+                   writer.descfrmClassLabel : writer.descfrmInterfaceLabel);
+                strong.addContent(writer.getSpace());
+                strong.addContent(codeLink);
+                fieldDocTree.addContent(HtmlTree.DIV(HtmlStyle.block, strong));
+                writer.addInlineComment(field, fieldDocTree);
             }
         }
     }
 
     /**
-     * Write the tag output for the given field.
-     *
-     * @param field the field being documented.
+     * {@inheritDoc}
      */
-    public void writeTags(FieldDoc field) {
-        writer.printTags(field);
+    public void addTags(FieldDoc field, Content fieldDocTree) {
+        writer.addTagsInfo(field, fieldDocTree);
     }
 
     /**
-     * Write the field footer.
+     * {@inheritDoc}
      */
-    public void writeFieldFooter() {
-        printMemberFooter();
+    public Content getFieldDetails(Content fieldDetailsTree) {
+        return getMemberTree(fieldDetailsTree);
     }
 
     /**
-     * Write the footer for the field documentation.
-     *
-     * @param classDoc the class that the fields belong to.
+     * {@inheritDoc}
      */
-    public void writeFooter(ClassDoc classDoc) {
-        //No footer to write for field documentation
+    public Content getFieldDoc(Content fieldDocTree,
+            boolean isLastContent) {
+        return getMemberTree(fieldDocTree, isLastContent);
     }
 
     /**
@@ -237,85 +177,136 @@
         return VisibleMemberMap.FIELDS;
     }
 
-    public void printSummaryLabel() {
-        writer.printText("doclet.Field_Summary");
+    /**
+     * {@inheritDoc}
+     */
+    public void addSummaryLabel(Content memberTree) {
+        Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
+                writer.getResource("doclet.Field_Summary"));
+        memberTree.addContent(label);
     }
 
-    public void printTableSummary() {
-        writer.tableIndexSummary(configuration().getText("doclet.Member_Table_Summary",
+    /**
+     * {@inheritDoc}
+     */
+    public String getTableSummary() {
+        return configuration().getText("doclet.Member_Table_Summary",
                 configuration().getText("doclet.Field_Summary"),
-                configuration().getText("doclet.fields")));
+                configuration().getText("doclet.fields"));
     }
 
-    public void printSummaryTableHeader(ProgramElementDoc member) {
+    /**
+     * {@inheritDoc}
+     */
+    public String getCaption() {
+        return configuration().getText("doclet.Fields");
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String[] getSummaryTableHeader(ProgramElementDoc member) {
         String[] header = new String[] {
             writer.getModifierTypeHeader(),
             configuration().getText("doclet.0_and_1",
                     configuration().getText("doclet.Field"),
                     configuration().getText("doclet.Description"))
         };
-        writer.summaryTableHeader(header, "col");
+        return header;
     }
 
-    public void printSummaryAnchor(ClassDoc cd) {
-        writer.anchor("field_summary");
+    /**
+     * {@inheritDoc}
+     */
+    public void addSummaryAnchor(ClassDoc cd, Content memberTree) {
+        memberTree.addContent(writer.getMarkerAnchor("field_summary"));
     }
 
-    public void printInheritedSummaryAnchor(ClassDoc cd) {
-        writer.anchor("fields_inherited_from_class_" + configuration().getClassName(cd));
+    /**
+     * {@inheritDoc}
+     */
+    public void addInheritedSummaryAnchor(ClassDoc cd, Content inheritedTree) {
+        inheritedTree.addContent(writer.getMarkerAnchor(
+                "fields_inherited_from_class_" + configuration().getClassName(cd)));
     }
 
-    public void printInheritedSummaryLabel(ClassDoc cd) {
-        String classlink = writer.getPreQualifiedClassLink(
-            LinkInfoImpl.CONTEXT_MEMBER, cd, false);
-        writer.strong();
-        String key = cd.isClass()?
-            "doclet.Fields_Inherited_From_Class" :
-            "doclet.Fields_Inherited_From_Interface";
-        writer.printText(key, classlink);
-        writer.strongEnd();
+    /**
+     * {@inheritDoc}
+     */
+    public void addInheritedSummaryLabel(ClassDoc cd, Content inheritedTree) {
+        Content classLink = new RawHtml(writer.getPreQualifiedClassLink(
+                LinkInfoImpl.CONTEXT_MEMBER, cd, false));
+        Content label = new StringContent(cd.isClass() ?
+            configuration().getText("doclet.Fields_Inherited_From_Class") :
+            configuration().getText("doclet.Fields_Inherited_From_Interface"));
+        Content labelHeading = HtmlTree.HEADING(HtmlConstants.INHERITED_SUMMARY_HEADING,
+                label);
+        labelHeading.addContent(writer.getSpace());
+        labelHeading.addContent(classLink);
+        inheritedTree.addContent(labelHeading);
     }
 
-    protected void writeSummaryLink(int context, ClassDoc cd, ProgramElementDoc member) {
-        writer.strong();
-        writer.printDocLink(context, cd , (MemberDoc) member, member.name(), false);
-        writer.strongEnd();
+    /**
+     * {@inheritDoc}
+     */
+    protected void addSummaryLink(int context, ClassDoc cd, ProgramElementDoc member,
+            Content tdSummary) {
+        Content strong = HtmlTree.STRONG(new RawHtml(
+                writer.getDocLink(context, cd , (MemberDoc) member, member.name(), false)));
+        Content code = HtmlTree.CODE(strong);
+        tdSummary.addContent(code);
     }
 
-    protected void writeInheritedSummaryLink(ClassDoc cd,
-            ProgramElementDoc member) {
-        writer.printDocLink(LinkInfoImpl.CONTEXT_MEMBER, cd, (MemberDoc)member,
-            member.name(), false);
+    /**
+     * {@inheritDoc}
+     */
+    protected void addInheritedSummaryLink(ClassDoc cd,
+            ProgramElementDoc member, Content linksTree) {
+        linksTree.addContent(new RawHtml(
+                writer.getDocLink(LinkInfoImpl.CONTEXT_MEMBER, cd, (MemberDoc)member,
+                member.name(), false)));
     }
 
-    protected void printSummaryType(ProgramElementDoc member) {
+    /**
+     * {@inheritDoc}
+     */
+    protected void addSummaryType(ProgramElementDoc member, Content tdSummaryType) {
         FieldDoc field = (FieldDoc)member;
-        printModifierAndType(field, field.type());
+        addModifierAndType(field, field.type(), tdSummaryType);
     }
 
-    protected void writeDeprecatedLink(ProgramElementDoc member) {
-        writer.printDocLink(LinkInfoImpl.CONTEXT_MEMBER,
-            (MemberDoc) member, ((FieldDoc)member).qualifiedName(), false);
+    /**
+     * {@inheritDoc}
+     */
+    protected Content getDeprecatedLink(ProgramElementDoc member) {
+        return writer.getDocLink(LinkInfoImpl.CONTEXT_MEMBER,
+                (MemberDoc) member, ((FieldDoc)member).qualifiedName());
     }
 
-    protected void printNavSummaryLink(ClassDoc cd, boolean link) {
+    /**
+     * {@inheritDoc}
+     */
+    protected Content getNavSummaryLink(ClassDoc cd, boolean link) {
         if (link) {
-            writer.printHyperLink("", (cd == null)?
-                        "field_summary":
-                        "fields_inherited_from_class_" +
-                        configuration().getClassName(cd),
-                    configuration().getText("doclet.navField"));
+            return writer.getHyperLink("", (cd == null)?
+                "field_summary":
+                "fields_inherited_from_class_" +
+                configuration().getClassName(cd),
+                writer.getResource("doclet.navField"));
         } else {
-            writer.printText("doclet.navField");
+            return writer.getResource("doclet.navField");
         }
     }
 
-    protected void printNavDetailLink(boolean link) {
+    /**
+     * {@inheritDoc}
+     */
+    protected void addNavDetailLink(boolean link, Content liNav) {
         if (link) {
-            writer.printHyperLink("", "field_detail",
-                configuration().getText("doclet.navField"));
+            liNav.addContent(writer.getHyperLink("", "field_detail",
+                    writer.getResource("doclet.navField")));
         } else {
-            writer.printText("doclet.navField");
+            liNav.addContent(writer.getResource("doclet.navField"));
         }
     }
 }
--- a/src/share/classes/com/sun/tools/doclets/formats/html/FrameOutputWriter.java	Thu Dec 16 19:57:01 2010 -0800
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/FrameOutputWriter.java	Mon Dec 20 21:10:57 2010 -0800
@@ -25,8 +25,10 @@
 
 package com.sun.tools.doclets.formats.html;
 
+import java.io.*;
 import com.sun.tools.doclets.internal.toolkit.util.*;
-import java.io.*;
+import com.sun.tools.doclets.internal.toolkit.*;
+import com.sun.tools.doclets.formats.html.markup.*;
 
 /**
  * Generate the documentation in the Html "frame" format in the browser. The
@@ -47,6 +49,8 @@
      */
     int noOfPackages;
 
+    private final String SCROLL_YES = "yes";
+
     /**
      * Constructor to construct FrameOutputWriter object.
      *
@@ -86,82 +90,93 @@
      * as well as warning if browser is not supporting the Html frames.
      */
     protected void generateFrameFile() {
+        Content frameset = getFrameDetails();
         if (configuration.windowtitle.length() > 0) {
-            printFramesetHeader(configuration.windowtitle, configuration.notimestamp);
+            printFramesetDocument(configuration.windowtitle, configuration.notimestamp,
+                    frameset);
         } else {
-            printFramesetHeader(configuration.getText("doclet.Generated_Docs_Untitled"),
-                                configuration.notimestamp);
+            printFramesetDocument(configuration.getText("doclet.Generated_Docs_Untitled"),
+                    configuration.notimestamp, frameset);
         }
-        printFrameDetails();
-        printFrameFooter();
     }
 
     /**
-     * Generate the code for issueing the warning for a non-frame capable web
+     * Add the code for issueing the warning for a non-frame capable web
      * client. Also provide links to the non-frame version documentation.
+     *
+     * @param contentTree the content tree to which the non-frames information will be added
      */
-    protected void printFrameWarning() {
-        noFrames();
-        h2();
-        printText("doclet.Frame_Alert");
-        h2End();
-        p();
-        printText("doclet.Frame_Warning_Message");
-        br();
-        printText("doclet.Link_To");
-        printHyperLink(configuration.topFile,
-            configuration.getText("doclet.Non_Frame_Version"));
-        println("");
-        noFramesEnd();
+    protected void addFrameWarning(Content contentTree) {
+        Content noframes = new HtmlTree(HtmlTag.NOFRAMES);
+        Content noScript = HtmlTree.NOSCRIPT(
+                HtmlTree.DIV(getResource("doclet.No_Script_Message")));
+        noframes.addContent(noScript);
+        Content noframesHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
+                getResource("doclet.Frame_Alert"));
+        noframes.addContent(noframesHead);
+        Content p = HtmlTree.P(getResource("doclet.Frame_Warning_Message"));
+        noframes.addContent(p);
+        noframes.addContent(new HtmlTree(HtmlTag.BR));
+        noframes.addContent(getResource("doclet.Link_To"));
+        Content link = getHyperLink(configuration.topFile,
+                getResource("doclet.Non_Frame_Version"));
+        noframes.addContent(link);
+        contentTree.addContent(noframes);
     }
 
     /**
-     * Print the frame sizes and their contents.
+     * Get the frame sizes and their contents.
+     *
+     * @return a content tree for the frame details
      */
-    protected void printFrameDetails() {
-        // title attribute intentionally made empty so
-        // 508 tests will not flag it as missing
-        frameSet("cols=\"20%,80%\" title=\"\" onLoad=\"top.loadFrames()\"");
+    protected Content getFrameDetails() {
+        HtmlTree frameset = HtmlTree.FRAMESET("20%,80%", null, "Documentation frame",
+                "top.loadFrames()");
         if (noOfPackages <= 1) {
-            printAllClassesFrameTag();
+            addAllClassesFrameTag(frameset);
         } else if (noOfPackages > 1) {
-            frameSet("rows=\"30%,70%\" title=\"\" onLoad=\"top.loadFrames()\"");
-            printAllPackagesFrameTag();
-            printAllClassesFrameTag();
-            frameSetEnd();
+            HtmlTree leftFrameset = HtmlTree.FRAMESET(null, "30%,70%", "Left frames",
+                "top.loadFrames()");
+            addAllPackagesFrameTag(leftFrameset);
+            addAllClassesFrameTag(leftFrameset);
+            frameset.addContent(leftFrameset);
         }
-        printClassFrameTag();
-        printFrameWarning();
-        frameSetEnd();
+        addClassFrameTag(frameset);
+        addFrameWarning(frameset);
+        return frameset;
     }
 
     /**
-     * Print the FRAME tag for the frame that lists all packages
+     * Add the FRAME tag for the frame that lists all packages.
+     *
+     * @param contentTree the content tree to which the information will be added
      */
-    private void printAllPackagesFrameTag() {
-        frame("src=\"overview-frame.html\" name=\"packageListFrame\""
-            + " title=\"" + configuration.getText("doclet.All_Packages") + "\"");
+    private void addAllPackagesFrameTag(Content contentTree) {
+        HtmlTree frame = HtmlTree.FRAME("overview-frame.html", "packageListFrame",
+                configuration.getText("doclet.All_Packages"));
+        contentTree.addContent(frame);
     }
 
     /**
-     * Print the FRAME tag for the frame that lists all classes
+     * Add the FRAME tag for the frame that lists all classes.
+     *
+     * @param contentTree the content tree to which the information will be added
      */
-    private void printAllClassesFrameTag() {
-        frame("src=\"" + "allclasses-frame.html" + "\""
-            + " name=\"packageFrame\""
-            + " title=\"" + configuration.getText("doclet.All_classes_and_interfaces")
-            + "\"");
+    private void addAllClassesFrameTag(Content contentTree) {
+        HtmlTree frame = HtmlTree.FRAME("allclasses-frame.html", "packageFrame",
+                configuration.getText("doclet.All_classes_and_interfaces"));
+        contentTree.addContent(frame);
     }
 
     /**
-     * Print the FRAME tag for the frame that describes the class in detail
+     * Add the FRAME tag for the frame that describes the class in detail.
+     *
+     * @param contentTree the content tree to which the information will be added
      */
-    private void printClassFrameTag() {
-        frame("src=\"" + configuration.topFile + "\""
-            + " name=\"classFrame\""
-            + " title=\""
-            + configuration.getText("doclet.Package_class_and_interface_descriptions")
-            + "\" scrolling=\"yes\"");
+    private void addClassFrameTag(Content contentTree) {
+        HtmlTree frame = HtmlTree.FRAME(configuration.topFile, "classFrame",
+                configuration.getText("doclet.Package_class_and_interface_descriptions"),
+                SCROLL_YES);
+        contentTree.addContent(frame);
     }
-
 }
--- a/src/share/classes/com/sun/tools/doclets/formats/html/HelpWriter.java	Thu Dec 16 19:57:01 2010 -0800
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/HelpWriter.java	Mon Dec 20 21:10:57 2010 -0800
@@ -25,8 +25,10 @@
 
 package com.sun.tools.doclets.formats.html;
 
+import java.io.*;
 import com.sun.tools.doclets.internal.toolkit.util.*;
-import java.io.*;
+import com.sun.tools.doclets.internal.toolkit.*;
+import com.sun.tools.doclets.formats.html.markup.*;
 
 /**
  * Generate the Help File for the generated API documentation. The help file
@@ -72,159 +74,242 @@
      * Generate the help file contents.
      */
     protected void generateHelpFile() {
-        printHtmlHeader(configuration.getText("doclet.Window_Help_title"),
-            null, true);
-        printTop();
-        navLinks(true);  hr();
-
-        printHelpFileContents();
-
-        navLinks(false);
-        printBottom();
-        printBodyHtmlEnd();
+        String title = configuration.getText("doclet.Window_Help_title");
+        Content body = getBody(true, getWindowTitle(title));
+        addTop(body);
+        addNavLinks(true, body);
+        addHelpFileContents(body);
+        addNavLinks(false, body);
+        addBottom(body);
+        printHtmlDocument(null, true, body);
     }
 
     /**
-     * Print the help file contents from the resource file. While generating the
+     * Add the help file contents from the resource file to the content tree. While adding the
      * help file contents it also keeps track of user options. If "-notree"
-     * is used, then the "overview-tree.html" will not get generated and hence
-     * help information also will not get generated.
+     * is used, then the "overview-tree.html" will not get added and hence
+     * help information also will not get added.
+     *
+     * @param contentTree the content tree to which the help file contents will be added
      */
-    protected void printHelpFileContents() {
-        center(); h1(); printText("doclet.Help_line_1"); h1End(); centerEnd();
-        printText("doclet.Help_line_2");
+    protected void addHelpFileContents(Content contentTree) {
+        Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, false, HtmlStyle.title,
+                getResource("doclet.Help_line_1"));
+        Content div = HtmlTree.DIV(HtmlStyle.header, heading);
+        Content line2 = HtmlTree.P(HtmlStyle.subTitle,
+                getResource("doclet.Help_line_2"));
+        div.addContent(line2);
+        contentTree.addContent(div);
+        HtmlTree ul = new HtmlTree(HtmlTag.UL);
+        ul.addStyle(HtmlStyle.blockList);
         if (configuration.createoverview) {
-            h3(); printText("doclet.Overview"); h3End();
-            blockquote(); p();
-            printText("doclet.Help_line_3",
-                getHyperLink("overview-summary.html",
-                configuration.getText("doclet.Overview")));
-            blockquoteEnd();
+            Content overviewHeading = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
+                getResource("doclet.Overview"));
+            Content liOverview = HtmlTree.LI(HtmlStyle.blockList, overviewHeading);
+            Content line3 = getResource("doclet.Help_line_3",
+                    getHyperLinkString("overview-summary.html",
+                    configuration.getText("doclet.Overview")));
+            Content overviewPara = HtmlTree.P(line3);
+            liOverview.addContent(overviewPara);
+            ul.addContent(liOverview);
         }
-        h3(); printText("doclet.Package"); h3End();
-        blockquote(); p(); printText("doclet.Help_line_4");
-        ul();
-        li(); printText("doclet.Interfaces_Italic");
-        li(); printText("doclet.Classes");
-        li(); printText("doclet.Enums");
-        li(); printText("doclet.Exceptions");
-        li(); printText("doclet.Errors");
-        li(); printText("doclet.AnnotationTypes");
-        ulEnd();
-        blockquoteEnd();
-        h3(); printText("doclet.Help_line_5"); h3End();
-        blockquote(); p(); printText("doclet.Help_line_6");
-        ul();
-        li(); printText("doclet.Help_line_7");
-        li(); printText("doclet.Help_line_8");
-        li(); printText("doclet.Help_line_9");
-        li(); printText("doclet.Help_line_10");
-        li(); printText("doclet.Help_line_11");
-        li(); printText("doclet.Help_line_12");
-        p();
-        li(); printText("doclet.Nested_Class_Summary");
-        li(); printText("doclet.Field_Summary");
-        li(); printText("doclet.Constructor_Summary");
-        li(); printText("doclet.Method_Summary");
-        p();
-        li(); printText("doclet.Field_Detail");
-        li(); printText("doclet.Constructor_Detail");
-        li(); printText("doclet.Method_Detail");
-        ulEnd();
-        printText("doclet.Help_line_13");
-        blockquoteEnd();
-
+        Content packageHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
+                getResource("doclet.Package"));
+        Content liPackage = HtmlTree.LI(HtmlStyle.blockList, packageHead);
+        Content line4 = getResource("doclet.Help_line_4");
+        Content packagePara = HtmlTree.P(line4);
+        liPackage.addContent(packagePara);
+        HtmlTree ulPackage = new HtmlTree(HtmlTag.UL);
+        ulPackage.addContent(HtmlTree.LI(
+                getResource("doclet.Interfaces_Italic")));
+        ulPackage.addContent(HtmlTree.LI(
+                getResource("doclet.Classes")));
+        ulPackage.addContent(HtmlTree.LI(
+                getResource("doclet.Enums")));
+        ulPackage.addContent(HtmlTree.LI(
+                getResource("doclet.Exceptions")));
+        ulPackage.addContent(HtmlTree.LI(
+                getResource("doclet.Errors")));
+        ulPackage.addContent(HtmlTree.LI(
+                getResource("doclet.AnnotationTypes")));
+        liPackage.addContent(ulPackage);
+        ul.addContent(liPackage);
+        Content classHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
+                getResource("doclet.Help_line_5"));
+        Content liClass = HtmlTree.LI(HtmlStyle.blockList, classHead);
+        Content line6 = getResource("doclet.Help_line_6");
+        Content classPara = HtmlTree.P(line6);
+        liClass.addContent(classPara);
+        HtmlTree ul1 = new HtmlTree(HtmlTag.UL);
+        ul1.addContent(HtmlTree.LI(
+                getResource("doclet.Help_line_7")));
+        ul1.addContent(HtmlTree.LI(
+                getResource("doclet.Help_line_8")));
+        ul1.addContent(HtmlTree.LI(
+                getResource("doclet.Help_line_9")));
+        ul1.addContent(HtmlTree.LI(
+                getResource("doclet.Help_line_10")));
+        ul1.addContent(HtmlTree.LI(
+                getResource("doclet.Help_line_11")));
+        ul1.addContent(HtmlTree.LI(
+                getResource("doclet.Help_line_12")));
+        liClass.addContent(ul1);
+        HtmlTree ul2 = new HtmlTree(HtmlTag.UL);
+        ul2.addContent(HtmlTree.LI(
+                getResource("doclet.Nested_Class_Summary")));
+        ul2.addContent(HtmlTree.LI(
+                getResource("doclet.Field_Summary")));
+        ul2.addContent(HtmlTree.LI(
+                getResource("doclet.Constructor_Summary")));
+        ul2.addContent(HtmlTree.LI(
+                getResource("doclet.Method_Summary")));
+        liClass.addContent(ul2);
+        HtmlTree ul3 = new HtmlTree(HtmlTag.UL);
+        ul3.addContent(HtmlTree.LI(
+                getResource("doclet.Field_Detail")));
+        ul3.addContent(HtmlTree.LI(
+                getResource("doclet.Constructor_Detail")));
+        ul3.addContent(HtmlTree.LI(
+                getResource("doclet.Method_Detail")));
+        liClass.addContent(ul3);
+        Content line13 = getResource("doclet.Help_line_13");
+        Content para = HtmlTree.P(line13);
+        liClass.addContent(para);
+        ul.addContent(liClass);
         //Annotation Types
-        blockquoteEnd();
-        h3(); printText("doclet.AnnotationType"); h3End();
-        blockquote(); p(); printText("doclet.Help_annotation_type_line_1");
-        ul();
-        li(); printText("doclet.Help_annotation_type_line_2");
-        li(); printText("doclet.Help_annotation_type_line_3");
-        li(); printText("doclet.Annotation_Type_Required_Member_Summary");
-        li(); printText("doclet.Annotation_Type_Optional_Member_Summary");
-        li(); printText("doclet.Annotation_Type_Member_Detail");
-        ulEnd();
-        blockquoteEnd();
-
+        Content aHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
+                getResource("doclet.AnnotationType"));
+        Content liAnnotation = HtmlTree.LI(HtmlStyle.blockList, aHead);
+        Content aline1 = getResource("doclet.Help_annotation_type_line_1");
+        Content aPara = HtmlTree.P(aline1);
+        liAnnotation.addContent(aPara);
+        HtmlTree aul = new HtmlTree(HtmlTag.UL);
+        aul.addContent(HtmlTree.LI(
+                getResource("doclet.Help_annotation_type_line_2")));
+        aul.addContent(HtmlTree.LI(
+                getResource("doclet.Help_annotation_type_line_3")));
+        aul.addContent(HtmlTree.LI(
+                getResource("doclet.Annotation_Type_Required_Member_Summary")));
+        aul.addContent(HtmlTree.LI(
+                getResource("doclet.Annotation_Type_Optional_Member_Summary")));
+        aul.addContent(HtmlTree.LI(
+                getResource("doclet.Annotation_Type_Member_Detail")));
+        liAnnotation.addContent(aul);
+        ul.addContent(liAnnotation);
         //Enums
-        blockquoteEnd();
-        h3(); printText("doclet.Enum"); h3End();
-        blockquote(); p(); printText("doclet.Help_enum_line_1");
-        ul();
-        li(); printText("doclet.Help_enum_line_2");
-        li(); printText("doclet.Help_enum_line_3");
-        li(); printText("doclet.Enum_Constant_Summary");
-        li(); printText("doclet.Enum_Constant_Detail");
-        ulEnd();
-        blockquoteEnd();
-
+        Content enumHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
+                getResource("doclet.Enum"));
+        Content liEnum = HtmlTree.LI(HtmlStyle.blockList, enumHead);
+        Content eline1 = getResource("doclet.Help_enum_line_1");
+        Content enumPara = HtmlTree.P(eline1);
+        liEnum.addContent(enumPara);
+        HtmlTree eul = new HtmlTree(HtmlTag.UL);
+        eul.addContent(HtmlTree.LI(
+                getResource("doclet.Help_enum_line_2")));
+        eul.addContent(HtmlTree.LI(
+                getResource("doclet.Help_enum_line_3")));
+        eul.addContent(HtmlTree.LI(
+                getResource("doclet.Enum_Constant_Summary")));
+        eul.addContent(HtmlTree.LI(
+                getResource("doclet.Enum_Constant_Detail")));
+        liEnum.addContent(eul);
+        ul.addContent(liEnum);
         if (configuration.classuse) {
-            h3(); printText("doclet.Help_line_14"); h3End();
-            blockquote();
-            printText("doclet.Help_line_15");
-            blockquoteEnd();
+            Content useHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
+                    getResource("doclet.Help_line_14"));
+            Content liUse = HtmlTree.LI(HtmlStyle.blockList, useHead);
+            Content line15 = getResource("doclet.Help_line_15");
+            Content usePara = HtmlTree.P(line15);
+            liUse.addContent(usePara);
+            ul.addContent(liUse);
         }
         if (configuration.createtree) {
-            h3(); printText("doclet.Help_line_16"); h3End();
-            blockquote();
-            printText("doclet.Help_line_17_with_tree_link",
-                 getHyperLink("overview-tree.html",
-                 configuration.getText("doclet.Class_Hierarchy")));
-            ul();
-            li(); printText("doclet.Help_line_18");
-            li(); printText("doclet.Help_line_19");
-            ulEnd();
-            blockquoteEnd();
+            Content treeHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
+                    getResource("doclet.Help_line_16"));
+            Content liTree = HtmlTree.LI(HtmlStyle.blockList, treeHead);
+            Content line17 = getResource("doclet.Help_line_17_with_tree_link",
+                    getHyperLinkString("overview-tree.html",
+                    configuration.getText("doclet.Class_Hierarchy")));
+            Content treePara = HtmlTree.P(line17);
+            liTree.addContent(treePara);
+            HtmlTree tul = new HtmlTree(HtmlTag.UL);
+            tul.addContent(HtmlTree.LI(
+                    getResource("doclet.Help_line_18")));
+            tul.addContent(HtmlTree.LI(
+                    getResource("doclet.Help_line_19")));
+            liTree.addContent(tul);
+            ul.addContent(liTree);
         }
         if (!(configuration.nodeprecatedlist ||
                   configuration.nodeprecated)) {
-            h3(); printText("doclet.Deprecated_API"); h3End();
-            blockquote();
-            printText("doclet.Help_line_20_with_deprecated_api_link",
-                getHyperLink("deprecated-list.html",
-                configuration.getText("doclet.Deprecated_API")));
-            blockquoteEnd();
+            Content dHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
+                    getResource("doclet.Deprecated_API"));
+            Content liDeprecated = HtmlTree.LI(HtmlStyle.blockList, dHead);
+            Content line20 = getResource("doclet.Help_line_20_with_deprecated_api_link",
+                    getHyperLinkString("deprecated-list.html",
+                    configuration.getText("doclet.Deprecated_API")));
+            Content dPara = HtmlTree.P(line20);
+            liDeprecated.addContent(dPara);
+            ul.addContent(liDeprecated);
         }
         if (configuration.createindex) {
             String indexlink;
             if (configuration.splitindex) {
-                indexlink = getHyperLink("index-files/index-1.html",
-                    configuration.getText("doclet.Index"));
+                indexlink = getHyperLinkString("index-files/index-1.html",
+                        configuration.getText("doclet.Index"));
             } else {
-                indexlink = getHyperLink("index-all.html",
-                    configuration.getText("doclet.Index"));
+                indexlink = getHyperLinkString("index-all.html",
+                        configuration.getText("doclet.Index"));
             }
-            h3(); printText("doclet.Help_line_21"); h3End();
-            blockquote();
-            printText("doclet.Help_line_22", indexlink);
-            blockquoteEnd();
+            Content indexHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
+                    getResource("doclet.Help_line_21"));
+            Content liIndex = HtmlTree.LI(HtmlStyle.blockList, indexHead);
+            Content line22 = getResource("doclet.Help_line_22", indexlink);
+            Content indexPara = HtmlTree.P(line22);
+            liIndex.addContent(indexPara);
+            ul.addContent(liIndex);
         }
-        h3(); printText("doclet.Help_line_23"); h3End();
-        printText("doclet.Help_line_24");
-        h3(); printText("doclet.Help_line_25"); h3End();
-        printText("doclet.Help_line_26"); p();
-
-        h3(); printText("doclet.Serialized_Form"); h3End();
-        printText("doclet.Help_line_27"); p();
-
-        h3(); printText("doclet.Constants_Summary"); h3End();
-        printText("doclet.Help_line_28"); p();
-
-        font("-1"); em();
-        printText("doclet.Help_line_29");
-        emEnd(); fontEnd(); br();
-        hr();
+        Content prevHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
+                getResource("doclet.Help_line_23"));
+        Content liPrev = HtmlTree.LI(HtmlStyle.blockList, prevHead);
+        Content line24 = getResource("doclet.Help_line_24");
+        Content prevPara = HtmlTree.P(line24);
+        liPrev.addContent(prevPara);
+        ul.addContent(liPrev);
+        Content frameHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
+                getResource("doclet.Help_line_25"));
+        Content liFrame = HtmlTree.LI(HtmlStyle.blockList, frameHead);
+        Content line26 = getResource("doclet.Help_line_26");
+        Content framePara = HtmlTree.P(line26);
+        liFrame.addContent(framePara);
+        ul.addContent(liFrame);
+        Content sHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
+                getResource("doclet.Serialized_Form"));
+        Content liSerial = HtmlTree.LI(HtmlStyle.blockList, sHead);
+        Content line27 = getResource("doclet.Help_line_27");
+        Content serialPara = HtmlTree.P(line27);
+        liSerial.addContent(serialPara);
+        ul.addContent(liSerial);
+        Content constHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
+                getResource("doclet.Constants_Summary"));
+        Content liConst = HtmlTree.LI(HtmlStyle.blockList, constHead);
+        Content line28 = getResource("doclet.Help_line_28");
+        Content constPara = HtmlTree.P(line28);
+        liConst.addContent(constPara);
+        ul.addContent(liConst);
+        Content divContent = HtmlTree.DIV(HtmlStyle.contentContainer, ul);
+        Content line29 = HtmlTree.EM(getResource("doclet.Help_line_29"));
+        divContent.addContent(line29);
+        contentTree.addContent(divContent);
     }
 
     /**
-     * Highlight the word "Help" in the navigation bar as this is the help file.
+     * Get the help label.
+     *
+     * @return a content tree for the help label
      */
-    protected void navLinkHelp() {
-        navCellRevStart();
-        fontStyle("NavBarFont1Rev");
-        strongText("doclet.Help");
-        fontEnd();
-        navCellEnd();
+    protected Content getNavLinkHelp() {
+        Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, helpLabel);
+        return li;
     }
 }
--- a/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDoclet.java	Thu Dec 16 19:57:01 2010 -0800
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDoclet.java	Mon Dec 20 21:10:57 2010 -0800
@@ -144,8 +144,12 @@
             !configuration.nohelp) {
             HelpWriter.generate(configuration);
         }
+        // If a stylesheet file is not specified, copy the default stylesheet
+        // and replace newline with platform-specific newline.
         if (configuration.stylesheetfile.length() == 0) {
-            StylesheetWriter.generate(configuration);
+            Util.copyFile(configuration, "stylesheet.css", Util.RESOURCESDIR,
+                    (configdestdir.isEmpty()) ?
+                        System.getProperty("user.dir") : configdestdir, false, true);
         }
     }
 
--- a/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java	Thu Dec 16 19:57:01 2010 -0800
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java	Mon Dec 20 21:10:57 2010 -0800
@@ -88,6 +88,11 @@
     public ConfigurationImpl configuration;
 
     /**
+     * To check whether annotation heading is printed or not.
+     */
+    protected boolean printedAnnotationHeading = false;
+
+    /**
      * Constructor to construct the HtmlStandardWriter object.
      *
      * @param filename File to be generated.
@@ -169,7 +174,7 @@
             // Append slash if next character is not a slash
             if (relativepathNoSlash.length() > 0 && previndex < htmlstr.length()
                     && htmlstr.charAt(previndex) != '/') {
-                buf.append(DirectoryManager.URL_FILE_SEPERATOR);
+                buf.append(DirectoryManager.URL_FILE_SEPARATOR);
             }
         }
         return buf.toString();
@@ -192,17 +197,47 @@
         println("  <!--");
         println("  if(window==top) {");
         println("    document.writeln('"
-            + getHyperLink(link, where, label, strong, "", "", target) + "');");
+            + getHyperLinkString(link, where, label, strong, "", "", target) + "');");
         println("  }");
         println("  //-->");
         scriptEnd();
         noScript();
-        println("  " + getHyperLink(link, where, label, strong, "", "", target));
+        println("  " + getHyperLinkString(link, where, label, strong, "", "", target));
         noScriptEnd();
         println(DocletConstants.NL);
     }
 
-    private void printMethodInfo(MethodDoc method) {
+    /**
+     * Get the script to show or hide the All classes link.
+     *
+     * @param id id of the element to show or hide
+     * @return a content tree for the script
+     */
+    public Content getAllClassesLinkScript(String id) {
+        HtmlTree script = new HtmlTree(HtmlTag.SCRIPT);
+        script.addAttr(HtmlAttr.TYPE, "text/javascript");
+        String scriptCode = "<!--" + DocletConstants.NL +
+                "  allClassesLink = document.getElementById(\"" + id + "\");" + DocletConstants.NL +
+                "  if(window==top) {" + DocletConstants.NL +
+                "    allClassesLink.style.display = \"block\";" + DocletConstants.NL +
+                "  }" + DocletConstants.NL +
+                "  else {" + DocletConstants.NL +
+                "    allClassesLink.style.display = \"none\";" + DocletConstants.NL +
+                "  }" + DocletConstants.NL +
+                "  //-->" + DocletConstants.NL;
+        Content scriptContent = new RawHtml(scriptCode);
+        script.addContent(scriptContent);
+        Content div = HtmlTree.DIV(script);
+        return div;
+    }
+
+    /**
+     * Add method information.
+     *
+     * @param method the method to be documented
+     * @param dl the content tree to which the method information will be added
+     */
+    private void addMethodInfo(MethodDoc method, Content dl) {
         ClassDoc[] intfacs = method.containingClass().interfaces();
         MethodDoc overriddenMethod = method.overriddenMethod();
         // Check whether there is any implementation or overridden info to be
@@ -211,46 +246,38 @@
         if ((intfacs.length > 0 &&
                 new ImplementedMethods(method, this.configuration).build().length > 0) ||
                 overriddenMethod != null) {
-            printMemberDetailsListStartTag();
-            dd();
-            printTagsInfoHeader();
-            MethodWriterImpl.printImplementsInfo(this, method);
+            MethodWriterImpl.addImplementsInfo(this, method, dl);
             if (overriddenMethod != null) {
-                MethodWriterImpl.printOverridden(this,
-                    method.overriddenType(), overriddenMethod);
+                MethodWriterImpl.addOverridden(this,
+                        method.overriddenType(), overriddenMethod, dl);
             }
-            printTagsInfoFooter();
-            ddEnd();
         }
     }
 
-    protected void printTags(Doc doc) {
-        if(configuration.nocomment){
+    /**
+     * Adds the tags information.
+     *
+     * @param doc the doc for which the tags will be generated
+     * @param htmltree the documentation tree to which the tags will be added
+     */
+    protected void addTagsInfo(Doc doc, Content htmltree) {
+        if (configuration.nocomment) {
             return;
         }
+        Content dl = new HtmlTree(HtmlTag.DL);
         if (doc instanceof MethodDoc) {
-            printMethodInfo((MethodDoc) doc);
+            addMethodInfo((MethodDoc) doc, dl);
         }
         TagletOutputImpl output = new TagletOutputImpl("");
         TagletWriter.genTagOuput(configuration.tagletManager, doc,
             configuration.tagletManager.getCustomTags(doc),
                 getTagletWriterInstance(false), output);
         String outputString = output.toString().trim();
-        // For RootDoc, ClassDoc and PackageDoc, this section is not the
-        // definition description but the start of definition list.
         if (!outputString.isEmpty()) {
-            if (!(doc instanceof RootDoc || doc instanceof ClassDoc ||
-                    doc instanceof PackageDoc)) {
-                printMemberDetailsListStartTag();
-                dd();
-            }
-            printTagsInfoHeader();
-            print(outputString);
-            printTagsInfoFooter();
-            if (!(doc instanceof RootDoc || doc instanceof ClassDoc ||
-                    doc instanceof PackageDoc))
-                ddEnd();
+            Content resultString = new RawHtml(outputString);
+            dl.addContent(resultString);
         }
+        htmltree.addContent(dl);
     }
 
     /**
@@ -286,17 +313,16 @@
     }
 
     /**
-     * Print Package link, with target frame.
+     * Get Package link, with target frame.
      *
-     * @param pd The link will be to the "package-summary.html" page for this
-     * package.
-     * @param target Name of the target frame.
-     * @param label Tag for the link.
+     * @param pd The link will be to the "package-summary.html" page for this package
+     * @param target name of the target frame
+     * @param label tag for the link
+     * @return a content for the target package link
      */
-    public void printTargetPackageLink(PackageDoc pd, String target,
-        String label) {
-        print(getHyperLink(pathString(pd, "package-summary.html"), "", label,
-            false, "", "", target));
+    public Content getTargetPackageLink(PackageDoc pd, String target,
+            Content label) {
+        return getHyperLink(pathString(pd, "package-summary.html"), "", label, "", target);
     }
 
     /**
@@ -360,6 +386,64 @@
     }
 
     /**
+     * Generates the HTML document tree and prints it out.
+     *
+     * @param metakeywords Array of String keywords for META tag. Each element
+     *                     of the array is assigned to a separate META tag.
+     *                     Pass in null for no array
+     * @param includeScript true if printing windowtitle script
+     *                      false for files that appear in the left-hand frames
+     * @param body the body htmltree to be included in the document
+     */
+    public void printHtmlDocument(String[] metakeywords, boolean includeScript,
+            Content body) {
+        Content htmlDocType = DocType.Transitional();
+        Content htmlComment = new Comment(configuration.getText("doclet.New_Page"));
+        Content head = new HtmlTree(HtmlTag.HEAD);
+        if (!configuration.notimestamp) {
+            Content headComment = new Comment("Generated by javadoc (version " +
+                    ConfigurationImpl.BUILD_DATE + ") on " + today());
+            head.addContent(headComment);
+        }
+        if (configuration.charset.length() > 0) {
+            Content meta = HtmlTree.META("Content-Type", "text/html",
+                    configuration.charset);
+            head.addContent(meta);
+        }
+        head.addContent(getTitle());
+        if (!configuration.notimestamp) {
+            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+            Content meta = HtmlTree.META("date", dateFormat.format(new Date()));
+            head.addContent(meta);
+        }
+        if (metakeywords != null) {
+            for (int i=0; i < metakeywords.length; i++) {
+                Content meta = HtmlTree.META("keywords", metakeywords[i]);
+                head.addContent(meta);
+            }
+        }
+        head.addContent(getStyleSheetProperties());
+        Content htmlTree = HtmlTree.HTML(configuration.getLocale().getLanguage(),
+                head, body);
+        Content htmlDocument = new HtmlDocument(htmlDocType,
+                htmlComment, htmlTree);
+        print(htmlDocument.toString());
+    }
+
+    /**
+     * Get the window title.
+     *
+     * @param title the title string to construct the complete window title
+     * @return the window title string
+     */
+    public String getWindowTitle(String title) {
+        if (configuration.windowtitle.length() > 0) {
+            title += " (" + configuration.windowtitle  + ")";
+        }
+        return title;
+    }
+
+    /**
      * Print user specified header and the footer.
      *
      * @param header if true print the user provided header else print the
@@ -380,6 +464,28 @@
     }
 
     /**
+     * Get user specified header and the footer.
+     *
+     * @param header if true print the user provided header else print the
+     * user provided footer.
+     */
+    public Content getUserHeaderFooter(boolean header) {
+        String content;
+        if (header) {
+            content = replaceDocRootDir(configuration.header);
+        } else {
+            if (configuration.footer.length() != 0) {
+                content = replaceDocRootDir(configuration.footer);
+            } else {
+                content = replaceDocRootDir(configuration.header);
+            }
+        }
+        Content rawContent = new RawHtml(content);
+        Content em = HtmlTree.EM(rawContent);
+        return em;
+    }
+
+    /**
      * Print the user specified top.
      */
     public void printTop() {
@@ -388,6 +494,16 @@
     }
 
     /**
+     * Adds the user specified top.
+     *
+     * @param body the content tree to which user specified top will be added
+     */
+    public void addTop(Content body) {
+        Content top = new RawHtml(replaceDocRootDir(configuration.top));
+        body.addContent(top);
+    }
+
+    /**
      * Print the user specified bottom.
      */
     public void printBottom() {
@@ -396,6 +512,18 @@
     }
 
     /**
+     * Adds the user specified bottom.
+     *
+     * @param body the content tree to which user specified bottom will be added
+     */
+    public void addBottom(Content body) {
+        Content bottom = new RawHtml(replaceDocRootDir(configuration.bottom));
+        Content small = HtmlTree.SMALL(bottom);
+        Content p = HtmlTree.P(HtmlStyle.legalCopy, small);
+        body.addContent(p);
+    }
+
+    /**
      * Print the navigation bar for the Html page at the top and and the bottom.
      *
      * @param header If true print navigation bar at the top of the page else
@@ -408,13 +536,13 @@
                 println(DocletConstants.NL + "<!-- ========= START OF TOP NAVBAR ======= -->");
                 anchor("navbar_top");
                 println();
-                print(getHyperLink("", "skip-navbar_top", "", false, "",
+                print(getHyperLinkString("", "skip-navbar_top", "", false, "",
                     configuration.getText("doclet.Skip_navigation_links"), ""));
             } else {
                 println(DocletConstants.NL + "<!-- ======= START OF BOTTOM NAVBAR ====== -->");
                 anchor("navbar_bottom");
                 println();
-                print(getHyperLink("", "skip-navbar_bottom", "", false, "",
+                print(getHyperLinkString("", "skip-navbar_bottom", "", false, "",
                     configuration.getText("doclet.Skip_navigation_links"), ""));
             }
             table(0, "100%", 1, 0);
@@ -518,6 +646,97 @@
     }
 
     /**
+     * Adds the navigation bar for the Html page at the top and and the bottom.
+     *
+     * @param header If true print navigation bar at the top of the page else
+     * @param body the HtmlTree to which the nav links will be added
+     */
+    protected void addNavLinks(boolean header, Content body) {
+        if (!configuration.nonavbar) {
+            String allClassesId = "allclasses_";
+            HtmlTree navDiv = new HtmlTree(HtmlTag.DIV);
+            if (header) {
+                body.addContent(HtmlConstants.START_OF_TOP_NAVBAR);
+                navDiv.addStyle(HtmlStyle.topNav);
+                allClassesId += "navbar_top";
+                Content a = getMarkerAnchor("navbar_top");
+                navDiv.addContent(a);
+                Content skipLinkContent = getHyperLink("",
+                        "skip-navbar_top", HtmlTree.EMPTY, configuration.getText(
+                        "doclet.Skip_navigation_links"), "");
+                navDiv.addContent(skipLinkContent);
+            } else {
+                body.addContent(HtmlConstants.START_OF_BOTTOM_NAVBAR);
+                navDiv.addStyle(HtmlStyle.bottomNav);
+                allClassesId += "navbar_bottom";
+                Content a = getMarkerAnchor("navbar_bottom");
+                navDiv.addContent(a);
+                Content skipLinkContent = getHyperLink("",
+                        "skip-navbar_bottom", HtmlTree.EMPTY, configuration.getText(
+                        "doclet.Skip_navigation_links"), "");
+                navDiv.addContent(skipLinkContent);
+            }
+            if (header) {
+                navDiv.addContent(getMarkerAnchor("navbar_top_firstrow"));
+            } else {
+                navDiv.addContent(getMarkerAnchor("navbar_bottom_firstrow"));
+            }
+            HtmlTree navList = new HtmlTree(HtmlTag.UL);
+            navList.addStyle(HtmlStyle.navList);
+            navList.addAttr(HtmlAttr.TITLE, "Navigation");
+            if (configuration.createoverview) {
+                navList.addContent(getNavLinkContents());
+            }
+            if (configuration.packages.length == 1) {
+                navList.addContent(getNavLinkPackage(configuration.packages[0]));
+            } else if (configuration.packages.length > 1) {
+                navList.addContent(getNavLinkPackage());
+            }
+            navList.addContent(getNavLinkClass());
+            if(configuration.classuse) {
+                navList.addContent(getNavLinkClassUse());
+            }
+            if(configuration.createtree) {
+                navList.addContent(getNavLinkTree());
+            }
+            if(!(configuration.nodeprecated ||
+                     configuration.nodeprecatedlist)) {
+                navList.addContent(getNavLinkDeprecated());
+            }
+            if(configuration.createindex) {
+                navList.addContent(getNavLinkIndex());
+            }
+            if (!configuration.nohelp) {
+                navList.addContent(getNavLinkHelp());
+            }
+            navDiv.addContent(navList);
+            Content aboutDiv = HtmlTree.DIV(HtmlStyle.aboutLanguage, getUserHeaderFooter(header));
+            navDiv.addContent(aboutDiv);
+            body.addContent(navDiv);
+            Content ulNav = HtmlTree.UL(HtmlStyle.navList, getNavLinkPrevious());
+            ulNav.addContent(getNavLinkNext());
+            Content subDiv = HtmlTree.DIV(HtmlStyle.subNav, ulNav);
+            Content ulFrames = HtmlTree.UL(HtmlStyle.navList, getNavShowLists());
+            ulFrames.addContent(getNavHideLists(filename));
+            subDiv.addContent(ulFrames);
+            HtmlTree ulAllClasses = HtmlTree.UL(HtmlStyle.navList, getNavLinkClassIndex());
+            ulAllClasses.addAttr(HtmlAttr.ID, allClassesId.toString());
+            subDiv.addContent(ulAllClasses);
+            subDiv.addContent(getAllClassesLinkScript(allClassesId.toString()));
+            addSummaryDetailLinks(subDiv);
+            if (header) {
+                subDiv.addContent(getMarkerAnchor("skip-navbar_top"));
+                body.addContent(subDiv);
+                body.addContent(HtmlConstants.END_OF_TOP_NAVBAR);
+            } else {
+                subDiv.addContent(getMarkerAnchor("skip-navbar_bottom"));
+                body.addContent(subDiv);
+                body.addContent(HtmlConstants.END_OF_BOTTOM_NAVBAR);
+            }
+        }
+    }
+
+    /**
      * Print the word "NEXT" to indicate that no link is available.  Override
      * this method to customize next link.
      */
@@ -526,6 +745,16 @@
     }
 
     /**
+     * Get the word "NEXT" to indicate that no link is available.  Override
+     * this method to customize next link.
+     *
+     * @return a content tree for the link
+     */
+    protected Content getNavLinkNext() {
+        return getNavLinkNext(null);
+    }
+
+    /**
      * Print the word "PREV" to indicate that no link is available.  Override
      * this method to customize prev link.
      */
@@ -534,12 +763,28 @@
     }
 
     /**
+     * Get the word "PREV" to indicate that no link is available.  Override
+     * this method to customize prev link.
+     *
+     * @return a content tree for the link
+     */
+    protected Content getNavLinkPrevious() {
+        return getNavLinkPrevious(null);
+    }
+
+    /**
      * Do nothing. This is the default method.
      */
     protected void printSummaryDetailLinks() {
     }
 
     /**
+     * Do nothing. This is the default method.
+     */
+    protected void addSummaryDetailLinks(Content navDiv) {
+    }
+
+    /**
      * Print link to the "overview-summary.html" page.
      */
     protected void navLinkContents() {
@@ -550,6 +795,18 @@
     }
 
     /**
+     * Get link to the "overview-summary.html" page.
+     *
+     * @return a content tree for the link
+     */
+    protected Content getNavLinkContents() {
+        Content linkContent = getHyperLink(relativePath +
+                "overview-summary.html", "", overviewLabel, "", "");
+        Content li = HtmlTree.LI(linkContent);
+        return li;
+    }
+
+    /**
      * Description for a cell in the navigation bar.
      */
     protected void navCellStart() {
@@ -590,6 +847,19 @@
     }
 
     /**
+     * Get link to the "package-summary.html" page for the package passed.
+     *
+     * @param pkg Package to which link will be generated
+     * @return a content tree for the link
+     */
+    protected Content getNavLinkPackage(PackageDoc pkg) {
+        Content linkContent = getPackageLink(pkg,
+                packageLabel);
+        Content li = HtmlTree.LI(linkContent);
+        return li;
+    }
+
+    /**
      * Print the word "Package" in the navigation bar cell, to indicate that
      * link is not available here.
      */
@@ -602,6 +872,16 @@
     }
 
     /**
+     * Get the word "Package" , to indicate that link is not available here.
+     *
+     * @return a content tree for the link
+     */
+    protected Content getNavLinkPackage() {
+        Content li = HtmlTree.LI(packageLabel);
+        return li;
+    }
+
+    /**
      * Print the word "Use" in the navigation bar cell, to indicate that link
      * is not available.
      */
@@ -614,6 +894,16 @@
     }
 
     /**
+     * Get the word "Use", to indicate that link is not available.
+     *
+     * @return a content tree for the link
+     */
+    protected Content getNavLinkClassUse() {
+        Content li = HtmlTree.LI(useLabel);
+        return li;
+    }
+
+    /**
      * Print link for previous file.
      *
      * @param prev File name for the prev link.
@@ -628,6 +918,22 @@
     }
 
     /**
+     * Get link for previous file.
+     *
+     * @param prev File name for the prev link
+     * @return a content tree for the link
+     */
+    public Content getNavLinkPrevious(String prev) {
+        Content li;
+        if (prev != null) {
+            li = HtmlTree.LI(getHyperLink(prev, "", prevLabel, "", ""));
+        }
+        else
+            li = HtmlTree.LI(prevLabel);
+        return li;
+    }
+
+    /**
      * Print link for next file.  If next is null, just print the label
      * without linking it anywhere.
      *
@@ -643,16 +949,46 @@
     }
 
     /**
+     * Get link for next file.  If next is null, just print the label
+     * without linking it anywhere.
+     *
+     * @param next File name for the next link
+     * @return a content tree for the link
+     */
+    public Content getNavLinkNext(String next) {
+        Content li;
+        if (next != null) {
+            li = HtmlTree.LI(getHyperLink(next, "", nextLabel, "", ""));
+        }
+        else
+            li = HtmlTree.LI(nextLabel);
+        return li;
+    }
+
+    /**
      * Print "FRAMES" link, to switch to the frame version of the output.
      *
      * @param link File to be linked, "index.html".
      */
     protected void navShowLists(String link) {
-        print(getHyperLink(link + "?" + path + filename, "",
+        print(getHyperLinkString(link + "?" + path + filename, "",
             configuration.getText("doclet.FRAMES"), true, "", "", "_top"));
     }
 
     /**
+     * Get "FRAMES" link, to switch to the frame version of the output.
+     *
+     * @param link File to be linked, "index.html"
+     * @return a content tree for the link
+     */
+    protected Content getNavShowLists(String link) {
+        Content framesContent = getHyperLink(link + "?" + path +
+                filename, "", framesLabel, "", "_top");
+        Content li = HtmlTree.LI(framesContent);
+        return li;
+    }
+
+    /**
      * Print "FRAMES" link, to switch to the frame version of the output.
      */
     protected void navShowLists() {
@@ -660,16 +996,37 @@
     }
 
     /**
+     * Get "FRAMES" link, to switch to the frame version of the output.
+     *
+     * @return a content tree for the link
+     */
+    protected Content getNavShowLists() {
+        return getNavShowLists(relativePath + "index.html");
+    }
+
+    /**
      * Print "NO FRAMES" link, to switch to the non-frame version of the output.
      *
      * @param link File to be linked.
      */
     protected void navHideLists(String link) {
-        print(getHyperLink(link, "", configuration.getText("doclet.NO_FRAMES"),
+        print(getHyperLinkString(link, "", configuration.getText("doclet.NO_FRAMES"),
             true, "", "", "_top"));
     }
 
     /**
+     * Get "NO FRAMES" link, to switch to the non-frame version of the output.
+     *
+     * @param link File to be linked
+     * @return a content tree for the link
+     */
+    protected Content getNavHideLists(String link) {
+        Content noFramesContent = getHyperLink(link, "", noframesLabel, "", "_top");
+        Content li = HtmlTree.LI(noFramesContent);
+        return li;
+    }
+
+    /**
      * Print "Tree" link in the navigation bar. If there is only one package
      * specified on the command line, then the "Tree" link will be to the
      * only "package-tree.html" file otherwise it will be to the
@@ -689,10 +1046,39 @@
     }
 
     /**
-     * Print "Tree" link to the "overview-tree.html" file.
+     * Get "Tree" link in the navigation bar. If there is only one package
+     * specified on the command line, then the "Tree" link will be to the
+     * only "package-tree.html" file otherwise it will be to the
+     * "overview-tree.html" file.
+     *
+     * @return a content tree for the link
      */
-    protected void navLinkMainTree(String label) {
-        printHyperLink(relativePath + "overview-tree.html", label);
+    protected Content getNavLinkTree() {
+        Content treeLinkContent;
+        PackageDoc[] packages = configuration.root.specifiedPackages();
+        if (packages.length == 1 && configuration.root.specifiedClasses().length == 0) {
+            treeLinkContent = getHyperLink(pathString(packages[0],
+                    "package-tree.html"), "", treeLabel,
+                    "", "");
+        } else {
+            treeLinkContent = getHyperLink(relativePath + "overview-tree.html",
+                    "", treeLabel, "", "");
+        }
+        Content li = HtmlTree.LI(treeLinkContent);
+        return li;
+    }
+
+    /**
+     * Get the overview tree link for the main tree.
+     *
+     * @param label the label for the link
+     * @return a content tree for the link
+     */
+    protected Content getNavLinkMainTree(String label) {
+        Content mainTreeContent = getHyperLink(relativePath + "overview-tree.html",
+                new StringContent(label));
+        Content li = HtmlTree.LI(mainTreeContent);
+        return li;
     }
 
     /**
@@ -708,6 +1094,16 @@
     }
 
     /**
+     * Get the word "Class", to indicate that class link is not available.
+     *
+     * @return a content tree for the link
+     */
+    protected Content getNavLinkClass() {
+        Content li = HtmlTree.LI(classLabel);
+        return li;
+    }
+
+    /**
      * Print "Deprecated" API link in the navigation bar.
      */
     protected void navLinkDeprecated() {
@@ -718,6 +1114,18 @@
     }
 
     /**
+     * Get "Deprecated" API link in the navigation bar.
+     *
+     * @return a content tree for the link
+     */
+    protected Content getNavLinkDeprecated() {
+        Content linkContent = getHyperLink(relativePath +
+                "deprecated-list.html", "", deprecatedLabel, "", "");
+        Content li = HtmlTree.LI(linkContent);
+        return li;
+    }
+
+    /**
      * Print link for generated index. If the user has used "-splitindex"
      * command line option, then link to file "index-files/index-1.html" is
      * generated otherwise link to file "index-all.html" is generated.
@@ -727,6 +1135,21 @@
                 AllClassesFrameWriter.OUTPUT_FILE_NAME_NOFRAMES,
             "", "", configuration.getText("doclet.All_Classes"), true);
     }
+
+    /**
+     * Get link for generated index. If the user has used "-splitindex"
+     * command line option, then link to file "index-files/index-1.html" is
+     * generated otherwise link to file "index-all.html" is generated.
+     *
+     * @return a content tree for the link
+     */
+    protected Content getNavLinkClassIndex() {
+        Content allClassesContent = getHyperLink(relativePath +
+                AllClassesFrameWriter.OUTPUT_FILE_NAME_NOFRAMES, "",
+                allclassesLabel, "", "");
+        Content li = HtmlTree.LI(allClassesContent);
+        return li;
+    }
     /**
      * Print link for generated class index.
      */
@@ -743,6 +1166,20 @@
     }
 
     /**
+     * Get link for generated class index.
+     *
+     * @return a content tree for the link
+     */
+    protected Content getNavLinkIndex() {
+        Content linkContent = getHyperLink(relativePath +(configuration.splitindex?
+            DirectoryManager.getPath("index-files") + fileseparator: "") +
+            (configuration.splitindex?"index-1.html" : "index-all.html"), "",
+            indexLabel, "", "");
+        Content li = HtmlTree.LI(linkContent);
+        return li;
+    }
+
+    /**
      * Print help file link. If user has provided a help file, then generate a
      * link to the user given file, which is already copied to current or
      * destination directory.
@@ -764,6 +1201,29 @@
     }
 
     /**
+     * Get help file link. If user has provided a help file, then generate a
+     * link to the user given file, which is already copied to current or
+     * destination directory.
+     *
+     * @return a content tree for the link
+     */
+    protected Content getNavLinkHelp() {
+        String helpfilenm = configuration.helpfile;
+        if (helpfilenm.equals("")) {
+            helpfilenm = "help-doc.html";
+        } else {
+            int lastsep;
+            if ((lastsep = helpfilenm.lastIndexOf(File.separatorChar)) != -1) {
+                helpfilenm = helpfilenm.substring(lastsep + 1);
+            }
+        }
+        Content linkContent = getHyperLink(relativePath + helpfilenm, "",
+                helpLabel, "", "");
+        Content li = HtmlTree.LI(linkContent);
+        return li;
+    }
+
+    /**
      * Print the word "Detail" in the navigation bar. No link is available.
      */
     protected void navDetail() {
@@ -845,6 +1305,96 @@
     }
 
     /**
+     * Get summary table header.
+     *
+     * @param header the header for the table
+     * @param scope the scope of the headers
+     * @return a content tree for the header
+     */
+    public Content getSummaryTableHeader(String[] header, String scope) {
+        Content tr = new HtmlTree(HtmlTag.TR);
+        int size = header.length;
+        Content tableHeader;
+        if (size == 1) {
+            tableHeader = new StringContent(header[0]);
+            tr.addContent(HtmlTree.TH(HtmlStyle.colOne, scope, tableHeader));
+            return tr;
+        }
+        for (int i = 0; i < size; i++) {
+            tableHeader = new StringContent(header[i]);
+            if(i == 0)
+                tr.addContent(HtmlTree.TH(HtmlStyle.colFirst, scope, tableHeader));
+            else if(i == (size - 1))
+                tr.addContent(HtmlTree.TH(HtmlStyle.colLast, scope, tableHeader));
+            else
+                tr.addContent(HtmlTree.TH(scope, tableHeader));
+        }
+        return tr;
+    }
+
+    /**
+     * Get table caption.
+     *
+     * @param rawText the caption for the table which could be raw Html
+     * @return a content tree for the caption
+     */
+    public Content getTableCaption(String rawText) {
+        Content title = new RawHtml(rawText);
+        Content captionSpan = HtmlTree.SPAN(title);
+        Content space = getSpace();
+        Content tabSpan = HtmlTree.SPAN(HtmlStyle.tabEnd, space);
+        Content caption = HtmlTree.CAPTION(captionSpan);
+        caption.addContent(tabSpan);
+        return caption;
+    }
+
+    /**
+     * Get the marker anchor which will be added to the documentation tree.
+     *
+     * @param anchorName the anchor name attribute
+     * @return a content tree for the marker anchor
+     */
+    public Content getMarkerAnchor(String anchorName) {
+        return getMarkerAnchor(anchorName, null);
+    }
+
+    /**
+     * Get the marker anchor which will be added to the documentation tree.
+     *
+     * @param anchorName the anchor name attribute
+     * @param anchorContent the content that should be added to the anchor
+     * @return a content tree for the marker anchor
+     */
+    public Content getMarkerAnchor(String anchorName, Content anchorContent) {
+        if (anchorContent == null)
+            anchorContent = new Comment(" ");
+        Content markerAnchor = HtmlTree.A_NAME(anchorName, anchorContent);
+        return markerAnchor;
+    }
+
+    /**
+     * Returns a packagename content.
+     *
+     * @param packageDoc the package to check
+     * @return package name content
+     */
+    public Content getPackageName(PackageDoc packageDoc) {
+        return packageDoc == null || packageDoc.name().length() == 0 ?
+            defaultPackageLabel :
+            getPackageLabel(packageDoc.name());
+    }
+
+    /**
+     * Returns a package name label.
+     *
+     * @param parsedName the package name
+     * @return the package name content
+     */
+    public Content getPackageLabel(String packageName) {
+        return new StringContent(packageName);
+    }
+
+    /**
      * Prine table header information about color, column span and the font.
      *
      * @param color Background color.
@@ -1028,7 +1578,7 @@
      * @param isStrong true if the label should be strong.
      */
     public void printPackageLink(PackageDoc pkg, String label, boolean isStrong) {
-        print(getPackageLink(pkg, label, isStrong));
+        print(getPackageLinkString(pkg, label, isStrong));
     }
 
     /**
@@ -1041,7 +1591,7 @@
      */
     public void printPackageLink(PackageDoc pkg, String label, boolean isStrong,
             String style) {
-        print(getPackageLink(pkg, label, isStrong, style));
+        print(getPackageLinkString(pkg, label, isStrong, style));
     }
 
     /**
@@ -1052,9 +1602,9 @@
      * @param isStrong true if the label should be strong.
      * @return the link to the given package.
      */
-    public String getPackageLink(PackageDoc pkg, String label,
+    public String getPackageLinkString(PackageDoc pkg, String label,
                                  boolean isStrong) {
-        return getPackageLink(pkg, label, isStrong, "");
+        return getPackageLinkString(pkg, label, isStrong, "");
     }
 
     /**
@@ -1066,7 +1616,7 @@
      * @param style  the font of the package link label.
      * @return the link to the given package.
      */
-    public String getPackageLink(PackageDoc pkg, String label, boolean isStrong,
+    public String getPackageLinkString(PackageDoc pkg, String label, boolean isStrong,
             String style) {
         boolean included = pkg != null && pkg.isIncluded();
         if (! included) {
@@ -1079,12 +1629,43 @@
             }
         }
         if (included || pkg == null) {
-            return getHyperLink(pathString(pkg, "package-summary.html"),
+            return getHyperLinkString(pathString(pkg, "package-summary.html"),
                                 "", label, isStrong, style);
         } else {
             String crossPkgLink = getCrossPackageLink(Util.getPackageName(pkg));
             if (crossPkgLink != null) {
-                return getHyperLink(crossPkgLink, "", label, isStrong, style);
+                return getHyperLinkString(crossPkgLink, "", label, isStrong, style);
+            } else {
+                return label;
+            }
+        }
+    }
+
+    /**
+     * Return the link to the given package.
+     *
+     * @param pkg the package to link to.
+     * @param label the label for the link.
+     * @return a content tree for the package link.
+     */
+    public Content getPackageLink(PackageDoc pkg, Content label) {
+        boolean included = pkg != null && pkg.isIncluded();
+        if (! included) {
+            PackageDoc[] packages = configuration.packages;
+            for (int i = 0; i < packages.length; i++) {
+                if (packages[i].equals(pkg)) {
+                    included = true;
+                    break;
+                }
+            }
+        }
+        if (included || pkg == null) {
+            return getHyperLink(pathString(pkg, "package-summary.html"),
+                                "", label);
+        } else {
+            String crossPkgLink = getCrossPackageLink(Util.getPackageName(pkg));
+            if (crossPkgLink != null) {
+                return getHyperLink(crossPkgLink, "", label);
             } else {
                 return label;
             }
@@ -1112,6 +1693,29 @@
     }
 
     /**
+     * Add the link to the content tree.
+     *
+     * @param doc program element doc for which the link will be added
+     * @param label label for the link
+     * @param htmltree the content tree to which the link will be added
+     */
+    public void addSrcLink(ProgramElementDoc doc, Content label, Content htmltree) {
+        if (doc == null) {
+            return;
+        }
+        ClassDoc cd = doc.containingClass();
+        if (cd == null) {
+            //d must be a class doc since in has no containing class.
+            cd = (ClassDoc) doc;
+        }
+        String href = relativePath + DocletConstants.SOURCE_OUTPUT_DIR_NAME
+                + DirectoryManager.getDirectoryPath(cd.containingPackage())
+                + cd.name() + ".html#" + SourceToHTMLConverter.getAnchorName(doc);
+        Content linkContent = getHyperLink(href, "", label, "", "");
+        htmltree.addContent(linkContent);
+    }
+
+    /**
      * Return the link to the given class.
      *
      * @param linkInfo the information about the link.
@@ -1175,7 +1779,7 @@
                 //the -link option.  There are ways to determine if an external package
                 //exists, but no way to determine if the external class exists.  We just
                 //have to assume that it does.
-                return getHyperLink(
+                return getHyperLinkString(
                     configuration.extern.getExternalLink(packageName, relativePath,
                                 className + ".html?is-external=true"),
                     refMemName == null ? "" : refMemName,
@@ -1200,17 +1804,27 @@
             "package-summary.html?is-external=true");
     }
 
-    public void printQualifiedClassLink(int context, ClassDoc cd) {
-        printLink(new LinkInfoImpl(context, cd,
-            configuration.getClassName(cd), ""));
+    /**
+     * Get the class link.
+     *
+     * @param context the id of the context where the link will be added
+     * @param cd the class doc to link to
+     * @return a content tree for the link
+     */
+    public Content getQualifiedClassLink(int context, ClassDoc cd) {
+        return new RawHtml(getLink(new LinkInfoImpl(context, cd,
+                configuration.getClassName(cd), "")));
     }
 
     /**
-     * Print Class link, with only class name as the link and prefixing
-     * plain package name.
+     * Add the class link.
+     *
+     * @param context the id of the context where the link will be added
+     * @param cd the class doc to link to
+     * @param contentTree the content tree to which the link will be added
      */
-    public void printPreQualifiedClassLink(int context, ClassDoc cd) {
-        print(getPreQualifiedClassLink(context, cd, false));
+    public void addPreQualifiedClassLink(int context, ClassDoc cd, Content contentTree) {
+        addPreQualifiedClassLink(context, cd, false, contentTree);
     }
 
     /**
@@ -1233,13 +1847,36 @@
         return classlink;
     }
 
+    /**
+     * Add the class link with the package portion of the label in
+     * plain text. If the qualifier is excluded, it will not be included in the
+     * link label.
+     *
+     * @param context the id of the context where the link will be added
+     * @param cd the class to link to
+     * @param isStrong true if the link should be strong
+     * @param contentTree the content tree to which the link with be added
+     */
+    public void addPreQualifiedClassLink(int context,
+            ClassDoc cd, boolean isStrong, Content contentTree) {
+        PackageDoc pd = cd.containingPackage();
+        if(pd != null && ! configuration.shouldExcludeQualifier(pd.name())) {
+            contentTree.addContent(getPkgName(cd));
+        }
+        contentTree.addContent(new RawHtml(getLink(new LinkInfoImpl(
+                context, cd, cd.name(), isStrong))));
+    }
 
     /**
-     * Print Class link, with only class name as the strong link and prefixing
+     * Add the class link, with only class name as the strong link and prefixing
      * plain package name.
+     *
+     * @param context the id of the context where the link will be added
+     * @param cd the class to link to
+     * @param contentTree the content tree to which the link with be added
      */
-    public void printPreQualifiedStrongClassLink(int context, ClassDoc cd) {
-        print(getPreQualifiedClassLink(context, cd, true));
+    public void addPreQualifiedStrongClassLink(int context, ClassDoc cd, Content contentTree) {
+        addPreQualifiedClassLink(context, cd, true, contentTree);
     }
 
     public void printText(String key) {
@@ -1267,16 +1904,15 @@
     }
 
     /**
-     * Print the link for the given member.
+     * Get the link for the given member.
      *
-     * @param context the id of the context where the link will be printed.
-     * @param doc the member being linked to.
-     * @param label the label for the link.
-     * @param strong true if the link should be strong.
+     * @param context the id of the context where the link will be added
+     * @param doc the member being linked to
+     * @param label the label for the link
+     * @return a content tree for the doc link
      */
-    public void printDocLink(int context, MemberDoc doc, String label,
-            boolean strong) {
-        print(getDocLink(context, doc, label, strong));
+    public Content getDocLink(int context, MemberDoc doc, String label) {
+        return getDocLink(context, doc.containingClass(), doc, label);
     }
 
     /**
@@ -1338,6 +1974,34 @@
         }
     }
 
+    /**
+     * Return the link for the given member.
+     *
+     * @param context the id of the context where the link will be added
+     * @param classDoc the classDoc that we should link to.  This is not
+     *                 necessarily equal to doc.containingClass().  We may be
+     *                 inheriting comments
+     * @param doc the member being linked to
+     * @param label the label for the link
+     * @return the link for the given member
+     */
+    public Content getDocLink(int context, ClassDoc classDoc, MemberDoc doc,
+        String label) {
+        if (! (doc.isIncluded() ||
+            Util.isLinkable(classDoc, configuration()))) {
+            return new StringContent(label);
+        } else if (doc instanceof ExecutableMemberDoc) {
+            ExecutableMemberDoc emd = (ExecutableMemberDoc)doc;
+            return new RawHtml(getLink(new LinkInfoImpl(context, classDoc,
+                getAnchor(emd), label, false)));
+        } else if (doc instanceof MemberDoc) {
+            return new RawHtml(getLink(new LinkInfoImpl(context, classDoc,
+                doc.name(), label, false)));
+        } else {
+            return new StringContent(label);
+        }
+    }
+
     public void anchor(ExecutableMemberDoc emd) {
         anchor(getAnchor(emd));
     }
@@ -1392,14 +2056,14 @@
                 //@see is referencing an included package
                 String packageName = isplaintext ? refPackage.name() :
                     getCode() + refPackage.name() + getCodeEnd();
-                result.append(getPackageLink(refPackage,
+                result.append(getPackageLinkString(refPackage,
                     label.length() == 0 ? packageName : label, false));
             } else {
                 //@see is not referencing an included class or package.  Check for cross links.
                 String classCrossLink, packageCrossLink = getCrossPackageLink(refClassName);
                 if (packageCrossLink != null) {
                     //Package cross link found
-                    result.append(getHyperLink(packageCrossLink, "",
+                    result.append(getHyperLinkString(packageCrossLink, "",
                         (label.length() == 0)? text : label, false));
                 } else if ((classCrossLink = getCrossClassLink(refClassName,
                         refMemName, label, false, "", ! isplaintext)) != null) {
@@ -1468,18 +2132,61 @@
         printCommentTags(doc, tag.inlineTags(), false, false);
     }
 
+    /**
+     * Add the inline comment.
+     *
+     * @param doc the doc for which the inline comment will be added
+     * @param tag the inline tag to be added
+     * @param htmltree the content tree to which the comment will be added
+     */
+    public void addInlineComment(Doc doc, Tag tag, Content htmltree) {
+        addCommentTags(doc, tag.inlineTags(), false, false, htmltree);
+    }
+
     public void printInlineDeprecatedComment(Doc doc, Tag tag) {
         printCommentTags(doc, tag.inlineTags(), true, false);
     }
 
+    /**
+     * Add the inline deprecated comment.
+     *
+     * @param doc the doc for which the inline deprecated comment will be added
+     * @param tag the inline tag to be added
+     * @param htmltree the content tree to which the comment will be added
+     */
+    public void addInlineDeprecatedComment(Doc doc, Tag tag, Content htmltree) {
+        addCommentTags(doc, tag.inlineTags(), true, false, htmltree);
+    }
+
     public void printSummaryComment(Doc doc) {
         printSummaryComment(doc, doc.firstSentenceTags());
     }
 
+    /**
+     * Adds the summary content.
+     *
+     * @param doc the doc for which the summary will be generated
+     * @param htmltree the documentation tree to which the summary will be added
+     */
+    public void addSummaryComment(Doc doc, Content htmltree) {
+        addSummaryComment(doc, doc.firstSentenceTags(), htmltree);
+    }
+
     public void printSummaryComment(Doc doc, Tag[] firstSentenceTags) {
         printCommentTags(doc, firstSentenceTags, false, true);
     }
 
+    /**
+     * Adds the summary content.
+     *
+     * @param doc the doc for which the summary will be generated
+     * @param firstSentenceTags the first sentence tags for the doc
+     * @param htmltree the documentation tree to which the summary will be added
+     */
+    public void addSummaryComment(Doc doc, Tag[] firstSentenceTags, Content htmltree) {
+        addCommentTags(doc, firstSentenceTags, false, true, htmltree);
+    }
+
     public void printSummaryDeprecatedComment(Doc doc) {
         printCommentTags(doc, doc.firstSentenceTags(), true, true);
     }
@@ -1488,11 +2195,25 @@
         printCommentTags(doc, tag.firstSentenceTags(), true, true);
     }
 
+    public void addSummaryDeprecatedComment(Doc doc, Tag tag, Content htmltree) {
+        addCommentTags(doc, tag.firstSentenceTags(), true, true, htmltree);
+    }
+
     public void printInlineComment(Doc doc) {
         printCommentTags(doc, doc.inlineTags(), false, false);
         p();
     }
 
+    /**
+     * Adds the inline comment.
+     *
+     * @param doc the doc for which the inline comments will be generated
+     * @param htmltree the documentation tree to which the inline comments will be added
+     */
+    public void addInlineComment(Doc doc, Content htmltree) {
+        addCommentTags(doc, doc.inlineTags(), false, false, htmltree);
+    }
+
     public void printInlineDeprecatedComment(Doc doc) {
         printCommentTags(doc, doc.inlineTags(), true, false);
     }
@@ -1515,6 +2236,36 @@
     }
 
     /**
+     * Adds the comment tags.
+     *
+     * @param doc the doc for which the comment tags will be generated
+     * @param tags the first sentence tags for the doc
+     * @param depr true if it is deprecated
+     * @param first true if the first sentenge tags should be added
+     * @param htmltree the documentation tree to which the comment tags will be added
+     */
+    private void addCommentTags(Doc doc, Tag[] tags, boolean depr,
+            boolean first, Content htmltree) {
+        if(configuration.nocomment){
+            return;
+        }
+        Content div;
+        Content result = new RawHtml(commentTagsToString(null, doc, tags, first));
+        if (depr) {
+            Content italic = HtmlTree.I(result);
+            div = HtmlTree.DIV(HtmlStyle.block, italic);
+            htmltree.addContent(div);
+        }
+        else {
+            div = HtmlTree.DIV(HtmlStyle.block, result);
+            htmltree.addContent(div);
+        }
+        if (tags.length == 0) {
+            htmltree.addContent(getSpace());
+        }
+    }
+
+    /**
      * Converts inline tags and text to text strings, expanding the
      * inline tags along the way.  Called wherever text can contain
      * an inline tag, such as in comments or in free-form text arguments
@@ -1624,8 +2375,8 @@
             return text;
         }
 
-        if (! redirectPathFromRoot.endsWith(DirectoryManager.URL_FILE_SEPERATOR)) {
-            redirectPathFromRoot += DirectoryManager.URL_FILE_SEPERATOR;
+        if (! redirectPathFromRoot.endsWith(DirectoryManager.URL_FILE_SEPARATOR)) {
+            redirectPathFromRoot += DirectoryManager.URL_FILE_SEPARATOR;
         }
 
         //Redirect all relative links.
@@ -1751,6 +2502,27 @@
     }
 
     /**
+     * Returns a link to the stylesheet file.
+     *
+     * @return an HtmlTree for the lINK tag which provides the stylesheet location
+     */
+    public HtmlTree getStyleSheetProperties() {
+        String filename = configuration.stylesheetfile;
+        if (filename.length() > 0) {
+            File stylefile = new File(filename);
+            String parent = stylefile.getParent();
+            filename = (parent == null)?
+                filename:
+                filename.substring(parent.length() + 1);
+        } else {
+            filename = "stylesheet.css";
+        }
+        filename = relativePath + filename;
+        HtmlTree link = HtmlTree.LINK("stylesheet", "text/css", filename, "Style");
+        return link;
+    }
+
+    /**
      * According to the Java Language Specifications, all the outer classes
      * and static nested classes are core classes.
      */
@@ -1768,6 +2540,17 @@
     }
 
     /**
+     * Adds the annotatation types for the given packageDoc.
+     *
+     * @param packageDoc the package to write annotations for.
+     * @param htmltree the documentation tree to which the annotation info will be
+     *        added
+     */
+    public void addAnnotationInfo(PackageDoc packageDoc, Content htmltree) {
+        addAnnotationInfo(packageDoc, packageDoc.annotations(), htmltree);
+    }
+
+    /**
      * Write the annotatation types for the given doc.
      *
      * @param doc the doc to write annotations for.
@@ -1777,6 +2560,16 @@
     }
 
     /**
+     * Adds the annotatation types for the given doc.
+     *
+     * @param packageDoc the package to write annotations for
+     * @param htmltree the content tree to which the annotation types will be added
+     */
+    public void addAnnotationInfo(ProgramElementDoc doc, Content htmltree) {
+        addAnnotationInfo(doc, doc.annotations(), htmltree);
+    }
+
+    /**
      * Write the annotatation types for the given doc and parameter.
      *
      * @param indent the number of spaced to indent the parameters.
@@ -1788,6 +2581,19 @@
     }
 
     /**
+     * Add the annotatation types for the given doc and parameter.
+     *
+     * @param indent the number of spaces to indent the parameters.
+     * @param doc the doc to write annotations for.
+     * @param param the parameter to write annotations for.
+     * @param tree the content tree to which the annotation types will be added
+     */
+    public boolean addAnnotationInfo(int indent, Doc doc, Parameter param,
+            Content tree) {
+        return addAnnotationInfo(indent, doc, param.annotations(), false, tree);
+    }
+
+    /**
      * Write the annotatation types for the given doc.
      *
      * @param doc the doc to write annotations for.
@@ -1798,6 +2604,19 @@
     }
 
     /**
+     * Adds the annotatation types for the given doc.
+     *
+     * @param doc the doc to write annotations for.
+     * @param descList the array of {@link AnnotationDesc}.
+     * @param htmltree the documentation tree to which the annotation info will be
+     *        added
+     */
+    private void addAnnotationInfo(Doc doc, AnnotationDesc[] descList,
+            Content htmltree) {
+        addAnnotationInfo(0, doc, descList, true, htmltree);
+    }
+
+    /**
      * Write the annotatation types for the given doc.
      *
      * @param indent the number of extra spaces to indent the annotations.
@@ -1818,6 +2637,29 @@
     }
 
     /**
+     * Adds the annotatation types for the given doc.
+     *
+     * @param indent the number of extra spaces to indent the annotations.
+     * @param doc the doc to write annotations for.
+     * @param descList the array of {@link AnnotationDesc}.
+     * @param htmltree the documentation tree to which the annotation info will be
+     *        added
+     */
+    private boolean addAnnotationInfo(int indent, Doc doc,
+            AnnotationDesc[] descList, boolean lineBreak, Content htmltree) {
+        List<String> annotations = getAnnotations(indent, descList, lineBreak);
+        if (annotations.size() == 0) {
+            return false;
+        }
+        Content annotationContent;
+        for (Iterator<String> iter = annotations.iterator(); iter.hasNext();) {
+            annotationContent = new RawHtml(iter.next());
+            htmltree.addContent(annotationContent);
+        }
+        return true;
+    }
+
+   /**
      * Return the string representations of the annotation types for
      * the given doc.
      *
--- a/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialFieldWriter.java	Thu Dec 16 19:57:01 2010 -0800
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialFieldWriter.java	Mon Dec 20 21:10:57 2010 -0800
@@ -31,6 +31,7 @@
 import com.sun.tools.doclets.internal.toolkit.*;
 import com.sun.tools.doclets.internal.toolkit.taglets.*;
 import com.sun.tools.doclets.internal.toolkit.util.*;
+import com.sun.tools.doclets.formats.html.markup.*;
 
 /**
  * Generate serialized form for serializable fields.
@@ -46,8 +47,6 @@
 
     private boolean printedOverallAnchor = false;
 
-    private boolean printedFirstMember = false;
-
     public HtmlSerialFieldWriter(SubWriterHolderWriter writer,
                                     ClassDoc classdoc) {
         super(writer, classdoc);
@@ -69,109 +68,143 @@
         }
     }
 
-    public void writeHeader(String heading) {
-        if (! printedOverallAnchor) {
-            writer.anchor("serializedForm");
-            printedOverallAnchor = true;
-            writer.printTableHeadingBackground(heading);
-            writer.println();
-            if (heading.equals(
-                   configuration().getText("doclet.Serialized_Form_class"))) {
-                assert !writer.getMemberDetailsListPrinted();
-            }
-        } else {
-            writer.printTableHeadingBackground(heading);
-            writer.println();
-        }
-    }
-
-    public void writeMemberHeader(ClassDoc fieldType, String fieldTypeStr,
-            String fieldDimensions, String fieldName) {
-        if (printedFirstMember) {
-            writer.printMemberHeader();
-        }
-        printedFirstMember = true;
-        writer.h3();
-        writer.print(fieldName);
-        writer.h3End();
-        writer.pre();
-        if (fieldType == null) {
-            writer.print(fieldTypeStr);
-        } else {
-            writer.printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_SERIAL_MEMBER,
-                fieldType));
-        }
-        print(fieldDimensions + ' ');
-        strong(fieldName);
-        writer.preEnd();
-        assert !writer.getMemberDetailsListPrinted();
+    /**
+     * Return the header for serializable fields section.
+     *
+     * @return a content tree for the header
+     */
+    public Content getSerializableFieldsHeader() {
+        HtmlTree ul = new HtmlTree(HtmlTag.UL);
+        ul.addStyle(HtmlStyle.blockList);
+        return ul;
     }
 
     /**
-     * Write the deprecated information for this member.
+     * Return the header for serializable fields content section.
      *
-     * @param field the field to document.
+     * @param isLastContent true if the cotent being documented is the last content.
+     * @return a content tree for the header
      */
-    public void writeMemberDeprecatedInfo(FieldDoc field) {
-        printDeprecated(field);
+    public Content getFieldsContentHeader(boolean isLastContent) {
+        HtmlTree li = new HtmlTree(HtmlTag.LI);
+        if (isLastContent)
+            li.addStyle(HtmlStyle.blockListLast);
+        else
+            li.addStyle(HtmlStyle.blockList);
+        return li;
     }
 
     /**
-     * Write the description text for this member.
+     * Add serializable fields.
+     *
+     * @param heading the heading for the section
+     * @param serializableFieldsTree the tree to be added to the serializable fileds
+     *        content tree
+     * @return a content tree for the serializable fields content
+     */
+    public Content getSerializableFields(String heading, Content serializableFieldsTree) {
+        HtmlTree li = new HtmlTree(HtmlTag.LI);
+        li.addStyle(HtmlStyle.blockList);
+        if (serializableFieldsTree.isValid()) {
+            if (!printedOverallAnchor) {
+                li.addContent(writer.getMarkerAnchor("serializedForm"));
+                printedOverallAnchor = true;
+            }
+            Content headingContent = new StringContent(heading);
+            Content serialHeading = HtmlTree.HEADING(HtmlConstants.SERIALIZED_MEMBER_HEADING,
+                    headingContent);
+            li.addContent(serialHeading);
+            li.addContent(serializableFieldsTree);
+        }
+        return li;
+    }
+
+    /**
+     * Add the member header.
+     *
+     * @param fieldsType the class document to be listed
+     * @param fieldTypeStr the string for the filed type to be documented
+     * @param fieldDimensions the dimensions of the field string to be added
+     * @param firldName name of the field to be added
+     * @param contentTree the content tree to which the member header will be added
+     */
+    public void addMemberHeader(ClassDoc fieldType, String fieldTypeStr,
+            String fieldDimensions, String fieldName, Content contentTree) {
+        Content nameContent = new RawHtml(fieldName);
+        Content heading = HtmlTree.HEADING(HtmlConstants.MEMBER_HEADING, nameContent);
+        contentTree.addContent(heading);
+        Content pre = new HtmlTree(HtmlTag.PRE);
+        if (fieldType == null) {
+            pre.addContent(fieldTypeStr);
+        } else {
+            Content fieldContent = new RawHtml(writer.getLink(new LinkInfoImpl(
+                    LinkInfoImpl.CONTEXT_SERIAL_MEMBER, fieldType)));
+            pre.addContent(fieldContent);
+        }
+        pre.addContent(fieldDimensions + " ");
+        pre.addContent(fieldName);
+        contentTree.addContent(pre);
+    }
+
+    /**
+     * Add the deprecated information for this member.
      *
      * @param field the field to document.
+     * @param contentTree the tree to which the deprecated info will be added
      */
-    public void writeMemberDescription(FieldDoc field) {
+    public void addMemberDeprecatedInfo(FieldDoc field, Content contentTree) {
+        addDeprecatedInfo(field, contentTree);
+    }
+
+    /**
+     * Add the description text for this member.
+     *
+     * @param field the field to document.
+     * @param contentTree the tree to which the deprecated info will be added
+     */
+    public void addMemberDescription(FieldDoc field, Content contentTree) {
         if (field.inlineTags().length > 0) {
-            writer.printMemberDetailsListStartTag();
-            writer.dd();
-            writer.printInlineComment(field);
-            writer.ddEnd();
+            writer.addInlineComment(field, contentTree);
         }
         Tag[] tags = field.tags("serial");
         if (tags.length > 0) {
-            writer.printMemberDetailsListStartTag();
-            writer.dd();
-            writer.printInlineComment(field, tags[0]);
-            writer.ddEnd();
+            writer.addInlineComment(field, tags[0], contentTree);
         }
     }
 
     /**
-     * Write the description text for this member represented by the tag.
+     * Add the description text for this member represented by the tag.
      *
-     * @param serialFieldTag the field to document (represented by tag).
+     * @param serialFieldTag the field to document (represented by tag)
+     * @param contentTree the tree to which the deprecated info will be added
      */
-    public void writeMemberDescription(SerialFieldTag serialFieldTag) {
+    public void addMemberDescription(SerialFieldTag serialFieldTag, Content contentTree) {
         String serialFieldTagDesc = serialFieldTag.description().trim();
         if (!serialFieldTagDesc.isEmpty()) {
-            writer.dl();
-            writer.dd();
-            writer.print(serialFieldTagDesc);
-            writer.ddEnd();
-            writer.dlEnd();
+            Content serialFieldContent = new RawHtml(serialFieldTagDesc);
+            Content div = HtmlTree.DIV(HtmlStyle.block, serialFieldContent);
+            contentTree.addContent(div);
         }
     }
 
     /**
-     * Write the tag information for this member.
+     * Add the tag information for this member.
      *
      * @param field the field to document.
+     * @param contentTree the tree to which the member tags info will be added
      */
-    public void writeMemberTags(FieldDoc field) {
+    public void addMemberTags(FieldDoc field, Content contentTree) {
         TagletOutputImpl output = new TagletOutputImpl("");
         TagletWriter.genTagOuput(configuration().tagletManager, field,
-            configuration().tagletManager.getCustomTags(field),
+                configuration().tagletManager.getCustomTags(field),
                 writer.getTagletWriterInstance(false), output);
         String outputString = output.toString().trim();
+        Content dlTags = new HtmlTree(HtmlTag.DL);
         if (!outputString.isEmpty()) {
-            writer.printMemberDetailsListStartTag();
-            writer.dd();
-            writer.dl();
-            print(outputString);
-            writer.dlEnd();
-            writer.ddEnd();
+            Content tagContent = new RawHtml(outputString);
+            dlTags.addContent(tagContent);
         }
+        contentTree.addContent(dlTags);
     }
 
     /**
@@ -192,24 +225,4 @@
             return true;
         return false;
     }
-
-    public void writeMemberFooter() {
-        printMemberFooter();
-    }
-
-    /**
-     * Write the footer information. If the serilization overview section was
-     * printed, check for definition list and close list tag.
-     *
-     * @param heading the heading that was written.
-     */
-    public void writeFooter(String heading) {
-        if (printedOverallAnchor) {
-            if (heading.equals(
-                   configuration().getText("doclet.Serialized_Form_class"))) {
-                writer.printMemberDetailsListEndTag();
-                assert !writer.getMemberDetailsListPrinted();
-            }
-        }
-    }
 }
--- a/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialMethodWriter.java	Thu Dec 16 19:57:01 2010 -0800
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialMethodWriter.java	Mon Dec 20 21:10:57 2010 -0800
@@ -28,57 +28,119 @@
 import com.sun.javadoc.*;
 import com.sun.tools.doclets.internal.toolkit.*;
 import com.sun.tools.doclets.internal.toolkit.taglets.*;
+import com.sun.tools.doclets.formats.html.markup.*;
 
 /**
  * Generate serialized form for Serializable/Externalizable methods.
  * Documentation denoted by the <code>serialData</code> tag is processed.
  *
  * @author Joe Fialli
+ * @author Bhavesh Patel (Modified)
  */
 public class HtmlSerialMethodWriter extends MethodWriterImpl implements
         SerializedFormWriter.SerialMethodWriter{
 
-    private boolean printedFirstMember = false;
-
     public HtmlSerialMethodWriter(SubWriterHolderWriter writer,
             ClassDoc classdoc) {
         super(writer, classdoc);
     }
 
-    public void writeHeader(String heading) {
-        writer.anchor("serialized_methods");
-        writer.printTableHeadingBackground(heading);
-        writer.p();
+    /**
+     * Return the header for serializable methods section.
+     *
+     * @return a content tree for the header
+     */
+    public Content getSerializableMethodsHeader() {
+        HtmlTree ul = new HtmlTree(HtmlTag.UL);
+        ul.addStyle(HtmlStyle.blockList);
+        return ul;
     }
 
-    public void writeNoCustomizationMsg(String msg) {
-        writer.print(msg);
-        writer.p();
+    /**
+     * Return the header for serializable methods content section.
+     *
+     * @param isLastContent true if the cotent being documented is the last content.
+     * @return a content tree for the header
+     */
+    public Content getMethodsContentHeader(boolean isLastContent) {
+        HtmlTree li = new HtmlTree(HtmlTag.LI);
+        if (isLastContent)
+            li.addStyle(HtmlStyle.blockListLast);
+        else
+            li.addStyle(HtmlStyle.blockList);
+        return li;
     }
 
-    public void writeMemberHeader(MethodDoc member) {
-        if (printedFirstMember) {
-            writer.printMemberHeader();
-        }
-        printedFirstMember = true;
-        writer.anchor(member);
-        printHead(member);
-        writeSignature(member);
+    /**
+     * Add serializable methods.
+     *
+     * @param heading the heading for the section
+     * @param serializableMethodContent the tree to be added to the serializable methods
+     *        content tree
+     * @return a content tree for the serializable methods content
+     */
+    public Content getSerializableMethods(String heading, Content serializableMethodContent) {
+        Content li = HtmlTree.LI(HtmlStyle.blockList, writer.getMarkerAnchor(
+                "serialized_methods"));
+        Content headingContent = new StringContent(heading);
+        Content serialHeading = HtmlTree.HEADING(HtmlConstants.SERIALIZED_MEMBER_HEADING,
+                headingContent);
+        li.addContent(serialHeading);
+        li.addContent(serializableMethodContent);
+        return li;
     }
 
-    public void writeMemberFooter() {
-        printMemberFooter();
+    /**
+     * Return the no customization message.
+     *
+     * @param msg the message to be displayed
+     * @return no customization message content
+     */
+    public Content getNoCustomizationMsg(String msg) {
+        Content noCustomizationMsg = new StringContent(msg);
+        return noCustomizationMsg;
     }
 
-    public void writeDeprecatedMemberInfo(MethodDoc member) {
-        printDeprecated(member);
+    /**
+     * Add the member header.
+     *
+     * @param member the method document to be listed
+     * @param methodsContentTree the content tree to which the member header will be added
+     */
+    public void addMemberHeader(MethodDoc member, Content methodsContentTree) {
+        methodsContentTree.addContent(writer.getMarkerAnchor(
+                writer.getAnchor(member)));
+        methodsContentTree.addContent(getHead(member));
+        methodsContentTree.addContent(getSignature(member));
     }
 
-    public void writeMemberDescription(MethodDoc member) {
-        printComment(member);
+    /**
+     * Add the deprecated information for this member.
+     *
+     * @param member the method to document.
+     * @param methodsContentTree the tree to which the deprecated info will be added
+     */
+    public void addDeprecatedMemberInfo(MethodDoc member, Content methodsContentTree) {
+        addDeprecatedInfo(member, methodsContentTree);
     }
 
-    public void writeMemberTags(MethodDoc member) {
+    /**
+     * Add the description text for this member.
+     *
+     * @param member the method to document.
+     * @param methodsContentTree the tree to which the deprecated info will be added
+     */
+    public void addMemberDescription(MethodDoc member, Content methodsContentTree) {
+        addComment(member, methodsContentTree);
+    }
+
+    /**
+     * Add the tag information for this member.
+     *
+     * @param member the method to document.
+     * @param methodsContentTree the tree to which the member tags info will be added
+     */
+    public void addMemberTags(MethodDoc member, Content methodsContentTree) {
         TagletOutputImpl output = new TagletOutputImpl("");
         TagletManager tagletManager =
             ConfigurationImpl.getInstance().tagletManager;
@@ -86,14 +148,12 @@
             tagletManager.getSerializedFormTags(),
             writer.getTagletWriterInstance(false), output);
         String outputString = output.toString().trim();
+        Content dlTags = new HtmlTree(HtmlTag.DL);
         if (!outputString.isEmpty()) {
-            writer.printMemberDetailsListStartTag();
-            writer.dd();
-            writer.dl();
-            print(outputString);
-            writer.dlEnd();
-            writer.ddEnd();
+            Content tagContent = new RawHtml(outputString);
+            dlTags.addContent(tagContent);
         }
+        methodsContentTree.addContent(dlTags);
         MethodDoc method = member;
         if (method.name().compareTo("writeExternal") == 0
                 && method.tags("serialData").length == 0) {
--- a/src/share/classes/com/sun/tools/doclets/formats/html/LinkFactoryImpl.java	Thu Dec 16 19:57:01 2010 -0800
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/LinkFactoryImpl.java	Mon Dec 20 21:10:57 2010 -0800
@@ -79,7 +79,7 @@
                 String filename = pathString(classLinkInfo);
                 if (linkInfo.linkToSelf ||
                                 !(linkInfo.classDoc.name() + ".html").equals(m_writer.filename)) {
-                        linkOutput.append(m_writer.getHyperLink(filename,
+                        linkOutput.append(m_writer.getHyperLinkString(filename,
                             classLinkInfo.where, label.toString(),
                             classLinkInfo.isStrong, classLinkInfo.styleName,
                             title, classLinkInfo.target));
--- a/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java	Thu Dec 16 19:57:01 2010 -0800
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java	Mon Dec 20 21:10:57 2010 -0800
@@ -28,9 +28,9 @@
 import java.io.*;
 
 import com.sun.javadoc.*;
+import com.sun.tools.doclets.formats.html.markup.*;
 import com.sun.tools.doclets.internal.toolkit.*;
 import com.sun.tools.doclets.internal.toolkit.util.*;
-import com.sun.tools.doclets.internal.toolkit.taglets.*;
 
 /**
  * Writes method documentation in HTML format.
@@ -43,8 +43,6 @@
 public class MethodWriterImpl extends AbstractExecutableMemberWriter
         implements MethodWriter, MemberSummaryWriter {
 
-    private boolean printedSummaryHeader = false;
-
     /**
      * Construct a new MethodWriterImpl.
      *
@@ -65,184 +63,127 @@
     }
 
     /**
-     * Write the methods summary header for the given class.
-     *
-     * @param classDoc the class the summary belongs to.
+     * {@inheritDoc}
      */
-    public void writeMemberSummaryHeader(ClassDoc classDoc) {
-        printedSummaryHeader = true;
-        writer.println();
-        writer.println("<!-- ========== METHOD SUMMARY =========== -->");
-        writer.println();
-        writer.printSummaryHeader(this, classDoc);
-    }
-
-    /**
-     * Write the methods summary footer for the given class.
-     *
-     * @param classDoc the class the summary belongs to.
-     */
-    public void writeMemberSummaryFooter(ClassDoc classDoc) {
-        writer.printSummaryFooter(this, classDoc);
-    }
-
-    /**
-     * Write the inherited methods summary header for the given class.
-     *
-     * @param classDoc the class the summary belongs to.
-     */
-    public void writeInheritedMemberSummaryHeader(ClassDoc classDoc) {
-        if(! printedSummaryHeader){
-            //We don't want inherited summary to not be under heading.
-            writeMemberSummaryHeader(classDoc);
-            writeMemberSummaryFooter(classDoc);
-            printedSummaryHeader = true;
-        }
-        writer.printInheritedSummaryHeader(this, classDoc);
+    public Content getMemberSummaryHeader(ClassDoc classDoc,
+            Content memberSummaryTree) {
+        memberSummaryTree.addContent(HtmlConstants.START_OF_METHOD_SUMMARY);
+        Content memberTree = writer.getMemberTreeHeader();
+        writer.addSummaryHeader(this, classDoc, memberTree);
+        return memberTree;
     }
 
     /**
      * {@inheritDoc}
      */
-    public void writeInheritedMemberSummary(ClassDoc classDoc,
-        ProgramElementDoc method, boolean isFirst, boolean isLast) {
-        writer.printInheritedSummaryMember(this, classDoc, method, isFirst);
+    public Content getMethodDetailsTreeHeader(ClassDoc classDoc,
+            Content memberDetailsTree) {
+        memberDetailsTree.addContent(HtmlConstants.START_OF_METHOD_DETAILS);
+        Content methodDetailsTree = writer.getMemberTreeHeader();
+        methodDetailsTree.addContent(writer.getMarkerAnchor("method_detail"));
+        Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING,
+                writer.methodDetailsLabel);
+        methodDetailsTree.addContent(heading);
+        return methodDetailsTree;
     }
 
     /**
-     * Write the inherited methods summary footer for the given class.
-     *
-     * @param classDoc the class the summary belongs to.
+     * {@inheritDoc}
      */
-    public void writeInheritedMemberSummaryFooter(ClassDoc classDoc) {
-        writer.printInheritedSummaryFooter(this, classDoc);        ;
+    public Content getMethodDocTreeHeader(MethodDoc method,
+            Content methodDetailsTree) {
+        String erasureAnchor;
+        if ((erasureAnchor = getErasureAnchor(method)) != null) {
+            methodDetailsTree.addContent(writer.getMarkerAnchor((erasureAnchor)));
+        }
+        methodDetailsTree.addContent(
+                writer.getMarkerAnchor(writer.getAnchor(method)));
+        Content methodDocTree = writer.getMemberTreeHeader();
+        Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING);
+        heading.addContent(method.name());
+        methodDocTree.addContent(heading);
+        return methodDocTree;
     }
 
     /**
-     * Write the header for the method documentation.
+     * Get the signature for the given method.
      *
-     * @param classDoc the class that the methods belong to.
+     * @param method the method being documented.
+     * @return a content object for the signature
      */
-    public void writeHeader(ClassDoc classDoc, String header) {