Package jdiff
Class HTMLReportGenerator
- java.lang.Object
-
- jdiff.HTMLReportGenerator
-
public class HTMLReportGenerator extends java.lang.ObjectEmit HTML based on the changes between two sets of APIs. See the file LICENSE.txt for copyright details.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringdocTitleThe title used on the first page of the report.static booleandoStatsTo generate statistical output, set this to true.static java.lang.StringnewDocPrefixDefine the prefix for HTML links to the existing set of Javadoc- generated documentation for the new API.static booleannoCommentsOnAdditionsIf set, then do not suggest comments for additions from the first sentence of the doc block of the new API.static booleannoCommentsOnChangesIf set, then do not suggest comments for changes from the first sentence of the doc block of the new API.static booleannoCommentsOnRemovalsIf set, then do not suggest comments for removals from the first sentence of the doc block of the old API.static java.lang.StringoldDocPrefixDefine the prefix for HTML links to the existing set of Javadoc- generated documentation for the old API.static java.lang.StringoutputDirThe destination directory for output files.static booleanreportDocChangesIf set, then report changes in documentation (Javadoc comments) between the old and the new API.static java.lang.StringwindowTitleThe browser window title for the report.
-
Constructor Summary
Constructors Constructor Description HTMLReportGenerator()Default constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidemitChanges(jdiff.MemberDiff memberDiff, int memberType)Emit all changes associated with a MemberDiff as an entry in a table.voidemitComment(java.lang.String commentID, java.lang.String possibleComment, int linkType)Find any existing comment and emit it.voidemitException(java.lang.String ex)Emit a string which is an exception by surrounding it with <code> tags.voidemitType(java.lang.String type)Emit a string which is a type by surrounding it with <code> tags.static voidemitTypeWithNoParens(java.lang.String type)Emit a string which is a type by surrounding it with <code> tags.static voidemitTypeWithParens(java.lang.String type)Emit a string which is a type by surrounding it with <code> tags.static voidemitTypeWithParens(java.lang.String type, boolean addBreaks)Emit a string which is a type by surrounding it with <code> tags.voidgenerate(APIComparator comp, Comments existingComments)Generate the report.CommentsgetNewComments()Accessor method for the freshly generated Comments object.voidindent(int indent)Emit some non-breaking space for indentation.java.lang.StringmakeTwoRows(java.lang.String name)If a class or package name is considered to be too long for convenient display, insert
in the middle of it at a period.voidreportAllCtors(java.lang.String pkgName, jdiff.ClassDiff classDiff)Write out the details of constructors in a class.voidreportAllFields(java.lang.String pkgName, jdiff.ClassDiff classDiff)Write out the details of fields in a class.voidreportAllMethods(java.lang.String pkgName, jdiff.ClassDiff classDiff)Write out the details of methods in a class.voidreportChangedClass(java.lang.String pkgName, jdiff.ClassDiff[] classDiffs, int classIndex)Write out the details of a changed class in a separate file.voidreportChangedPackage(jdiff.PackageDiff[] pkgDiffs, int pkgIndex)Write out the details of a changed package in a separate file.static java.lang.StringsimpleName(java.lang.String fqNames)Return a String with the simple names of the classes in fqName.voidwriteClassTableEntry(java.lang.String pkgName, java.lang.String className, int linkType, boolean isInterface, java.lang.String possibleComment, boolean useOld)Write a table entry for a class or interface.voidwriteCtorChangedTableEntry(java.lang.String pkgName, java.lang.String className, jdiff.MemberDiff memberDiff)Write a table entry for a changed constructor.voidwriteCtorTableEntry(java.lang.String pkgName, java.lang.String className, java.lang.String type, int linkType, java.lang.String possibleComment, boolean useOld)Write a table entry for a constructor.voidwriteFieldChangedTableEntry(java.lang.String pkgName, java.lang.String className, jdiff.MemberDiff memberDiff)Write a table entry for a changed field.voidwriteFieldTableEntry(java.lang.String pkgName, java.lang.String className, jdiff.FieldAPI fieldAPI, int linkType, java.lang.String possibleComment, boolean useOld)Write a table entry for a field.voidwriteHTMLFooter()Write the HTML footer.voidwriteHTMLTitle(java.lang.String title)Write the HTML titlevoidwriteMethodChangedTableEntry(java.lang.String pkgName, java.lang.String className, jdiff.MemberDiff memberDiff)Write a table entry for a changed method.voidwriteMethodTableEntry(java.lang.String pkgName, java.lang.String className, jdiff.MethodAPI methodAPI, int linkType, java.lang.String possibleComment, boolean useOld)Write a table entry for a method.voidwriteNavigationBar(java.lang.String pkgName, java.lang.String prevElemLink, java.lang.String nextElemLink, java.lang.String className, int level, boolean upperNavigationBar, boolean hasRemovals, boolean hasAdditions, boolean hasChanges)Write a navigation bar section header.voidwritePackageTableEntry(java.lang.String pkgName, int linkType, java.lang.String possibleComment, boolean useOld)Write a table entry for a package, with support for links to Javadoc for removed packages.voidwriteReport(APIDiff apiDiff)Write the HTML report.voidwriteSectionFooter(java.lang.String packageName, java.lang.String prevElemLink, java.lang.String nextElemLink, java.lang.String className, int level)Write a section footer, which includes a navigation bar.voidwriteSectionHeader(java.lang.String title, java.lang.String packageName, java.lang.String prevElemLink, java.lang.String nextElemLink, java.lang.String className, int level, boolean hasRemovals, boolean hasAdditions, boolean hasChanges)Write a section header, which includes a navigation bar.voidwriteStartHTMLHeader()Write the start of the HTML header.voidwriteStartHTMLHeader(boolean addDate)Write the start of the HTML header.voidwriteStartHTMLHeaderWithDate()Write the start of the HTML header, together with the current date and time in an HTML comment.voidwriteStyleSheetRef()Write the HTML style sheet reference for files in the subdirectory.voidwriteStyleSheetRef(boolean inSameDir)Write the HTML style sheet reference.voidwriteTableEnd()Write the end of a table.voidwriteTableStart(java.lang.String title, int colSpan)Write the start of a table.voidwriteText()Write a newline out.voidwriteText(java.lang.String text)Write some text out.
-
-
-
Field Detail
-
noCommentsOnRemovals
public static boolean noCommentsOnRemovals
If set, then do not suggest comments for removals from the first sentence of the doc block of the old API.
-
noCommentsOnAdditions
public static boolean noCommentsOnAdditions
If set, then do not suggest comments for additions from the first sentence of the doc block of the new API.
-
noCommentsOnChanges
public static boolean noCommentsOnChanges
If set, then do not suggest comments for changes from the first sentence of the doc block of the new API.
-
reportDocChanges
public static boolean reportDocChanges
If set, then report changes in documentation (Javadoc comments) between the old and the new API. The default is that this is not set.
-
newDocPrefix
public static java.lang.String newDocPrefix
Define the prefix for HTML links to the existing set of Javadoc- generated documentation for the new API. E.g. For J2SE1.3.x, use "http://java.sun.com/j2se/1.3/docs/api/"
-
oldDocPrefix
public static java.lang.String oldDocPrefix
Define the prefix for HTML links to the existing set of Javadoc- generated documentation for the old API.
-
doStats
public static boolean doStats
To generate statistical output, set this to true.
-
outputDir
public static java.lang.String outputDir
The destination directory for output files.
-
docTitle
public static java.lang.String docTitle
The title used on the first page of the report. By default, this is "API Differences Between <name of old API> and <name of new API>". It can be set by using the -doctitle option.
-
windowTitle
public static java.lang.String windowTitle
The browser window title for the report. By default, this is "API Differences Between <name of old API> and <name of new API>". It can be set by using the -windowtitle option.
-
-
Method Detail
-
getNewComments
public Comments getNewComments()
Accessor method for the freshly generated Comments object. The list of comments is sorted before the object is returned.
-
generate
public void generate(APIComparator comp, Comments existingComments)
Generate the report.
-
writeReport
public void writeReport(APIDiff apiDiff)
Write the HTML report. The top section describes all the packages added (with links) and removed, and the changed packages section has links which takes you to a section for each package. This pattern continues for classes and constructors, methods and fields.
-
reportChangedPackage
public void reportChangedPackage(jdiff.PackageDiff[] pkgDiffs, int pkgIndex)Write out the details of a changed package in a separate file.
-
reportChangedClass
public void reportChangedClass(java.lang.String pkgName, jdiff.ClassDiff[] classDiffs, int classIndex)Write out the details of a changed class in a separate file.
-
reportAllCtors
public void reportAllCtors(java.lang.String pkgName, jdiff.ClassDiff classDiff)Write out the details of constructors in a class.
-
reportAllMethods
public void reportAllMethods(java.lang.String pkgName, jdiff.ClassDiff classDiff)Write out the details of methods in a class.
-
reportAllFields
public void reportAllFields(java.lang.String pkgName, jdiff.ClassDiff classDiff)Write out the details of fields in a class.
-
writeStartHTMLHeaderWithDate
public void writeStartHTMLHeaderWithDate()
Write the start of the HTML header, together with the current date and time in an HTML comment.
-
writeStartHTMLHeader
public void writeStartHTMLHeader()
Write the start of the HTML header.
-
writeStartHTMLHeader
public void writeStartHTMLHeader(boolean addDate)
Write the start of the HTML header.
-
writeHTMLTitle
public void writeHTMLTitle(java.lang.String title)
Write the HTML title
-
writeStyleSheetRef
public void writeStyleSheetRef()
Write the HTML style sheet reference for files in the subdirectory.
-
writeStyleSheetRef
public void writeStyleSheetRef(boolean inSameDir)
Write the HTML style sheet reference. If inSameDir is set, don't add "../" to the location.
-
writeHTMLFooter
public void writeHTMLFooter()
Write the HTML footer.
-
writeSectionHeader
public void writeSectionHeader(java.lang.String title, java.lang.String packageName, java.lang.String prevElemLink, java.lang.String nextElemLink, java.lang.String className, int level, boolean hasRemovals, boolean hasAdditions, boolean hasChanges)Write a section header, which includes a navigation bar.- Parameters:
title- Title of the header. Contains any links necessary.packageName- The name of the current package, with no slashes or links in it. May be nullprevElemLink- An HTML link to the previous element (a package or class). May be null.nextElemLink- An HTML link to the next element (a package or class). May be null.className- The name of the current class, with no slashes or links in it. May be null.level- 0 = overview, 1 = package, 2 = class/interface
-
writeSectionFooter
public void writeSectionFooter(java.lang.String packageName, java.lang.String prevElemLink, java.lang.String nextElemLink, java.lang.String className, int level)Write a section footer, which includes a navigation bar.- Parameters:
packageName- The name of the current package, with no slashes or links in it. may be nullprevElemLink- An HTML link to the previous element (a package or class). May be null.nextElemLink- An HTML link to the next element (a package or class). May be null.className- The name of the current class, with no slashes or links in it. May be nulllevel- 0 = overview, 1 = package, 2 = class/interface
-
writeNavigationBar
public void writeNavigationBar(java.lang.String pkgName, java.lang.String prevElemLink, java.lang.String nextElemLink, java.lang.String className, int level, boolean upperNavigationBar, boolean hasRemovals, boolean hasAdditions, boolean hasChanges)Write a navigation bar section header.- Parameters:
pkgName- The name of the current package, with no slashes or links in it.prevElemLink- An HTML link to the previous element (a package or class). May be null.nextElemLink- An HTML link to the next element (a package or class). May be null.className- The name of the current class, with no slashes or links in it. May be null.level- 0 = overview, 1 = package, 2 = class/interface
-
writeTableStart
public void writeTableStart(java.lang.String title, int colSpan)Write the start of a table.
-
makeTwoRows
public java.lang.String makeTwoRows(java.lang.String name)
If a class or package name is considered to be too long for convenient display, insert
in the middle of it at a period.
-
writePackageTableEntry
public void writePackageTableEntry(java.lang.String pkgName, int linkType, java.lang.String possibleComment, boolean useOld)Write a table entry for a package, with support for links to Javadoc for removed packages. linkType: 0 - no link by default, 1 = link to Javadoc HTML file, 2 = link to JDiff file
-
writeClassTableEntry
public void writeClassTableEntry(java.lang.String pkgName, java.lang.String className, int linkType, boolean isInterface, java.lang.String possibleComment, boolean useOld)Write a table entry for a class or interface. linkType: 0 - no link by default, 1 = link to Javadoc HTML file, 2 = link to JDiff file
-
writeCtorTableEntry
public void writeCtorTableEntry(java.lang.String pkgName, java.lang.String className, java.lang.String type, int linkType, java.lang.String possibleComment, boolean useOld)Write a table entry for a constructor. linkType: 0 - no link by default, 1 = link to Javadoc HTML file
-
writeCtorChangedTableEntry
public void writeCtorChangedTableEntry(java.lang.String pkgName, java.lang.String className, jdiff.MemberDiff memberDiff)Write a table entry for a changed constructor.
-
writeMethodTableEntry
public void writeMethodTableEntry(java.lang.String pkgName, java.lang.String className, jdiff.MethodAPI methodAPI, int linkType, java.lang.String possibleComment, boolean useOld)Write a table entry for a method. linkType: 0 - no link by default, 1 = link to Javadoc HTML file
-
writeMethodChangedTableEntry
public void writeMethodChangedTableEntry(java.lang.String pkgName, java.lang.String className, jdiff.MemberDiff memberDiff)Write a table entry for a changed method.
-
writeFieldTableEntry
public void writeFieldTableEntry(java.lang.String pkgName, java.lang.String className, jdiff.FieldAPI fieldAPI, int linkType, java.lang.String possibleComment, boolean useOld)Write a table entry for a field. linkType: 0 - no link by default, 1 = link to Javadoc HTML file
-
writeFieldChangedTableEntry
public void writeFieldChangedTableEntry(java.lang.String pkgName, java.lang.String className, jdiff.MemberDiff memberDiff)Write a table entry for a changed field.
-
emitChanges
public void emitChanges(jdiff.MemberDiff memberDiff, int memberType)Emit all changes associated with a MemberDiff as an entry in a table.- Parameters:
memberType- 0 = ctor, 1 = method, 2 = field
-
emitException
public void emitException(java.lang.String ex)
Emit a string which is an exception by surrounding it with <code> tags. If there is a space in the type, e.g. "String, File", then surround it with parentheses too. Do not add <code> tags or parentheses if the String is "no exceptions".
-
emitType
public void emitType(java.lang.String type)
Emit a string which is a type by surrounding it with <code> tags. If there is a space in the type, e.g. "String, File", then surround it with parentheses too.
-
emitTypeWithParens
public static void emitTypeWithParens(java.lang.String type)
Emit a string which is a type by surrounding it with <code> tags. Also surround it with parentheses too. Used to display methods' parameters. Suggestions for where a browser should break the text are provided with <br> and <nobr> tags.
-
emitTypeWithParens
public static void emitTypeWithParens(java.lang.String type, boolean addBreaks)Emit a string which is a type by surrounding it with <code> tags. Also surround it with parentheses too. Used to display methods' parameters.
-
emitTypeWithNoParens
public static void emitTypeWithNoParens(java.lang.String type)
Emit a string which is a type by surrounding it with <code> tags. Do not surround it with parentheses. Used to display methods' return types and field types.
-
simpleName
public static java.lang.String simpleName(java.lang.String fqNames)
Return a String with the simple names of the classes in fqName. "java.lang.String" becomes "String", "java.lang.String, java.io.File" becomes "String, File" and so on. If fqName is null, return null. If fqName is "", return "".
-
emitComment
public void emitComment(java.lang.String commentID, java.lang.String possibleComment, int linkType)Find any existing comment and emit it. Add the new comment to the list of new comments. The first instance of the string "@first" in a hand-written comment will be replaced by the first sentence from the associated doc block, if such exists. Also replace @link by an HTML link.- Parameters:
commentID- The identifier for this comment.possibleComment- A possible comment from another source.linkType- 0 = remove, 1 = add, 2 = change
-
writeTableEnd
public void writeTableEnd()
Write the end of a table.
-
writeText
public void writeText()
Write a newline out.
-
writeText
public void writeText(java.lang.String text)
Write some text out.
-
indent
public void indent(int indent)
Emit some non-breaking space for indentation.
-
-