merged tag ooo/DEV300_m102
[LibreOffice.git] / qadevOOo / runner / stats / SimpleFileOutProducer.java
blobe03cf374e187fea47822a5b22bb9a6f78971e5e8
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 package stats;
30 import share.LogWriter;
31 import java.io.File;
32 import java.io.FileWriter;
34 public class SimpleFileOutProducer implements LogWriter {
37 /** initialization, here a filename might be given
38 * or a dbUrL
40 public boolean initialize(share.DescEntry entry, boolean active) {
41 return true;
44 /** Method to print
46 public void println(String msg) {
50 /** will mostly be used by outproducers to sum up
51 * the information, maybe write them to a db
53 public boolean summary(share.DescEntry entry) {
54 try {
55 String outpath = (String) entry.UserDefinedParams.get("OutputPath");
56 if (outpath==null) {
57 System.out.println("## Parameter OutputPath isn't defined using default");
58 return summary_default(entry);
60 String FileName = entry.longName + ".out";
61 if (!entry.EntryType.equals("component")) {
62 FileName = entry.longName.substring(0,
63 entry.longName.indexOf(":")) + ".out";
65 util.utils.make_Directories("",outpath);
66 File outputFile = new File(outpath, FileName);
67 FileWriter out = new FileWriter(outputFile.toString(),true);
68 String ls = System.getProperty("line.separator");
69 String date = new java.util.Date().toString();
70 String header = "***** State for "+entry.longName+"( "+ date +" ) ******";
71 out.write(header+ls);
72 if (entry.hasErrorMsg) {
73 out.write(entry.ErrorMsg+ls);
74 out.write("Whole "+entry.EntryType+": "+entry.State+ls);
75 } else {
76 out.write("Whole "+entry.EntryType+": "+entry.State+ls);
78 String bottom="";
79 for (int i=0;i<header.length();i++) {
80 bottom += "*";
82 out.write(bottom+ls);
83 out.write(""+ls);
84 out.close();
85 } catch (java.io.IOException e) {
88 return true;
91 public boolean summary_default(share.DescEntry entry) {
92 String header = "***** State for "+entry.longName+" ******";
93 System.out.println(header);
94 if (entry.hasErrorMsg) {
95 System.out.println(entry.ErrorMsg);
96 System.out.println("Whole "+entry.EntryType+": "+entry.State);
97 } else {
98 System.out.println("Whole "+entry.EntryType+": "+entry.State);
100 for (int i=0;i<header.length();i++) {
101 System.out.print("*");
103 System.out.println("");
104 return true;
107 public Object getWatcher() {
108 return null;
111 public void setWatcher(Object watcher) {