private void writeLogEntry(PrintWriter out, LogEntry logEntry) { if (logEntry.getEntriesCount() == 0) { return; } String message = logEntry.getMessage().replace(QUOTE_CHARACTER, QUOTE_SPECIAL_CHARACTER); message = message.replace(ANGLE_OPENING_BRACKET_CHARACTER, ANGLE_OPENING_BRACKET_SPECIAL_CHARACTER); message = message.replace(ANGLE_CLOSING_BRACKET_CHARACTER, ANGLE_CLOSING_BRACKET_SPECIAL_CHARACTER); out.println( MessageFormat.format( LOGENTRY_START_NODE, new String[] {message, Integer.toString(logEntry.getRevision()), logEntry.getDate()})); List<PathEntry> pathEntries = logEntry.getPathEntries(); for (PathEntry pathEntry : pathEntries) { out.println( MessageFormat.format( PATH_NODE, new String[] {pathEntry.getAction(), pathEntry.getPath()})); } out.println(LOGENTRY_END_NODE); }
public void writeReport(String file, XSLTProcess xsltTask) { String tempFile = file + "__"; PrintWriter out = null; try { out = new PrintWriter(new OutputStreamWriter(new FileOutputStream(tempFile, false), "UTF-8")); writeReport(out); } catch (UnsupportedEncodingException e) { throw new BuildException( "Failed to create temporary file \"" + tempFile + "\" with UTF-8 encoding", e); } catch (FileNotFoundException e) { throw new BuildException( "Failed to create temporary file \"" + tempFile + "\" for report", e); } finally { if (out != null) { out.close(); } } xsltTask.setIn(new File(tempFile)); xsltTask.setOut(new File(file)); xsltTask.perform(); (new File(tempFile)).delete(); }
private void writeReport(PrintWriter out) { out.println(XML_HEADER); out.println(REPORT_START_NODE); writeSummary(out); writeChanges(out); out.println(REPORT_END_NODE); }
private void writeSummary(PrintWriter out) { out.println(SUMMARY_START_NODE); out.println( MessageFormat.format( CHANGES_START_NODE, new String[] {Integer.toString(getLogEntriesCount())})); List<String> authors = getAuthors(); for (String author : authors) { out.println( MessageFormat.format( AUTHOR_SUMMARY_NODE, new String[] { author, Integer.toString(getAuthorLogEntriesCount(author)), Integer.toString(getAuthorLogEntriesPercent(author)) })); } out.println(CHANGES_END_NODE); out.println(SUMMARY_END_NODE); }
private void writeChanges(PrintWriter out) { List<String> authors = getAuthors(); for (String author : authors) { List<LogEntry> logEntries = getOrderedAuthorLogEntries(author); if (logEntries == null || logEntries.isEmpty()) { continue; } out.println( MessageFormat.format( AUTHOR_START_NODE, new String[] { author, Integer.toString(getAuthorLogEntriesCount(author)), Integer.toString(logEntries.size()) })); for (LogEntry logEntry : logEntries) { writeLogEntry(out, logEntry); } out.println(AUTHOR_END_NODE); } }