Class StreamMsgLogger

java.lang.Object
jj2000.j2k.util.StreamMsgLogger
All Implemented Interfaces:
MsgLogger

public class StreamMsgLogger extends Object implements MsgLogger
This class implements the MsgLogger interface for streams. Streams can be simple files, terminals, stdout, stderr, etc. The messages or simple strings are formatted using the linewidth given to the constructor.

Messages are printed to the 'err' stream if they are of severity WARNING or ERROR, otherwise they are printed to the 'out' stream. Simple strings are always printed the 'out' stream.

  • Field Summary

    Fields inherited from interface jj2000.j2k.util.MsgLogger

    ERROR, INFO, LOG, WARNING
  • Constructor Summary

    Constructors
    Constructor
    Description
    StreamMsgLogger(OutputStream outstr, OutputStream errstr, int lw)
    Constructs a StreamMsgLogger that uses 'outstr' as the 'out' stream, and 'errstr' as the 'err' stream.
    StreamMsgLogger(PrintWriter outstr, PrintWriter errstr, int lw)
    Constructs a StreamMsgLogger that uses 'outstr' as the 'out' stream, and 'errstr' as the 'err' stream.
    StreamMsgLogger(Writer outstr, Writer errstr, int lw)
    Constructs a StreamMsgLogger that uses 'outstr' as the 'out' stream, and 'errstr' as the 'err' stream.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Writes any buffered data from the print() and println() methods to the device.
    void
    println(String str, int flind, int ind)
    Prints the string 'str' to the 'out' stream, appending a newline.
    void
    printmsg(int sev, String msg)
    Prints the message 'msg' to the output device, appending a newline, with severity 'sev'.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • StreamMsgLogger

      public StreamMsgLogger(OutputStream outstr, OutputStream errstr, int lw)
      Constructs a StreamMsgLogger that uses 'outstr' as the 'out' stream, and 'errstr' as the 'err' stream. Note that 'outstr' and 'errstr' can be System.out and System.err.
      Parameters:
      outstr - Where to print simple strings and LOG and INFO messages.
      errstr - Where to print WARNING and ERROR messages
      lw - The line width to use in formatting
    • StreamMsgLogger

      public StreamMsgLogger(Writer outstr, Writer errstr, int lw)
      Constructs a StreamMsgLogger that uses 'outstr' as the 'out' stream, and 'errstr' as the 'err' stream. Note that 'outstr' and 'errstr' can be System.out and System.err.
      Parameters:
      outstr - Where to print simple strings and LOG and INFO messages.
      errstr - Where to print WARNING and ERROR messages
      lw - The line width to use in formatting
    • StreamMsgLogger

      public StreamMsgLogger(PrintWriter outstr, PrintWriter errstr, int lw)
      Constructs a StreamMsgLogger that uses 'outstr' as the 'out' stream, and 'errstr' as the 'err' stream. Note that 'outstr' and 'errstr' can be System.out and System.err.
      Parameters:
      outstr - Where to print simple strings and LOG and INFO messages.
      errstr - Where to print WARNING and ERROR messages
      lw - The line width to use in formatting
  • Method Details

    • printmsg

      public void printmsg(int sev, String msg)
      Prints the message 'msg' to the output device, appending a newline, with severity 'sev'. The severity of the message is prepended to the message.
      Specified by:
      printmsg in interface MsgLogger
      Parameters:
      sev - The message severity (LOG, INFO, etc.)
      msg - The message to display
    • println

      public void println(String str, int flind, int ind)
      Prints the string 'str' to the 'out' stream, appending a newline. The message is reformatted to the line width given to the constructors and using 'flind' characters to indent the first line and 'ind' characters to indent the second line. However, any newlines appearing in 'str' are respected. The output device may or may not display the string until flush() is called, depending on the autoflush state of the PrintWriter, to be sure flush() should be called to write the string to the device. This method just prints the string, the string does not make part of a "message" in the sense that noe severity is associated to it.
      Specified by:
      println in interface MsgLogger
      Parameters:
      str - The string to print
      flind - Indentation of the first line
      ind - Indentation of any other lines.
    • flush

      public void flush()
      Writes any buffered data from the print() and println() methods to the device.
      Specified by:
      flush in interface MsgLogger