ChangeLogWriterpublic class ChangeLogWriter extends Object Class used to generate an XML changelog. |
Fields Summary |
---|
private static final SimpleDateFormat | OUTPUT_DATEoutput format for dates written to xml file | private static final SimpleDateFormat | OUTPUT_TIMEoutput format for times written to xml file | private static final org.apache.tools.ant.util.DOMElementWriter | DOM_WRITERstateless helper for writing the XML document |
Methods Summary |
---|
public void | printChangeLog(java.io.PrintWriter output, CVSEntry[] entries)Print out the specified entries.
TimeZone utc = TimeZone.getTimeZone("UTC");
OUTPUT_DATE.setTimeZone(utc);
OUTPUT_TIME.setTimeZone(utc);
try {
output.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
Document doc = DOMUtils.newDocument();
Element root = doc.createElement("changelog");
DOM_WRITER.openElement(root, output, 0, "\t");
output.println();
for (int i = 0; i < entries.length; i++) {
final CVSEntry entry = entries[i];
printEntry(doc, output, entry);
}
DOM_WRITER.closeElement(root, output, 0, "\t", true);
output.flush();
output.close();
} catch (IOException e) {
throw new org.apache.tools.ant.BuildException(e);
}
| private void | printEntry(org.w3c.dom.Document doc, java.io.PrintWriter output, CVSEntry entry)Print out an individual entry in changelog.
Element ent = doc.createElement("entry");
DOMUtils.appendTextElement(ent, "date",
OUTPUT_DATE.format(entry.getDate()));
DOMUtils.appendTextElement(ent, "time",
OUTPUT_TIME.format(entry.getDate()));
DOMUtils.appendCDATAElement(ent, "author", entry.getAuthor());
final Enumeration enumeration = entry.getFiles().elements();
while (enumeration.hasMoreElements()) {
final RCSFile file = (RCSFile) enumeration.nextElement();
Element f = DOMUtils.createChildElement(ent, "file");
DOMUtils.appendCDATAElement(f, "name", file.getName());
DOMUtils.appendTextElement(f, "revision", file.getRevision());
final String previousRevision = file.getPreviousRevision();
if (previousRevision != null) {
DOMUtils.appendTextElement(f, "prevrevision",
previousRevision);
}
}
DOMUtils.appendCDATAElement(ent, "msg", entry.getComment());
DOM_WRITER.write(ent, output, 1, "\t");
|
|