com.sun.tools.doclets.internal.toolkit.util
Class SourceToHTMLConverter

java.lang.Object
  extended by com.sun.tools.doclets.internal.toolkit.util.SourceToHTMLConverter

public class SourceToHTMLConverter
extends java.lang.Object

Converts Java Source Code to HTML. This code is not part of an API. It is implementation that is subject to change. Do not use it as an API

Since:
1.4

Field Summary
protected static java.lang.String BGCOLOR
          The background color.
protected static java.lang.String LINE_NO_COLOR
          The line number color.
protected static int NUM_BLANK_LINES
          The number of trailing blank lines at the end of the page.
 
Constructor Summary
private SourceToHTMLConverter()
          Source is converted to HTML using static methods below.
 
Method Summary
private static java.lang.StringBuffer addLineNumbers(java.lang.String s)
          Given a String, add line numbers.
protected static void addToHash(Doc[] docs, java.util.HashMap<java.lang.Integer,java.lang.String> hash)
          Given an array of Docs, add to the given HashMap the line numbers and anchors that should be inserted in the output at those lines.
static void convertClass(Configuration configuration, ClassDoc cd, java.lang.String outputdir)
          Convert the given Class to an HTML.
static void convertPackage(Configuration configuration, PackageDoc pd, java.lang.String outputdir)
          Convert the Classes in the given Package to an HTML.
static void convertRoot(Configuration configuration, RootDoc rd, java.lang.String outputdir)
          Convert the Classes in the given RootDoc to an HTML.
protected static java.lang.String formatLine(java.lang.String line, int tabLength, int currentLineNo)
          Format a given line of source.
protected static java.lang.String getAnchor(Doc d)
          Given a Doc, return an anchor for it.
static java.lang.String getAnchorName(Doc d)
          Given a Doc, return an anchor name for it.
protected static java.lang.String getFooter()
          Get the footer
protected static java.lang.String getHeader(Configuration configuration)
          Get the header.
protected static java.lang.String getHTMLLineNo(int lineno)
          Get the HTML for the lines.
private static java.lang.String getPackageOutputDir(java.lang.String outputDir, PackageDoc pd)
          Return the directory write output to for the given package.
private static void writeToFile(java.lang.String output, java.lang.String outputDir, java.lang.String className, Configuration configuration)
          Write the output to the file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BGCOLOR

protected static final java.lang.String BGCOLOR
The background color.

See Also:
Constant Field Values

LINE_NO_COLOR

protected static final java.lang.String LINE_NO_COLOR
The line number color.

See Also:
Constant Field Values

NUM_BLANK_LINES

protected static final int NUM_BLANK_LINES
The number of trailing blank lines at the end of the page. This is inserted so that anchors at the bottom of small pages can be reached.

See Also:
Constant Field Values
Constructor Detail

SourceToHTMLConverter

private SourceToHTMLConverter()
Source is converted to HTML using static methods below.

Method Detail

convertRoot

public static void convertRoot(Configuration configuration,
                               RootDoc rd,
                               java.lang.String outputdir)
Convert the Classes in the given RootDoc to an HTML.

Parameters:
configuration - the configuration.
rd - the RootDoc to convert.
outputdir - the name of the directory to output to.

convertPackage

public static void convertPackage(Configuration configuration,
                                  PackageDoc pd,
                                  java.lang.String outputdir)
Convert the Classes in the given Package to an HTML.

Parameters:
configuration - the configuration.
pd - the Package to convert.
outputdir - the name of the directory to output to.

getPackageOutputDir

private static java.lang.String getPackageOutputDir(java.lang.String outputDir,
                                                    PackageDoc pd)
Return the directory write output to for the given package.

Parameters:
outputDir - the directory to output to.
pd - the Package to generate output for.

convertClass

public static void convertClass(Configuration configuration,
                                ClassDoc cd,
                                java.lang.String outputdir)
Convert the given Class to an HTML.

Parameters:
configuration - the configuration.
cd - the class to convert.
outputdir - the name of the directory to output to.

writeToFile

private static void writeToFile(java.lang.String output,
                                java.lang.String outputDir,
                                java.lang.String className,
                                Configuration configuration)
                         throws java.io.IOException
Write the output to the file.

Parameters:
output - the string to output.
outputDir - the directory to output to.
className - the name of the class that I am converting to HTML.
configuration - the Doclet configuration to pass notices to.
Throws:
java.io.IOException

addLineNumbers

private static java.lang.StringBuffer addLineNumbers(java.lang.String s)
Given a String, add line numbers.

Parameters:
s - the text to add line numbers to.
Returns:
the string buffer with the line numbering for each line.

getHeader

protected static java.lang.String getHeader(Configuration configuration)
Get the header.

Parameters:
configuration - the Doclet configuration
Returns:
the header to the output file

getFooter

protected static java.lang.String getFooter()
Get the footer

Returns:
the footer to the output file

getHTMLLineNo

protected static java.lang.String getHTMLLineNo(int lineno)
Get the HTML for the lines.

Parameters:
lineno - The line number
Returns:
the HTML code for the line

formatLine

protected static java.lang.String formatLine(java.lang.String line,
                                             int tabLength,
                                             int currentLineNo)
Format a given line of source.
Note: In the future, we will add special colors for constructs in the language.

Parameters:
line - the string to format.
tabLength - the number of spaces for each tab.
currentLineNo - the current number.

addToHash

protected static void addToHash(Doc[] docs,
                                java.util.HashMap<java.lang.Integer,java.lang.String> hash)
Given an array of Docs, add to the given HashMap the line numbers and anchors that should be inserted in the output at those lines.

Parameters:
docs - the array of Docs to add anchors for.
hash - the HashMap to add to.

getAnchor

protected static java.lang.String getAnchor(Doc d)
Given a Doc, return an anchor for it.

Parameters:
d - the Doc to check.
Returns:
an anchor of the form <a name="my_name"></a>

getAnchorName

public static java.lang.String getAnchorName(Doc d)
Given a Doc, return an anchor name for it.

Parameters:
d - the Doc to check.
Returns:
the name of the anchor.