KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > common > validation > constraints > Constraint


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 /*
25  * Constraint.java March 24, 2003, 11:04 AM
26  *
27  */

28
29 package com.sun.enterprise.tools.common.validation.constraints;
30
31 import java.util.Collection JavaDoc;
32
33 /**
34  * Constraint is an <code>Interface</code> needed to perform a Validation.
35  * User can define a new type of Validation by implementing this
36  * <code>Interface</code>.
37  * Method <code>match</code> defines the Validation logic. This method
38  * returns an empty collection if the value being validated is valid;
39  * else it returns a <code>Collection</code> with a {@link ConstraintFailure}
40  * object in it.
41  *
42  * @author Rajeshwar Patil
43  * @version %I%, %G%
44  */

45 public interface Constraint {
46     /**
47      * Validates the given value against this <code>Constraint</code>.
48      *
49      * @param value the value to be validated
50      * @param name the element name, value of which is being validated.
51      *
52      * @return <code>Collection</code> the Collection of failure Objects.
53      * Collection is empty if there are no failures.
54      */

55     public Collection JavaDoc match(String JavaDoc value, String JavaDoc name);
56 }
57
Popular Tags