org.sapia.taskman
Class DefaultTaskOutput

java.lang.Object
  |
  +--org.sapia.taskman.DefaultTaskOutput
All Implemented Interfaces:
TaskOutput

public class DefaultTaskOutput
extends Object
implements TaskOutput

A TaskOutput that logs to System.out. This class adds "debug level" functionality.

Author:
Yanick Duchesne 15-Apr-2003

Field Summary
protected  String _taskName
           
static int DEBUG
          Identifies the "debug" level - the debug() method has been called to log a message.
static int ERROR
          Identifies the "error" level - the error() method has been called to log a message.
static int INFO
          Identifies the "info" level - the info() method has been called to log a message.
static String[] LEVEL
          An array string constant that holds the name of the logging priority defined by the constants in this class; in fact, each constant corresponds to an index in this array.
static int WARNING
          Identifies the "warning" level - the warning() method has been called to log a message.
 
Constructor Summary
DefaultTaskOutput(String taskName, int level)
          Constructor for DefaultTaskLog.
 
Method Summary
 void close()
          This method has an empty implementation (closing System.out would not be a good idea).
 TaskOutput debug(Object message)
          Outputs a message of "debug" priority.
protected  void doOutput(int lvl, Object message, Throwable t)
          Template method that can be overriden to log to another place than System.out.
protected  void doOutput(Throwable t)
          Template method that can be overriden to log to another place than System.out.
 TaskOutput error(Object message)
          Outputs a message of "error" priority.
 TaskOutput error(Object message, Throwable t)
          Outputs a message of "error" priority.
 TaskOutput error(Throwable t)
          Outputs a message of "error" priority.
protected  String getLevelNameFor(int priority)
          Returns the name of the passed in priority.
protected  String getTaskName()
          Returns this instance's name.
 TaskOutput info(Object message)
          Outputs a message of "info" priority.
 void setTaskName(String name)
          Sets the name of the task to which this instance corresponds, allowing implementations to display which task is currently generating output.
 TaskOutput warning(Object message)
          Outputs a message of "warning" priority.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG

public static int DEBUG
Identifies the "debug" level - the debug() method has been called to log a message.


INFO

public static int INFO
Identifies the "info" level - the info() method has been called to log a message.


WARNING

public static int WARNING
Identifies the "warning" level - the warning() method has been called to log a message.


ERROR

public static int ERROR
Identifies the "error" level - the error() method has been called to log a message.


LEVEL

public static final String[] LEVEL
An array string constant that holds the name of the logging priority defined by the constants in this class; in fact, each constant corresponds to an index in this array.


_taskName

protected String _taskName
Constructor Detail

DefaultTaskOutput

public DefaultTaskOutput(String taskName,
                         int level)
Constructor for DefaultTaskLog.

Method Detail

setTaskName

public void setTaskName(String name)
Description copied from interface: TaskOutput
Sets the name of the task to which this instance corresponds, allowing implementations to display which task is currently generating output.

Specified by:
setTaskName in interface TaskOutput
Parameters:
name - a task name.
See Also:
TaskOutput.setTaskName(String)

debug

public TaskOutput debug(Object message)
Description copied from interface: TaskOutput
Outputs a message of "debug" priority.

Specified by:
debug in interface TaskOutput
Parameters:
message - a message, as an Object.
See Also:
TaskOutput.debug(Object)

error

public TaskOutput error(Object message,
                        Throwable t)
Description copied from interface: TaskOutput
Outputs a message of "error" priority.

Specified by:
error in interface TaskOutput
Parameters:
message - a message, as an Object.
t - a Throwable.
See Also:
TaskOutput.error(Object, Throwable)

error

public TaskOutput error(Object message)
Description copied from interface: TaskOutput
Outputs a message of "error" priority.

Specified by:
error in interface TaskOutput
Parameters:
message - a message, as an Object.
See Also:
TaskOutput.error(Object)

error

public TaskOutput error(Throwable t)
Description copied from interface: TaskOutput
Outputs a message of "error" priority.

Specified by:
error in interface TaskOutput
Parameters:
t - a Throwable.
See Also:
TaskOutput.error(Throwable)

info

public TaskOutput info(Object message)
Description copied from interface: TaskOutput
Outputs a message of "info" priority.

Specified by:
info in interface TaskOutput
Parameters:
message - a message, as an Object.
See Also:
TaskOutput.info(Object)

warning

public TaskOutput warning(Object message)
Description copied from interface: TaskOutput
Outputs a message of "warning" priority.

Specified by:
warning in interface TaskOutput
Parameters:
message - a message, as an Object.
See Also:
TaskOutput.warning(Object)

close

public void close()
This method has an empty implementation (closing System.out would not be a good idea).

Specified by:
close in interface TaskOutput
See Also:
TaskOutput.close()

getTaskName

protected String getTaskName()
Returns this instance's name.

Returns:
a name.

getLevelNameFor

protected String getLevelNameFor(int priority)
Returns the name of the passed in priority.

Returns:
a name.

doOutput

protected void doOutput(int lvl,
                        Object message,
                        Throwable t)
Template method that can be overriden to log to another place than System.out.

Parameters:
lvl - the priority at which the given message is logged; this parameter's value corresponds to one of the constants of this class.
message - the message that was logged.
t - the Throwable that was logged, or null if no Throwable was logged.
See Also:
DEBUG, INFO, WARNING, ERROR

doOutput

protected void doOutput(Throwable t)
Template method that can be overriden to log to another place than System.out.

Parameters:
t - the Throwable that was logged.


Copyright © 2002 Sapia Open Community, Inc. All Rights Reserved.