KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > latka > validators > BaseValidator


1 /*
2  * Copyright 1999-2002,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
17 package org.apache.commons.latka.validators;
18
19 import org.apache.commons.latka.Validator;
20 import org.apache.commons.latka.ValidationException;
21
22 import org.apache.commons.latka.http.Response;
23
24 import org.apache.log4j.Category;
25
26 /**
27  * @author Rodney Waldhoff
28  * @author dIon Gillard
29  * @version $Id: BaseValidator.java 155424 2005-02-26 13:09:29Z dirkv $
30  */

31 public abstract class BaseValidator implements Validator {
32     // ----------------------------------------------------- Instance Variables
33

34     /** log4j category for debug output */
35     protected final Category _log = Category.getInstance(BaseValidator.class);
36
37     // ------------------------------------------------------- Abstract Methods
38
/**
39      * Validate a response
40      *
41      * @param response the response to validate
42      * @throws ValidationException
43      */

44     public abstract void validate(Response response) throws ValidationException;
45
46     protected String JavaDoc _label = null;
47
48     // ----------------------------------------------------------- Constructors
49

50     public BaseValidator() {
51         this(null);
52     }
53
54     public BaseValidator(String JavaDoc label) {
55         _label = label;
56     }
57
58     // ---------------------------------------------------------------- Methods
59

60     public void setLabel(String JavaDoc label) {
61         _label = label;
62     }
63
64     public String JavaDoc getLabel() {
65         return _label;
66     }
67
68     protected void fail(String JavaDoc reason) throws ValidationException {
69         throw new ValidationException(getLabel(),reason);
70     }
71
72 }
73
Popular Tags