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   import org.codehaus.groovy.syntax.SyntaxException;
9   
10  
11  
12  /***
13   *  A base class for compilation messages.
14   *
15   *  @author <a href="mailto:cpoirier@dreaming.org">Chris Poirier</a>
16   *
17   *  @version $Id: Message.java,v 1.2 2005/06/09 19:51:59 blackdrag Exp $
18   */
19  
20  public abstract class Message
21  {
22      
23      
24     /***
25      *  Writes the message to the specified PrintWriter.  The supplied
26      *  ProcessingUnit is the unit that holds this Message.
27      */
28      
29      public abstract void write( PrintWriter writer, Janitor janitor );
30      
31      
32     /***
33      *  A synonyn for write( writer, owner, null ).
34      */
35      
36      public final void write( PrintWriter writer)
37      {
38          write( writer,  null );
39      }
40      
41      
42      
43    //---------------------------------------------------------------------------
44    // FACTORY METHODS
45      
46      
47     /***
48      *  Creates a new Message from the specified text.
49      */
50      
51      public static Message create( String text, ProcessingUnit owner )
52      {
53          return new SimpleMessage( text, owner );
54      }
55      
56      
57            
58     /***
59      *  Creates a new Message from the specified text.
60      */
61       
62      public static Message create( String text, Object data, ProcessingUnit owner  )
63      {
64          return new SimpleMessage( text, data, owner);
65      }
66       
67       
68             
69     /***
70      *  Creates a new Message from the specified SyntaxException.
71      */
72        
73      public static Message create( SyntaxException error, SourceUnit owner )
74      {
75          return new SyntaxErrorMessage( error, owner );
76      }
77        
78      
79        
80      
81  }
82  
83  
84  
85