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