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.syntax.SyntaxException;
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: Message.java,v 1.1 2004/04/19 07:29:45 cpoirier Exp $
17   */
18  
19  public abstract class Message
20  {
21      
22      
23     /***
24      *  Writes the message to the specified PrintWriter.  The supplied
25      *  ProcessingUnit is the unit that holds this Message.
26      */
27      
28      public abstract void write( PrintWriter writer, ProcessingUnit owner, Janitor janitor );
29      
30      
31     /***
32      *  A synonyn for write( writer, owner, null ).
33      */
34      
35      public final void write( PrintWriter writer, ProcessingUnit owner )
36      {
37          write( writer, owner, null );
38      }
39      
40      
41      
42    //---------------------------------------------------------------------------
43    // FACTORY METHODS
44      
45      
46     /***
47      *  Creates a new Message from the specified text.
48      */
49      
50      public static Message create( String text )
51      {
52          return new SimpleMessage( text );
53      }
54      
55      
56            
57     /***
58      *  Creates a new Message from the specified text.
59      */
60       
61      public static Message create( String text, Object data )
62      {
63          return new SimpleMessage( text, data );
64      }
65       
66       
67             
68     /***
69      *  Creates a new Message from the specified SyntaxException.
70      */
71        
72      public static Message create( SyntaxException error )
73      {
74          return new SyntaxErrorMessage( error );
75      }
76        
77        
78        
79      
80  }
81  
82  
83  
84