KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > validator > rules > TestRule


1 package org.sapia.validator.rules;
2
3 import org.sapia.validator.Rule;
4 import org.sapia.validator.ValidationContext;
5
6 /**
7  * @author Yanick Duchesne
8  * 28-Apr-2003
9  */

10 public class TestRule extends Rule {
11   private boolean _wasCalled;
12   private boolean _createError;
13
14   /**
15    * Constructor for TestRule.
16    */

17   public TestRule(boolean createError) {
18     _createError = createError;
19   }
20
21   public void reset() {
22     _wasCalled = false;
23   }
24
25   public boolean wasCalled() {
26     return _wasCalled;
27   }
28
29   /**
30    * @see org.sapia.validator.Rule#validate(ValidationContext)
31    */

32   public void validate(ValidationContext context) {
33     _wasCalled = true;
34
35     if (_createError) {
36       context.getStatus().error(this);
37     }
38   }
39 }
40
Popular Tags