Class DefaultObserver

  • All Implemented Interfaces:
    ErrorObserver, MessageObserver

    public class DefaultObserver
    extends java.lang.Object
    implements MessageObserver, ErrorObserver
    A simple implementation of MessageObserver and ErrorObserver. This observer is cascading, which means you can add observers to it, and it will cascade notifications.
    Version:
    $Revision: 3633 $ $Date: 2003-03-01 08:38:44 +0100 (Sat, 01 Mar 2003) $
    Author:
    Keith Visco
    • Constructor Summary

      Constructors 
      Constructor Description
      DefaultObserver()
      Creates a new SimpleMessageObserver which will print messages to the console.
      DefaultObserver​(boolean allErrorsFatal)
      Creates a new SimpleMessageObserver which will print messages to the console.
      DefaultObserver​(java.io.Writer writer)
      Creates a new SimpleMessageObserver which will print messages to the console.
      DefaultObserver​(java.io.Writer writer, boolean allErrorsFatal)
      Creates a new SimpleMessageObserver which will print messages to the console.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addErrorObserver​(ErrorObserver observer)
      Adds the given ErrorObserver to this DefaultObserver
      void addMessageObserver​(MessageObserver observer)
      Adds the given MessageObserver to this DefaultObserver
      void receiveError​(java.lang.Exception exception)
      Signals an error with normal level
      void receiveError​(java.lang.Exception exception, int level)
      Signals an error with the given error level
      void receiveError​(java.lang.Exception exception, java.lang.String message)
      Signals an error with normal level
      void receiveError​(java.lang.Exception exception, java.lang.String message, int level)
      Signals an error with the given error level
      void receiveError​(java.lang.String message)
      Signals an error message with normal level
      void receiveError​(java.lang.String message, int level)
      Signals an error message with the given error level
      void receiveMessage​(java.lang.String message)
      Notifies this observer of a new message
      void removeAllErrorObservers()
      Removes all the ErrorObservers from the cascading ErrorObserver list
      void removeAllMessageObservers()
      Removes all the MessageObservers from the cascading ErrorObserver list
      void removeErrorObserver​(ErrorObserver observer)
      Removes the given ErrorObserver from the cascading ErrorObserver list
      void removeMessageObserver​(MessageObserver observer)
      Removes the given MessageObserver from the cascading MessageObserver list
      void setWriter​(java.io.Writer writer)
      Sets the Writer of this MessageObserver
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DefaultObserver

        public DefaultObserver()
        Creates a new SimpleMessageObserver which will print messages to the console. A fatal error will cause a RuntimeException.
      • DefaultObserver

        public DefaultObserver​(boolean allErrorsFatal)
        Creates a new SimpleMessageObserver which will print messages to the console. A fatal error will cause a RuntimeException.
        Parameters:
        allErrorsFatal - a boolean, when true will treat all errors as fatal errors (excludes warnings).
      • DefaultObserver

        public DefaultObserver​(java.io.Writer writer)
        Creates a new SimpleMessageObserver which will print messages to the console. A fatal error will cause a RuntimeException.
        Parameters:
        writer - the Writer to print messages to. This writer may be null, to create a null sink.
      • DefaultObserver

        public DefaultObserver​(java.io.Writer writer,
                               boolean allErrorsFatal)
        Creates a new SimpleMessageObserver which will print messages to the console. A fatal error will cause a RuntimeException.
        Parameters:
        writer - the Writer to print messages to. This writer may be null, to create a null sink.
        allErrorsFatal - a boolean, when true will treat all errors as fatal errors (excludes warnings).
    • Method Detail

      • addErrorObserver

        public void addErrorObserver​(ErrorObserver observer)
        Adds the given ErrorObserver to this DefaultObserver
        Parameters:
        observer - the ErrorObserver to add
      • addMessageObserver

        public void addMessageObserver​(MessageObserver observer)
        Adds the given MessageObserver to this DefaultObserver
        Parameters:
        observer - the MessageObserver to add
      • receiveError

        public void receiveError​(java.lang.Exception exception)
        Signals an error with normal level
        Specified by:
        receiveError in interface ErrorObserver
        Parameters:
        exception - the Exception that caused the error
      • receiveError

        public void receiveError​(java.lang.Exception exception,
                                 java.lang.String message)
        Signals an error with normal level
        Specified by:
        receiveError in interface ErrorObserver
        Parameters:
        exception - the Exception that caused the error
        message - an option message, used when additional information can be provided.
      • receiveError

        public void receiveError​(java.lang.Exception exception,
                                 int level)
        Signals an error with the given error level
        Specified by:
        receiveError in interface ErrorObserver
        Parameters:
        exception - the Exception that caused the error
        level - the error level
      • receiveError

        public void receiveError​(java.lang.Exception exception,
                                 java.lang.String message,
                                 int level)
        Signals an error with the given error level
        Specified by:
        receiveError in interface ErrorObserver
        Parameters:
        exception - the Exception that caused the error
        message - an option message, used when additional information can be provided.
        level - the error level
      • receiveError

        public void receiveError​(java.lang.String message)
        Signals an error message with normal level
        Specified by:
        receiveError in interface ErrorObserver
        Parameters:
        message - the error message
      • receiveError

        public void receiveError​(java.lang.String message,
                                 int level)
        Signals an error message with the given error level
        Specified by:
        receiveError in interface ErrorObserver
        Parameters:
        message - the error message
        level - the error level
      • receiveMessage

        public void receiveMessage​(java.lang.String message)
        Notifies this observer of a new message
        Specified by:
        receiveMessage in interface MessageObserver
        Parameters:
        message - the message to observe
      • removeAllErrorObservers

        public void removeAllErrorObservers()
        Removes all the ErrorObservers from the cascading ErrorObserver list
      • removeAllMessageObservers

        public void removeAllMessageObservers()
        Removes all the MessageObservers from the cascading ErrorObserver list
      • removeErrorObserver

        public void removeErrorObserver​(ErrorObserver observer)
        Removes the given ErrorObserver from the cascading ErrorObserver list
        Parameters:
        observer - the ErrorObserver to remove
      • removeMessageObserver

        public void removeMessageObserver​(MessageObserver observer)
        Removes the given MessageObserver from the cascading MessageObserver list
        Parameters:
        observer - the MessageObserver to remove
      • setWriter

        public void setWriter​(java.io.Writer writer)
        Sets the Writer of this MessageObserver
        Parameters:
        writer - the Writer to print messages to