org.vishia.mainCmd
Interface Report

All Known Subinterfaces:
MainCmd_ifc
All Known Implementing Classes:
CmdHeader2Reflection, CorrectHref.Main, Java2C, Main.CmdLine, MainCmd, MainCmdSwt, MainCmdWin, Menu, SampleCmdLine.CmdLine, SampleGuiSwtButtonInput.MainCmd, SampleZbnfJava, SocketTester, Textfile2Html, Xslt.CmdLine, Xsltpre.CmdLine, Zbnf2Xml.CmdLine, ZbnfGui, Zmake.CmdLine

public interface Report

This interface is the access to output Log- or report messages while running an application to check its work. In opposite to the LogMessage, the report-interface doesn't use ident-numbers... Dieses Interface dient zur Ausgabe von Reportmeldungen for kommandozeilenartige Abarbeitung. This interface is usefull for reporting something (logfiles). It should be used in every algorithm routine to support debugging without using an extra debugger. It may help to encircle problems.


date       who       change
2007-12-29 HartmutS  some methods from mainCmd_ifc are displaced here. 
                     Thus the Report interface is revalued to write some informations also to the display
                     with the capability to control the report levels for that in the implementation.
2006-01-07 HartmutS  initial revision



Field Summary
static int anytime
          Deprecated. use instead Report.error or Report.errorDisplay
static int debug
          report level to indicate the report should be written to detect problems in software.
static int error
          report level to indicate the report should be written anytime and anyway.
static int eventOrder
          Deprecated. use instead Report.info or Report.infoDisplay
static int exitSuccessfull
          exit value to indicate not at all problems.
static int exitUserAbort
          exit value to indicate a unconditional abort of a process.
static int exitWithArgumentError
          exit value to indicate a parameter error, that is a programmers error mostly.
static int exitWithErrors
          exit value to indicate a error in the own process, at example due to failed data
static int exitWithFileProblems
          exit value to indicate a file error, typicall write to a read only file, write to a failed directory, file not exists and others.
static int exitWithNotes
          exit value to indicate the user should read something and medidate about.
static int exitWithWarnings
          exit value to indicate some warnings, but no fatal errors.
static int fineDebug
          report level to indicate all report should be written to detect problems in software with finely and heavyset reports.
static int fineEventOrder
          Deprecated. use instead Report.fineInfo or Report.infoDisplay
static int fineInfo
          report level to indicate the report should be written if a user is interested on the order of the events finely.
static int info
          report level to indicate the report should be written if a user is interested on notes of the progression of programm is working.
static int interested
          Deprecated. use instead Report.warning or Report.warningDisplay
static int mNeverOutputToDisplay
          Mask bit to indicate, do not write to display.
static int mReportLevel
          Mask for the in fact reportlevel, other bits may have another meaning.
static int warning
          report level to indicate the report should be written if a user is interested on warnings.
 
Method Summary
 void flushReport()
          Writes the content in the physical medium.
 int getExitErrorLevel()
          get the errorLevel setted with setExitErrorLevel().
 LogMessage getLogMessageOutputConsole()
          Gets a LogMessage output.
 LogMessage getLogMessageOutputFile()
          Gets a LogMessage output.
 int getReportLevel()
          access to the level of report.
 int getReportLevelFromIdent(int ident)
          gets the associated report level to a report identifier.
 void openReportfile(java.lang.String sFileReport, boolean bAppendReport)
           
 void report(int nLevel, java.lang.String string)
          report inside a line
 void report(java.lang.String sText, java.lang.Exception exception)
          report of a excpetion (in a new line)
 void reportln(int nLevel, int nLeftMargin, java.lang.String string)
          report begins at a new a line with left margin
 void reportln(int nLevel, java.lang.String string)
          report begins at a new a line
 void setExitErrorLevel(int level)
          set the exitErrorLevel of the maximum of given level of every call.
 void setReportLevelToIdent(int ident, int nLevelActive)
          Sets a dedicated level number to the known output priorities.
 void writeError(java.lang.String sError)
          Writes an error line.
 void writeError(java.lang.String sError, java.lang.Exception exception)
          Writes an error line caused by an exception.
 void writeInfo(java.lang.String sInfo)
          Appends an info to the end of the previous info, @see #writeInfoln.
 void writeInfoln(java.lang.String sInfo)
          Writes an info line.
 void writeWarning(java.lang.String sError)
          Writes an error line.
 

Field Detail

exitUserAbort

static final int exitUserAbort
exit value to indicate a unconditional abort of a process.

See Also:
Constant Field Values

exitWithArgumentError

static final int exitWithArgumentError
exit value to indicate a parameter error, that is a programmers error mostly.

See Also:
Constant Field Values

exitWithFileProblems

static final int exitWithFileProblems
exit value to indicate a file error, typicall write to a read only file, write to a failed directory, file not exists and others.

See Also:
Constant Field Values

exitWithErrors

static final int exitWithErrors
exit value to indicate a error in the own process, at example due to failed data

See Also:
Constant Field Values

exitWithWarnings

static final int exitWithWarnings
exit value to indicate some warnings, but no fatal errors. Warnings may be errors in consequence later.

See Also:
Constant Field Values

exitWithNotes

static final int exitWithNotes
exit value to indicate the user should read something and medidate about.

See Also:
Constant Field Values

exitSuccessfull

static final int exitSuccessfull
exit value to indicate not at all problems.

See Also:
Constant Field Values

error

static final int error
report level to indicate the report should be written anytime and anyway. Useable especially for errors

See Also:
Constant Field Values

warning

static final int warning
report level to indicate the report should be written if a user is interested on warnings.

See Also:
Constant Field Values

info

static final int info
report level to indicate the report should be written if a user is interested on notes of the progression of programm is working.

See Also:
Constant Field Values

fineInfo

static final int fineInfo
report level to indicate the report should be written if a user is interested on the order of the events finely.

See Also:
Constant Field Values

debug

static final int debug
report level to indicate the report should be written to detect problems in software.

See Also:
Constant Field Values

fineDebug

static final int fineDebug
report level to indicate all report should be written to detect problems in software with finely and heavyset reports.

See Also:
Constant Field Values

mReportLevel

static final int mReportLevel
Mask for the in fact reportlevel, other bits may have another meaning.

See Also:
Constant Field Values

mNeverOutputToDisplay

static final int mNeverOutputToDisplay
Mask bit to indicate, do not write to display. This bit is used internally in MainCmd. It is outside the mReportLevel-mask.

See Also:
Constant Field Values

anytime

static final int anytime
Deprecated. use instead Report.error or Report.errorDisplay
older reportlevel

See Also:
Constant Field Values

interested

static final int interested
Deprecated. use instead Report.warning or Report.warningDisplay
older reportlevel

See Also:
Constant Field Values

eventOrder

static final int eventOrder
Deprecated. use instead Report.info or Report.infoDisplay
older reportlevel

See Also:
Constant Field Values

fineEventOrder

static final int fineEventOrder
Deprecated. use instead Report.fineInfo or Report.infoDisplay
older reportlevel

See Also:
Constant Field Values
Method Detail

writeInfoln

void writeInfoln(java.lang.String sInfo)
Writes an info line. This method should be used instead a directly write via System.out.println(...). The using of System.out writes the output directly on console window of the command line, but in general, the user mostly don't want to write to the console, he only will give an information out. In a GUI-application, this information can be displayed in a status line or scrolling output window. It may also be possible to write the information in a file additional. The implementation of this method writes the output in the conformed way to the application frame.
Before output, the previous line is terminated by a newline, or a status line will be cleared.

Parameters:
sInfo - String to be written.

writeInfo

void writeInfo(java.lang.String sInfo)
Appends an info to the end of the previous info, @see #writeInfoln.

Parameters:
sInfo - String to be written.

writeWarning

void writeWarning(java.lang.String sError)
Writes an error line. This method should be used instead a directly write via System.err.println(...). The using of System.err writes the output directly on console window of the command line, but in general, the user mostly don't want to write to the console, he will give an information out. In a GUI-application, this information can be displayed in a status line or scrolling output window. It may also be possible to write the information in a file additional. The implementation of this method writes the output in the conformed way to the application frame.
Before output, the previous line is terminated by a newline, or a status line will be cleared.

Parameters:
sError - The error text, it should be without such hot spot words line "!!!WARNING!!!", because the distinction in display should be done by the implementation of this method. A good sample is writeErrorln("file is empty: " + sFileName);

writeError

void writeError(java.lang.String sError)
Writes an error line. This method should be used instead a directly write via System.err.println(...). The using of System.err writes the output directly on console window of the command line, but in general, the user mostly don't want to write to the console, he will give an information out. In a GUI-application, this information can be displayed in a status line or scrolling output window. It may also be possible to write the information in a file additional. The implementation of this method writes the output in the conformed way to the application frame.
Before output, the previous line is terminated by a newline, or a status line will be cleared.

Parameters:
sError - The error text, it should be without such hot spot words line "!!!ERROR!!!", because the distinction in display should be done by the implementation of this method. A good sample is writeErrorln("cannot create file: " + sFileName);

writeError

void writeError(java.lang.String sError,
                java.lang.Exception exception)
Writes an error line caused by an exception. This method should be used instead a directly write via System.err.println(...) and by catching an exception. The using of System.err writes the output directly on console window of the command line, but in general, the user mostly don't want to write to the console, he will give an information out. In a GUI-application, this information can be displayed in a status line or scrolling output window. It may also be possible to write the information in a file additional. The implementation of this method writes the output in the conformed way to the application frame.
Before output, the previous line is terminated by a newline, or a status line will be cleared.

Parameters:
sError - The error text, it should be without such hot spot words line "!!!ERROR!!!", because the distinction in display should be done by the implementation of this method. A good sample is writeErrorln("cannot create file: " + sFileName);
exception - The catched Exception. The getMessage()-part of the exception is written after sError. The stacktrace of the exception is written to report.

openReportfile

void openReportfile(java.lang.String sFileReport,
                    boolean bAppendReport)
                    throws java.io.FileNotFoundException
Throws:
java.io.FileNotFoundException

report

void report(int nLevel,
            java.lang.String string)
report inside a line


reportln

void reportln(int nLevel,
              int nLeftMargin,
              java.lang.String string)
report begins at a new a line with left margin

Parameters:
nLevel - write the report only if the demand level is greater or equal.
nLeftMargin - determins a left margin. First a new line is outputted, followed by '*' and spaces.
string - String to write.

reportln

void reportln(int nLevel,
              java.lang.String string)
report begins at a new a line

Parameters:
nLevel - write the report only if the demand level is greater or equal.
string - String to write.

report

void report(java.lang.String sText,
            java.lang.Exception exception)
report of a excpetion (in a new line)


getReportLevel

int getReportLevel()
access to the level of report. With the knowledge of the maximal reportlevel the user can decide on some actions in context of report.

Returns:
The report level, defined by user invoking.

flushReport

void flushReport()
Writes the content in the physical medium. The implementation of flush is in the best way as possible. It depends on the possibilities of the output medium.


setReportLevelToIdent

void setReportLevelToIdent(int ident,
                           int nLevelActive)
Sets a dedicated level number to the known output priorities. This method helps to define several levels to dispatch it.

Parameters:
nLevel - The number identifying a dedicated level. This number should be greater than the known priority levels, it means >= 10 or >=1000. Use dedicated group of numbers for an application.
nLevelActive - Ones of the known priotity levels Report.error to Report.fineDebug.
Example of using:
   class MyModule
   { /**Define module-specific numbers to identify a level. 
      * The numbers should be define regarding a band of numbers in the application.
      * /  
     static final int myReportLevel1 = 3500, myReportLevel2=3501; 
     
     void init()
     { setLevelActive(myReportLevel1, Report.info);  //This reports should be outputted always
       setLevelActive(myReportLevel2, Report.debug); //This reports are debug infos.
     }
     
     void processAnything()
     { report.reportln( myReportLevel1, "InfoText"); //It depends on the report level settings 
       report.reportln( myReportLevel2, "DebugText");//wether it is outputted or not. 
     }  
 

getLogMessageOutputConsole

LogMessage getLogMessageOutputConsole()
Gets a LogMessage output.

Returns:
never null.

getLogMessageOutputFile

LogMessage getLogMessageOutputFile()
Gets a LogMessage output.

Returns:
never null.

getReportLevelFromIdent

int getReportLevelFromIdent(int ident)
gets the associated report level to a report identifier.

Parameters:
ident - The identifier.
Returns:
the level.

setExitErrorLevel

void setExitErrorLevel(int level)
set the exitErrorLevel of the maximum of given level of every call.

Parameters:
level - Errorlevel how defined in Report, 0 is the lowest level (successfull), >0 is worse.

getExitErrorLevel

int getExitErrorLevel()
get the errorLevel setted with setExitErrorLevel().