01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: *
17: * $Header:$
18: */
19: package org.apache.beehive.controls.runtime.generator.apt;
20:
21: import com.sun.mirror.apt.Messager;
22: import com.sun.mirror.util.SourcePosition;
23:
24: /**
25: * Wrap a com.sun.mirror.apt.Messager instance to track errors and warnings.
26: */
27: public final class CheckerMessagerImpl implements Messager {
28: private final Messager _messager;
29: private final Diagnostics _aptDiagnostics;
30: private int _errorCount;
31: private int _warningCount;
32:
33: /**
34: * Constructor.
35: *
36: * @param messager Messager to wrap.
37: */
38: CheckerMessagerImpl(Messager messager, Diagnostics aptDiagnostics) {
39: _messager = messager;
40: _aptDiagnostics = aptDiagnostics;
41: _errorCount = _warningCount = 0;
42: }
43:
44: /**
45: * Get the number of errors sent to this messager.
46: *
47: * @return Number of errors.
48: */
49: int getErrorCount() {
50: return _errorCount;
51: }
52:
53: /**
54: * Get the number of warnings sent to this messager.
55: *
56: * @return Number of warnings.
57: */
58: int getWarningCount() {
59: return _warningCount;
60: }
61:
62: public void printError(String string) {
63: _errorCount++;
64: _aptDiagnostics.setHasErrors(true);
65: _messager.printError(string);
66: }
67:
68: public void printError(SourcePosition sourcePosition, String string) {
69: _errorCount++;
70: _aptDiagnostics.setHasErrors(true);
71: _messager.printError(sourcePosition, string);
72: }
73:
74: public void printWarning(String string) {
75: _warningCount++;
76: _messager.printWarning(string);
77: }
78:
79: public void printWarning(SourcePosition sourcePosition,
80: String string) {
81: _warningCount++;
82: _messager.printWarning(sourcePosition, string);
83: }
84:
85: public void printNotice(String string) {
86: _messager.printNotice(string);
87: }
88:
89: public void printNotice(SourcePosition sourcePosition, String string) {
90: _messager.printNotice(sourcePosition, string);
91: }
92: }
|