View Javadoc

1   package org.apache.maven.j2ee;
2   
3   /* ====================================================================
4    *   Copyright 2001-2004 The Apache Software Foundation.
5    *
6    *   Licensed under the Apache License, Version 2.0 (the "License");
7    *   you may not use this file except in compliance with the License.
8    *   You may obtain a copy of the License at
9    *
10   *       http://www.apache.org/licenses/LICENSE-2.0
11   *
12   *   Unless required by applicable law or agreed to in writing, software
13   *   distributed under the License is distributed on an "AS IS" BASIS,
14   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   *   See the License for the specific language governing permissions and
16   *   limitations under the License.
17   * ====================================================================
18   */
19  
20  /**
21   * A {@link ValidationListener} that tracks events and will provide a true/false
22   * response about the status of the validation.
23   * 
24   * @author <a href="mailto:dion@multitask.com.au">dIon Gillard</a>
25   * @version 
26   * $Id: ValidationStatusListener.java 170200 2005-05-15 06:24:19Z brett $
27   */
28  public class ValidationStatusListener implements ValidationListener
29  {
30      /** Whether the validation has started */
31      private boolean started = false;
32      /** Whether the validation has ended */
33      private boolean ended = false;
34      /** Whether the validation has had 1 or more errors */
35      private boolean error = false;
36      /** Whether the validation has had 1 or more warnings */
37      private boolean warning = false;
38      /** Whether the validation has had 1 or more info messages */
39      private boolean information = false;
40      
41      /** 
42       * Creates a new instance of ValidationStatusListener
43       */
44      public ValidationStatusListener()
45      {
46      }
47      
48      /**
49       * Called when a validation error occurs. That is, the subject being
50       * validated has a serious (fatal) problem. Sets the <code>error</code>
51       * property to <code>true</code>.
52       * 
53       * @param event a {@link ValidationEvent}
54       */
55      public void validationError(ValidationEvent event)
56      {
57          setError(true);
58      }
59      
60      /**
61       * Called when a validation warning occurs. That is, the subject being
62       * validated has a problem which may not be fatal. Sets the 
63       * <code>warning</code> property to <code>true</true>.
64       * 
65       * @param event a {@link ValidationEvent}
66       */
67      public void validationWarning(ValidationEvent event)
68      {
69          setWarning(true);
70      }
71      
72      /**
73       * Called when validation info messages are issued. Sets the 
74       * <code>information</code> property to <code>true</true>.
75       * 
76       * @param event a {@link ValidationEvent}
77       */
78      public void validationInformation(ValidationEvent event)
79      {
80          setInformation(true);
81      }
82  
83      /**
84       * Called when validation starts. Sets the <code>started</code> property to 
85       * <code>true</code>
86       * 
87       * @param event a {@link ValidationEvent}
88       */
89      public void validationStarted(ValidationEvent event)
90      {
91          setStarted(true);
92      }
93      
94      /**
95       * Called when validation ends. Sets the <code>ended</code> property to
96       * <code>true</code>
97       * 
98       * @param event a {@link ValidationEvent}
99       */
100     public void validationEnded(ValidationEvent event)
101     {
102         setEnded(true);
103     }
104     
105     /**
106      * Has validation ended?
107      * 
108      * @return Value of property ended.
109      */
110     public boolean isEnded()
111     {
112         return ended;
113     }
114     
115     /**
116      * Sets whether validation has ended.
117      * 
118      * @param ended New value of property ended.
119      */
120     private void setEnded(boolean ended) 
121     {
122         this.ended = ended;
123     }
124     
125     /**
126      * Has a validation error occurred?
127      * 
128      * @return Value of property error.
129      */
130     public boolean isError()
131     {
132         return error;
133     }
134     
135     /**
136      * Sets whether a validation error has occurred.
137      * 
138      * @param error New value of property error.
139      */
140     private void setError(boolean error)
141     {
142         this.error = error;
143     }
144     
145     /**
146      * Has validation started?
147      * 
148      * @return Value of property started.
149      */
150     public boolean isStarted() 
151     {
152         return started;
153     }
154     
155     /**
156      * Sets whether validation has started
157      * 
158      * @param started New value of property started.
159      */
160     private void setStarted(boolean started)
161     {
162         this.started = started;
163     }
164     
165     /**
166      * Has a validation warning occurred?
167      * 
168      * @return Value of property warning.
169      */
170     public boolean isWarning()
171     {
172         return warning;
173     }
174     
175     /**
176      * Sets whether a validation warning has occurred.
177      * 
178      * @param warning New value of property warning.
179      */
180     private void setWarning(boolean warning)
181     {
182         this.warning = warning;
183     }
184     
185     /**
186      * Gets whether an info message has been issued.
187      * 
188      * @return Value of property information.
189      */
190     public boolean isInformation()
191     {
192         return information;
193     }
194     
195     /**
196      * Sets whether an info message has been issued.
197      * 
198      * @param information New value of property information.
199      */
200     public void setInformation(boolean information)
201     {
202         this.information = information;
203     }
204     
205 }