jdiff

Class Comments

public class Comments extends Object

Creates a Comments from an XML file. The Comments object is the internal representation of the comments for the changes. All methods in this class for populating a Comments object are static. See the file LICENSE.txt for copyright details.
Field Summary
static HashtableallPossibleComments
All the possible comments known about, accessible by the commentID.
ListcommentsList_
static StringplaceHolderText
The text placed into XML comments file where there is no comment yet.
Constructor Summary
Comments()
Default constructor.
Method Summary
voidaddComment(SingleComment comment)
Add the SingleComment object to the list of comments kept by this object.
static StringconvertAtLinks(String text, String currentElement, PackageAPI pkg, ClassAPI cls)
Convert @link tags to HTML links.
voiddump()
Dump the contents of a Comments object out for inspection.
voidemitComments()
Write the Comments object out in XML.
voidemitXMLFooter()
Emit the XML footer.
voidemitXMLHeader(String filename)
Emit the XML header.
static StringgetComment(Comments comments, String id)
Return the comment associated with the given id in the Comment object.
static booleanisMinimizedTag(String tag)
Return true if the given HTML tag has no separate end element.
static voidnoteDifferences(Comments oldComments, Comments newComments)
Emit messages about which comments are now unused and which are new.
static CommentsreadFile(String filename)
Read the file where the XML for comments about the changes between the old API and new API is stored and create a Comments object for it.
static booleanwriteFile(String outputFileName, Comments newComments)
Write the XML representation of comments to a file.
static voidwriteXSD(String filename)
Write the XML Schema file used for validation.

Field Detail

allPossibleComments

public static Hashtable allPossibleComments
All the possible comments known about, accessible by the commentID.

commentsList_

public List commentsList_

placeHolderText

public static final String placeHolderText
The text placed into XML comments file where there is no comment yet. It never appears in reports.

Constructor Detail

Comments

public Comments()
Default constructor.

Method Detail

addComment

public void addComment(SingleComment comment)
Add the SingleComment object to the list of comments kept by this object.

convertAtLinks

public static String convertAtLinks(String text, String currentElement, PackageAPI pkg, ClassAPI cls)
Convert @link tags to HTML links.

dump

public void dump()
Dump the contents of a Comments object out for inspection.

emitComments

public void emitComments()
Write the Comments object out in XML.

emitXMLFooter

public void emitXMLFooter()
Emit the XML footer.

emitXMLHeader

public void emitXMLHeader(String filename)
Emit the XML header.

getComment

public static String getComment(Comments comments, String id)
Return the comment associated with the given id in the Comment object. If there is no such comment, return the placeHolderText.

isMinimizedTag

public static boolean isMinimizedTag(String tag)
Return true if the given HTML tag has no separate end element. If you want to be able to use sloppy HTML in your comments, then you can add the element, e.g. li back into the condition here. However, if you then become more careful and do provide the closing tag, the output is generally just the closing tag, which is incorrect. tag.equalsIgnoreCase("tr") || // Is sometimes minimized tag.equalsIgnoreCase("th") || // Is sometimes minimized tag.equalsIgnoreCase("td") || // Is sometimes minimized tag.equalsIgnoreCase("dt") || // Is sometimes minimized tag.equalsIgnoreCase("dd") || // Is sometimes minimized tag.equalsIgnoreCase("img") || // Is sometimes minimized tag.equalsIgnoreCase("code") || // Is sometimes minimized (error) tag.equalsIgnoreCase("font") || // Is sometimes minimized (error) tag.equalsIgnoreCase("ul") || // Is sometimes minimized tag.equalsIgnoreCase("ol") || // Is sometimes minimized tag.equalsIgnoreCase("li") // Is sometimes minimized

noteDifferences

public static void noteDifferences(Comments oldComments, Comments newComments)
Emit messages about which comments are now unused and which are new.

readFile

public static Comments readFile(String filename)
Read the file where the XML for comments about the changes between the old API and new API is stored and create a Comments object for it. The Comments object may be null if no file exists.

writeFile

public static boolean writeFile(String outputFileName, Comments newComments)
Write the XML representation of comments to a file.

Parameters: outputFileName The name of the comments file. oldComments The old comments on the changed APIs. newComments The new comments on the changed APIs.

Returns: true if no problems encountered

writeXSD

public static void writeXSD(String filename)
Write the XML Schema file used for validation.