您的位置:首页 > 编程语言

report代码分析3--Report

2015-11-13 16:26 295 查看
A bstract superclass for all reports所有报告的抽象父类

outline





public abstract class Report{}

public Report(){} //构造方法,若未设置className.output,则
使用scenarioname_classname.txt作为文件名,并从相关setting中读取设置

private void checkDirExistence(String outFileName)

private boolean createDirs(File directory) //查看是否存在文件目录,若无,则新建

protected void init() //初始化报告输出。在每个报告文件开始都需要调用

{
this.lastReportTime = getSimTime();

if (outputInterval > 0) {
createSuffixedOutput(outFileName);
}
else {
createOutput(outFileName);
}
}

private void createOutput(String outFileName) //创建新的输出文件

private void createSuffixedOutput(String outFileName)
//创建新的数字后缀(逐渐增加)的输出

protected void newEvent() //每一个新的报告事件生成前调用

{
if (this.outputInterval <= 0) {
return;
}

if (getSimTime() > this.lastReportTime + this.outputInterval) {
done(); // finalize the old file
init(); // init the new file
}
}

protected void write(String txt)
//使用固定的格式输出
{
if (out == null) {
init();
}
out.println(prefix + txt);
//protected PrintWriter out;
}

protected String format(double value) //格式化

{
return String.format("%." + precision + "f", value);
}

protected void setPrefix(String txt) //设置后缀

protected String getScenarioName() //返回场景名称

protected double getSimTime()
//返回当前模拟时间
{
return SimClock.getTime();
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: