org.eclipse.actf.util.logging
Class PrintWriterReporter

java.lang.Object
  extended by org.eclipse.actf.util.logging.AbstractReporter
      extended by org.eclipse.actf.util.logging.PrintWriterReporter
All Implemented Interfaces:
IReporter

public class PrintWriterReporter
extends AbstractReporter

implementation to generate report records to the specified PrintWriter object.

Author:
Barry Feigenbaum

Field Summary
protected  StringBuffer formatBuffer
           
protected  StringBuffer lastReportBuffer
           
protected  int[] levelCount
           
protected  boolean open
           
protected  boolean reportStarted
           
protected  PrintWriter writer
           
 
Fields inherited from class org.eclipse.actf.util.logging.AbstractReporter
bundle, categories, CATEGORY_FORMATTER, categoryFormatter, defaultOutputLevel, errorLoggers, SOURCE_ID_MAP, sourceID
 
Fields inherited from interface org.eclipse.actf.util.logging.IReporter
CONFIG, CONFIGURATION, DEFAULT_LEVEL, DETAIL, ERROR, INFO, KEYS, MAX_LEVEL, MIN_LEVEL, SEVERE, SYSTEM_FATAL, SYSTEM_NONFATAL, TRACE, UNKNOWN, USER, VALIDATION, WARNING
 
Constructor Summary
PrintWriterReporter(PrintWriter writer)
          create a new reporter using the given PrintWriter
PrintWriterReporter(PrintWriter writer, ResourceBundle bundle)
          create a new reporter using the given PrintWriter
 
Method Summary
 void addReportRecords(List records)
           
 void close()
          close processing
 void endReport()
          ends a report started with startReport.
 void flush()
          Flush any pending output
 int getErrorCount()
          return the number of errors reported thus far by this reporter.
 String getLastReport()
          get the last reported message
 int getLevelCount(int level)
          return the number of messages at the given level reported thus far by this reporter.
 String getMethodNameFromStack()
          Get the class and method name that called PrintUtils.println().
 String getMethodNameFromStack(int numLinesToIgnore)
          Returns the class and method name from a line in the stack.
 PrintWriter getPrintWriter()
          get the PrintWriter being used by this Reporter
 String getThreadInfo()
          Get info about the calling Thread.
 int getWarningCount()
          return the number of warnings reported thus far by this reporter.
 boolean isOpen()
          returns whether or not this reporter is open
 boolean isReportStarted()
           
 void open()
          Open for processing
 void report(int level, String message, Object[] values)
          report the message at the given level with the given substitution values
 void reset()
          reset the reporter. This method should clear all categories and all remaining buffers and report records.
 void resetCount()
          reset the counts to 0.
 void setLastReport(String reportText)
          set the last report on this reporter.
 void startReport(Object comp)
          start a new report.
 String toString()
           
 
Methods inherited from class org.eclipse.actf.util.logging.AbstractReporter
endCategory, endCategory, getCategory, getCategoryFormatter, getDefaultOutputLevel, getReporter, getResourceBundle, getSourceID, getSourceIDString, registerErrorLogger, report, report, report, report, report, report, setCategoryFormatter, setDefaultOutputLevel, setResourceBundle, setSourceID, startCategory, unregisterErrorLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

writer

protected PrintWriter writer

levelCount

protected int[] levelCount

open

protected boolean open

formatBuffer

protected StringBuffer formatBuffer

lastReportBuffer

protected StringBuffer lastReportBuffer

reportStarted

protected boolean reportStarted
Constructor Detail

PrintWriterReporter

public PrintWriterReporter(PrintWriter writer)
create a new reporter using the given PrintWriter

Parameters:
writer - -- underlying PrintWriter

PrintWriterReporter

public PrintWriterReporter(PrintWriter writer,
                           ResourceBundle bundle)
create a new reporter using the given PrintWriter

Parameters:
writer - -- underlying PrintWriter
bundle -
Method Detail

reset

public void reset()
reset the reporter. This method should clear all categories and all remaining buffers and report records.

Specified by:
reset in interface IReporter
Overrides:
reset in class AbstractReporter

getPrintWriter

public PrintWriter getPrintWriter()
get the PrintWriter being used by this Reporter

Returns:
underlying PrintWriter

getErrorCount

public int getErrorCount()
return the number of errors reported thus far by this reporter.

Returns:
number of errors reported

getWarningCount

public int getWarningCount()
return the number of warnings reported thus far by this reporter.

Returns:
number of warnings reported

getLevelCount

public int getLevelCount(int level)
return the number of messages at the given level reported thus far by this reporter.

Parameters:
level - - level of messages to be counted
Returns:
number of messages at the given level reported

resetCount

public void resetCount()
reset the counts to 0.


getLastReport

public String getLastReport()
get the last reported message

Returns:
last reported message

toString

public String toString()
Overrides:
toString in class Object

open

public void open()
Open for processing


isOpen

public boolean isOpen()
returns whether or not this reporter is open

Returns:
true if has been opened, false otherwise
See Also:
IReporter.open()

close

public void close()
close processing


report

public void report(int level,
                   String message,
                   Object[] values)
report the message at the given level with the given substitution values

See Also:
IReporter.report(int, String)

flush

public void flush()
Flush any pending output


isReportStarted

public boolean isReportStarted()

startReport

public void startReport(Object comp)
start a new report. Every call of this method must be matched with a corresponding endReport call.

Parameters:
comp - - root component for which report is being generated

endReport

public void endReport()
ends a report started with startReport. Once this method is called, the getLastReport method can be called in order to supply the report generated betwen the startReport call and this call.


setLastReport

public void setLastReport(String reportText)
set the last report on this reporter. This method is only used in ValidationLauncher.DISTINCT_JVM after the launcher gets an indication that a report has completed.

Parameters:
reportText - - last report generated

getThreadInfo

public String getThreadInfo()
Get info about the calling Thread.

Returns:
String the id and name of the Thread.

getMethodNameFromStack

public String getMethodNameFromStack()
Get the class and method name that called PrintUtils.println(). In order to get the caller to PrintUtils.println() we need to go 6 deep into the stack.

Returns:
String the class and method name.

getMethodNameFromStack

public String getMethodNameFromStack(int numLinesToIgnore)
Returns the class and method name from a line in the stack.

Parameters:
numLinesToIgnore - number of lines in the stack trace to ignore
Returns:
String the class and method name from the specific line in the stack trace.

addReportRecords

public void addReportRecords(List records)