KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > beehive > netui > compiler > Diagnostics


1 /*
2  * Copyright 2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  * $Header:$
17  */

18 package org.apache.beehive.netui.compiler;
19
20 import org.apache.beehive.netui.compiler.typesystem.env.AnnotationProcessorEnvironment;
21 import org.apache.beehive.netui.compiler.typesystem.declaration.Declaration;
22 import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationValue;
23 import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationInstance;
24
25 public abstract class Diagnostics
26 {
27     private AnnotationProcessorEnvironment _env;
28     private boolean _hasErrors = false;
29     
30     protected Diagnostics( AnnotationProcessorEnvironment env )
31     {
32         _env = env;
33     }
34     
35     public void addError( Declaration decl, String JavaDoc messageKey )
36     {
37         addErrorArrayArgs( decl, messageKey, null );
38     }
39     
40     public void addError( Declaration decl, String JavaDoc messageKey, Object JavaDoc arg )
41     {
42         addErrorArrayArgs( decl, messageKey, new Object JavaDoc[]{ arg } );
43     }
44     
45     public void addError( Declaration decl, String JavaDoc messageKey, Object JavaDoc arg1, Object JavaDoc arg2 )
46     {
47         addErrorArrayArgs( decl, messageKey, new Object JavaDoc[]{ arg1, arg2 } );
48     }
49     
50     public void addError( Declaration decl, String JavaDoc messageKey, Object JavaDoc arg1, Object JavaDoc arg2, Object JavaDoc arg3 )
51     {
52         addErrorArrayArgs( decl, messageKey, new Object JavaDoc[]{ arg1, arg2, arg3 } );
53     }
54     
55     public void addErrorArrayArgs( Declaration decl, String JavaDoc messageKey, Object JavaDoc[] args )
56     {
57         _env.getMessager().printError( decl.getPosition(), getResourceString( messageKey, args ) );
58         _hasErrors = true;
59     }
60     
61     public void addErrorNoPosition( String JavaDoc messageKey, Object JavaDoc[] args )
62     {
63         _env.getMessager().printError( getResourceString( messageKey, args ) );
64     }
65
66     public void addError( AnnotationInstance ann, String JavaDoc messageKey )
67     {
68         addErrorArrayArgs( ann, messageKey, null );
69     }
70     
71     public void addError( AnnotationInstance ann, String JavaDoc messageKey, Object JavaDoc arg )
72     {
73         addErrorArrayArgs( ann, messageKey, new Object JavaDoc[]{ arg } );
74     }
75     
76     public void addError( AnnotationInstance ann, String JavaDoc messageKey, Object JavaDoc arg1, Object JavaDoc arg2 )
77     {
78         addErrorArrayArgs( ann, messageKey, new Object JavaDoc[]{ arg1, arg2 } );
79     }
80     
81     public void addError( AnnotationInstance ann, String JavaDoc messageKey, Object JavaDoc arg1, Object JavaDoc arg2, Object JavaDoc arg3 )
82     {
83         addErrorArrayArgs( ann, messageKey, new Object JavaDoc[]{ arg1, arg2, arg3 } );
84     }
85     
86     public void addErrorArrayArgs( AnnotationInstance ann, String JavaDoc messageKey, Object JavaDoc[] args )
87     {
88         _env.getMessager().printError( ann.getPosition(), getResourceString( messageKey, args ) );
89         _hasErrors = true;
90     }
91     
92     public void addError( AnnotationValue value, String JavaDoc messageKey )
93     {
94         addErrorArrayArgs( value, messageKey, null );
95     }
96     
97     public void addError( AnnotationValue value, String JavaDoc messageKey, Object JavaDoc arg )
98     {
99         addErrorArrayArgs( value, messageKey, new Object JavaDoc[]{ arg } );
100     }
101     
102     public void addError( AnnotationValue value, String JavaDoc messageKey, Object JavaDoc arg1, Object JavaDoc arg2 )
103     {
104         addErrorArrayArgs( value, messageKey, new Object JavaDoc[]{ arg1, arg2 } );
105     }
106     
107     public void addError( AnnotationValue value, String JavaDoc messageKey, Object JavaDoc arg1, Object JavaDoc arg2, Object JavaDoc arg3 )
108     {
109         addErrorArrayArgs( value, messageKey, new Object JavaDoc[]{ arg1, arg2, arg3 } );
110     }
111     
112     public void addErrorArrayArgs( AnnotationValue value, String JavaDoc messageKey, Object JavaDoc[] args )
113     {
114         _env.getMessager().printError( value.getPosition(), getResourceString( messageKey, args ) );
115         _hasErrors = true;
116     }
117
118     public void addWarning( Declaration decl, String JavaDoc messageKey )
119     {
120         addWarningArrayArgs( decl, messageKey, null );
121     }
122     
123     public void addWarning( Declaration decl, String JavaDoc messageKey, Object JavaDoc arg )
124     {
125         addWarningArrayArgs( decl, messageKey, new Object JavaDoc[]{ arg } );
126     }
127     
128     public void addWarning( Declaration decl, String JavaDoc messageKey, Object JavaDoc arg1, Object JavaDoc arg2 )
129     {
130         addWarningArrayArgs( decl, messageKey, new Object JavaDoc[]{ arg1, arg2 } );
131     }
132     
133     public void addWarning( Declaration decl, String JavaDoc messageKey, Object JavaDoc arg1, Object JavaDoc arg2, Object JavaDoc arg3 )
134     {
135         addWarningArrayArgs( decl, messageKey, new Object JavaDoc[]{ arg1, arg2, arg3 } );
136     }
137     
138     public void addWarningArrayArgs( Declaration decl, String JavaDoc messageKey, Object JavaDoc[] args )
139     {
140         _env.getMessager().printWarning( decl.getPosition(), getResourceString( messageKey, args ) );
141     }
142
143     public void addWarning( AnnotationInstance ann, String JavaDoc messageKey )
144     {
145         addWarningArrayArgs( ann, messageKey, null );
146     }
147     
148     public void addWarning( AnnotationInstance ann, String JavaDoc messageKey, Object JavaDoc arg )
149     {
150         addWarningArrayArgs( ann, messageKey, new Object JavaDoc[]{ arg } );
151     }
152     
153     public void addWarning( AnnotationInstance ann, String JavaDoc messageKey, Object JavaDoc arg1, Object JavaDoc arg2 )
154     {
155         addWarningArrayArgs( ann, messageKey, new Object JavaDoc[]{ arg1, arg2 } );
156     }
157     
158     public void addWarning( AnnotationInstance ann, String JavaDoc messageKey, Object JavaDoc arg1, Object JavaDoc arg2, Object JavaDoc arg3 )
159     {
160         addWarningArrayArgs( ann, messageKey, new Object JavaDoc[]{ arg1, arg2, arg3 } );
161     }
162     
163     public void addWarningArrayArgs( AnnotationInstance ann, String JavaDoc messageKey, Object JavaDoc[] args )
164     {
165         _env.getMessager().printWarning( ann.getPosition(), getResourceString( messageKey, args ) );
166     }
167     
168     public void addWarning( AnnotationValue value, String JavaDoc messageKey )
169     {
170         addWarningArrayArgs( value, messageKey, null );
171     }
172     
173     public void addWarning( AnnotationValue value, String JavaDoc messageKey, Object JavaDoc arg )
174     {
175         addWarningArrayArgs( value, messageKey, new Object JavaDoc[]{ arg } );
176     }
177     
178     public void addWarning( AnnotationValue value, String JavaDoc messageKey, Object JavaDoc arg1, Object JavaDoc arg2 )
179     {
180         addWarningArrayArgs( value, messageKey, new Object JavaDoc[]{ arg1, arg2 } );
181     }
182     
183     public void addWarning( AnnotationValue value, String JavaDoc messageKey, Object JavaDoc arg1, Object JavaDoc arg2, Object JavaDoc arg3 )
184     {
185         addWarningArrayArgs( value, messageKey, new Object JavaDoc[]{ arg1, arg2, arg3 } );
186     }
187     
188     public void addWarningArrayArgs( AnnotationValue value, String JavaDoc messageKey, Object JavaDoc[] args )
189     {
190         _env.getMessager().printWarning( value.getPosition(), getResourceString( messageKey, args ) );
191     }
192     
193     protected abstract String JavaDoc getResourceString( String JavaDoc key, Object JavaDoc[] args );
194
195     public boolean hasErrors()
196     {
197         return _hasErrors;
198     }
199     
200     protected void setHasErrors( boolean hadErrors )
201     {
202         _hasErrors = hadErrors;
203     }
204     
205     protected AnnotationProcessorEnvironment getAnnotationProcessorEnvironment()
206     {
207         return _env;
208     }
209 }
210
Popular Tags