KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > beehive > controls > runtime > generator > apt > 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.controls.runtime.generator.apt;
19
20 import com.sun.mirror.apt.AnnotationProcessorEnvironment;
21 import com.sun.mirror.declaration.Declaration;
22 import com.sun.mirror.declaration.AnnotationValue;
23 import com.sun.mirror.declaration.AnnotationMirror;
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, Object JavaDoc ... args )
36     {
37         _env.getMessager().printError( decl.getPosition(), getResourceString( messageKey, args ) );
38         _hasErrors = true;
39     }
40     
41     public void addError( AnnotationMirror ann, String JavaDoc messageKey, Object JavaDoc ... args )
42     {
43         _env.getMessager().printError( ann.getPosition(), getResourceString( messageKey, args ) );
44         _hasErrors = true;
45     }
46     
47     public void addErrorArrayArgs( AnnotationMirror ann, String JavaDoc messageKey, Object JavaDoc[] args )
48     {
49         _env.getMessager().printError( ann.getPosition(), getResourceString( messageKey, args ) );
50         _hasErrors = true;
51     }
52     
53     public void addError( AnnotationValue annVal, String JavaDoc messageKey, Object JavaDoc ... args )
54     {
55         _env.getMessager().printError( annVal.getPosition(), getResourceString( messageKey, args ) );
56         _hasErrors = true;
57     }
58     
59     public void addWarning( Declaration decl, String JavaDoc messageKey, Object JavaDoc ... args )
60     {
61         _env.getMessager().printWarning( decl.getPosition(), getResourceString( messageKey, args ) );
62     }
63     
64     public void addWarning( AnnotationMirror ann, String JavaDoc messageKey, Object JavaDoc ... args )
65     {
66         _env.getMessager().printWarning( ann.getPosition(), getResourceString( messageKey, args ) );
67     }
68     
69     public void addWarning( AnnotationValue annVal, String JavaDoc messageKey, Object JavaDoc ... args )
70     {
71         _env.getMessager().printWarning( annVal.getPosition(), getResourceString( messageKey, args ) );
72     }
73
74     public AnnotationProcessorEnvironment getAnnotationProcessorEnvironment()
75     {
76         return _env;
77     }
78
79     protected abstract String JavaDoc getResourceString( String JavaDoc key, Object JavaDoc ... args );
80
81     public boolean hasErrors()
82     {
83         return _hasErrors;
84     }
85     
86     protected void setHasErrors( boolean hadErrors )
87     {
88         _hasErrors = hadErrors;
89     }
90 }
91
Popular Tags