Show SimpleReport.java syntax highlighted
/*
* This file is distributed under the GPL v2 as part of teastats site statistics package
* http://teastats.sourceforge.net
*/
package
net.time4tea.webstats.report;
import net.time4tea.webstats.statistic.Statistic;
import net.time4tea.webstats.statistic.StatisticMap;
import net.time4tea.webstats.statistic.comparator.ByHitsComparator;
import net.time4tea.webstats.statistic.comparator.ReverseComparator;
import java.io.PrintStream;
import java.util.Formatter;
/**
* Originally richja Apr 11, 2006
*/
public class SimpleReport {
PrintStream stream;
public SimpleReport(PrintStream stream) {
this.stream = stream;
}
public SimpleReport() {
stream = System.out;
}
public void doReport(StatisticMap statisticMap) {
Formatter formatter = new Formatter(stream);
String format = "%50s %6d %10d\n";
stream.println();
stream.println("-------->");
stream.println(statisticMap.getName());
stream.println("-------->");
for (String key : statisticMap.keys(new ReverseComparator(new ByHitsComparator()))) {
Statistic counter = statisticMap.get(key);
formatter.format(format, counter.getKey(), counter.getCount(), counter.getSum());
}
}
}
See more files for this project here