bump product version to 4.1.6.2
[LibreOffice.git] / qadevOOo / runner / stats / InternalLogWriter.java
blob052baf5b94874814e4a392155bea126f13b215eb
1 /*
2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 package stats;
20 import java.io.PrintWriter;
21 import java.io.StringWriter;
23 /**
24 * Write all logs into a java.io.PrintWriter, i.e. a StringBuffer.
25 * Log is gathered there.
27 public class InternalLogWriter extends PrintWriter
28 implements share.LogWriter {
29 /** log active **/
30 boolean active;
31 /** write all output to a StringBuffer **/
32 static StringWriter writer = new StringWriter();
34 /**
35 * c'*tor
37 public InternalLogWriter() {
38 super(new PrintWriter(writer));
39 active = true;
42 /**
43 * Initialization.
44 * @param entry The description entry.
45 * @param active Logging is active.
46 * @return True, if initialize worked.
48 public boolean initialize(share.DescEntry entry, boolean active) {
49 this.active = active;
50 return true;
53 /**
54 * Method to print a line that is added to the StringBuffer.
55 * @param msg The message that is printed.
57 public void println(String msg) {
58 if (active)
59 super.println(msg);
62 /**
63 * Method to print to the StringBuffer.
64 * @param msg The message that is printed.
66 public void print(String msg) {
67 if (active)
68 super.print(msg);
72 /**
73 * Is used to sum up the information.
74 * The summary is also added to the StringBuffer.
75 * @param entry The description entry.
76 * @return True, if a summary could be created.
78 public boolean summary(share.DescEntry entry) {
79 // linePrefix = "";
80 String header = "***** State for "+entry.longName+" ******";
81 println(header);
82 if (entry.hasErrorMsg) {
83 println(entry.ErrorMsg);
84 println("Whole "+entry.EntryType+": "+entry.State);
85 } else {
86 println("Whole "+entry.EntryType+": "+entry.State);
88 for (int i=0;i<header.length();i++) {
89 print("*");
91 println("");
92 return true;
95 /**
96 * Return all the written stuff.
97 * @return All that was written to the StringBuffer with the
98 * 'println()', 'print()' and 'summarize()' methods.
99 * The StringBuffer is emptied afterwards.
101 public String getLog() {
102 String message = writer.getBuffer().toString();
103 writer = new StringWriter();
104 return message;
107 public Object getWatcher() {
108 return null;
111 public void setWatcher(Object watcher) {