View Javadoc

    1   package org.codehaus.groovy.control.messages;
    2
    3   import java.io.PrintWriter;
    4
    5   import org.codehaus.groovy.control.Janitor;
    6   import org.codehaus.groovy.control.ProcessingUnit;
    7   import org.codehaus.groovy.control.SourceUnit;
    8
    9
    10
    11  /***
    12   *  A base class for compilation messages.
    13   *
    14   *  @author <a href="mailto:cpoirier@dreaming.org">Chris Poirier</a>
    15   *
    16   *  @version $Id: SimpleMessage.java 2257 2005-06-09 19:51:59Z blackdrag $
    17   */
    18
    19  public class SimpleMessage extends Message
    20  {
    21      protected String message;  // Message text
    22      protected Object data;     // Data, when the message text is an I18N identifier
    23      protected ProcessingUnit owner;
    24
    25      public SimpleMessage( String message, ProcessingUnit source )
    26      {
    27          this( message, null, source );
    28      }
    29
    30      public SimpleMessage( String message, Object data, ProcessingUnit source )
    31      {
    32          this.message = message;
    33          this.data    = null;
    34          this.owner = source;
    35      }
    36
    37
    38      public void write( PrintWriter writer, Janitor janitor )
    39      {
    40          if( owner instanceof SourceUnit )
    41          {
    42              String name = ((SourceUnit)owner).getName();
    43              writer.println( "" + name + ": " + message );
    44          }
    45          else
    46          {
    47              writer.println( message );
    48          }
    49      }
    50
    51
    52      public String getMessage()
    53      {
    54          return message;
    55      }
    56
    57  }
    58
    59
    60
    61