Class LoggedReader

  extended bySK.gnome.dwarf.mail.utils.LoggedReader

public class LoggedReader
extends java.lang.Object

Provides line reader with a built-in logging capability.

This class may be used to read lines from the underlying input stream while automatically logging them for debugging purposes. It is suitable for handling text-based network protocols, such as SMTP or POP3, for example.

Constructor Summary
LoggedReader(SK.gnome.dwarf.log.Logger logger, java.lang.String facility, java.lang.String prefix, stream, int limit)
          Creates a new LoggedReader.
Method Summary getStream()
          Returns the underlying input stream.
 int read()
          Reads a single character.
 java.lang.String readLine()
          Reads a single line.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public LoggedReader(SK.gnome.dwarf.log.Logger logger,
                    java.lang.String facility,
                    java.lang.String prefix,
                    int limit)
Creates a new LoggedReader.

The reader will read from stream and log each read line via the logger. The log messages have the LOG_TRACE logging level and the logging facility associated with them. Each logged line is prepended with the prefix string. The reader will refuse to read lines larger than the limit argument.

The log messages will be generated only if it is enabled for the given facility via the SK.gnome.dwar.log.Log.setTrace(String) method.

This reader converts the input stream octets using the ISO 8859-1 character encoding.

logger - the logging service
facility - the logging facility
prefix - the prefix identifying the log messages
stream - the input stream to read from
limit - the maximum line length limit
Throws: - if the required encoding is not known
Method Detail


public int read()
Reads a single character.

the character read
Throws: - if an error occurs


public java.lang.String readLine()
Reads a single line.

the line read
Throws: - if an error occurs


public getStream()
Returns the underlying input stream.

The stream may be used to directly read byte octets when line-oriented input or logging function is not desired.

the input stream

Copyright (c) 2004-2005, Gnome Ltd. All rights reserved.