KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > codehaus > groovy > control > messages > SimpleMessage


1 package org.codehaus.groovy.control.messages;
2
3 import java.io.PrintWriter JavaDoc;
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 JavaDoc message; // Message text
22
protected Object JavaDoc data; // Data, when the message text is an I18N identifier
23

24     
25     public SimpleMessage( String JavaDoc message )
26     {
27         this( message, null );
28     }
29     
30     public SimpleMessage( String JavaDoc message, Object JavaDoc data )
31     {
32         this.message = message;
33         this.data = null;
34     }
35     
36     
37     public void write( PrintWriter JavaDoc writer, ProcessingUnit owner, Janitor janitor )
38     {
39         if( owner instanceof SourceUnit )
40         {
41             String JavaDoc name = ((SourceUnit)owner).getName();
42             writer.println( "" + name + ": " + message );
43         }
44         else
45         {
46             writer.println( message );
47         }
48     }
49     
50     
51     public String JavaDoc getMessage()
52     {
53         return message;
54     }
55     
56 }
57
58
59
60
61
Popular Tags