001    package org.hackystat.sensor.xmldata;
002    
003    import org.hackystat.sensor.xmldata.option.Options;
004    
005    /**
006     * The class which is delegated to by options and the controller when displaying
007     * informative messages to the user. This class wraps the way information is
008     * displayed to allow the extension of messaging if the mutliple views are added
009     * to this sensor, which is currently command-line only.
010     * @author aito
011     * 
012     */
013    public class MessageDelegate {
014      /** The controller which stores this message delegate. */
015      private XmlDataController controller = null;
016    
017      /**
018       * Constructs this delegate class with the specified controller.
019       * @param controller the controller that delegates to this class.
020       */
021      public MessageDelegate(XmlDataController controller) {
022        this.controller = controller;
023      }
024    
025      /**
026       * Displays the specified message. The same message is displayed even if the
027       * verbose option is enabled.
028       * @param message the specified message to display.
029       */
030      public void fireMessage(String message) {
031        System.out.println(message);
032      }
033    
034      /**
035       * Displays the specified message if verbose mode is enabled.
036       * @param message the specified message to display.
037       */
038      public void fireVerboseMessage(String message) {
039        if (Boolean.TRUE.equals(this.controller.getOptionObject(Options.VERBOSE))) {
040          System.out.println(message);
041        }
042      }
043    
044      /**
045       * Displays the specified message is verbose mode is disabled or the verbose
046       * message if verbose mode is enabled.
047       * @param message the specified message.
048       * @param verboseMessage the specified verbose message.
049       */
050      public void fireMessage(String message, String verboseMessage) {
051        if (Boolean.TRUE.equals(this.controller.getOptionObject(Options.VERBOSE))) {
052          System.out.println(verboseMessage);
053        }
054        else {
055          System.out.println(message);
056        }
057      }
058    }