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,v 1.1 2004/04/19 07:29:45 cpoirier Exp $
    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
    24
    25      public SimpleMessage( String message )
    26      {
    27          this( message, null );
    28      }
    29
    30      public SimpleMessage( String message, Object data )
    31      {
    32          this.message = message;
    33          this.data    = null;
    34      }
    35
    36
    37      public void write( PrintWriter writer, ProcessingUnit owner, Janitor janitor )
    38      {
    39          if( owner instanceof SourceUnit )
    40          {
    41              String name = ((SourceUnit)owner).getName();
    42              writer.println( "" + name + ": " + message );
    43          }
    44          else
    45          {
    46              writer.println( message );
    47          }
    48      }
    49
    50
    51      public String getMessage()
    52      {
    53          return message;
    54      }
    55
    56  }
    57
    58
    59
    60