KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > common > validation > Validatee


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  * Validatee.java April 11, 2003, 5:50 PM
26  *
27  */

28
29 package com.sun.enterprise.tools.common.validation;
30
31 import java.lang.reflect.Method JavaDoc;
32 import java.util.ArrayList JavaDoc;
33 import java.util.Collection JavaDoc;
34 import java.util.HashMap JavaDoc;
35
36
37 /**
38  * Validatee is an <code>Interface</code> implemented by an <code>Object</code>
39  * that needs to be validated.
40  * <p>
41  * In order to validate an object, framework expects either of the two things;
42  * Object being validated is a Validatee itself(it implements Validatee
43  * interface) or a separate Validatee Implementation for this Object is provided.
44  * <p>
45  * If a separate Validatee Implementation is provided then an entry needs to be
46  * added to an Implementation File. Framework uses information in Implementation
47  * File to figure out which Validatee Implementation to use for a given object.
48  * Implementation File is a <code>.properties<code> file with name-value pair
49  * enteries in it. Entry in an Implementation File is of the form :
50  * [fully qualified Object Name]=[Validatee Implementation for this Object]
51  * Implementation File to be used is specified through system property
52  * <code>impl.file</code>
53  * <p>
54  * Validation framework has the Validatee Implementation for Schema2beans
55  * objects(<code>BaseBean</code>). You can override any Validatee Implementation
56  * that comes with framework, by providing your own.
57  * <p>
58  * Validations are performed, recursively on the given Object.
59  * Two types of Validations are perfomed, Structural validations and Specified
60  * validations. Structural validations are expressed through
61  * <code>{@link CardinalConstraint}</code>. <code>CardinalConstraint</code> is
62  * an implicit Constraint. Its always applied to each of the element; you dont
63  * need to specify it explicitly. Where as , other Constaints need to be
64  * explicitly specified for each element you wanted to apply it to.
65  * Constraints to be applied are specified through xml. This xml file is called
66  * Validation File. Validation file is xml file based on
67  * <code>validation.dtd</code>. You can also define, your own custom
68  * <code>Constraint</code>s and apply them to any elements.
69  *
70  * @see Constraint
71  * @see CardinalConstraint
72  * @see ValidationManager
73  *
74  * @author Rajeshwar Patil
75  * @version %I%, %G%
76  */

77 public interface Validatee {
78     /*
79     Every Validatee has a corresponding Validator object and this object
80     knows how to validate its Validatee. Validator maintains a list of
81     Constraints that needs to be applied for each of the element of its
82     Validatee. Constraint objects are built using files, ConstraintsFile
83     and Validation File.
84     ValidationManager is an object that constructs Validator objects for all
85     the Validatees. ValidationManager maintains a map of xpaths to Validators.
86     It constructs this by reading Validation File. Validation File specifies
87     Constraints to be applied to the elements.
88     */

89
90     /**
91      * Returns the list of names, of all the leaf elements
92      * of this <code>Object</code>.
93      *
94      * @return the list of names, of all the leaf elements
95      * of this <code>Object</code>.
96      */

97     public ArrayList JavaDoc getElementNames();
98
99
100     /**
101      * Returns the list of dtd names, of all the leaf elements
102      * of this <code>Object</code>.
103      *
104      * @return the list of dtd names, of all the leaf elements
105      * of this <code>Object</code>.
106      */

107     public ArrayList JavaDoc getElementDtdNames();
108
109
110     /**
111      * Tells if the given element is an index property(array).
112      *
113      * @return true if the given element is an index property(array)
114      */

115     public boolean isIndexed(String JavaDoc elementName);
116
117
118     /**
119      * Gets a Cardinal for the given element of this <code>Object</code>.
120      * Cardinal could be one of the following four :
121      * MANDATORY, OPTIONAL(?), MANDATORY ARRAY(+) or OPTIONAL ARRAY(*)
122      *
123      * @return a Cardinal for the given element of this <code>Object</code>
124      */

125     public int getElementCardinal(String JavaDoc elementName);
126
127
128     /**
129      * Gets a Cardinal of this <code>Object</code>
130      * Cardinal could be one of the following four :
131      * MANDATORY, OPTIONAL(?), MANDATORY ARRAY(+) or OPTIONAL ARRAY(*)
132      *
133      * @return a Cardinal of this <code>Object</code>.
134      */

135     public int getCardinal();
136
137
138     /**
139      * Determines whether the given element is a bean or
140      * a property(leaf element).
141      *
142      * @return <code>true</code> if the given element is a bean.
143      */

144     public boolean isBeanElement(String JavaDoc elementName);
145
146
147     /**
148      * Gets xpath of this <code>Object</code>.
149      * xpath uniquely identifies an element in xml
150      *
151      * @return the xpath of this <code>Object</code>
152      */

153     public String JavaDoc getXPath();
154
155
156     /**
157      * Gets an indexed-xpath of this <code>Object</code>.
158      * indexed-xpath uniquely identifies an element in xml in case of + , *
159      * Cardinalities.
160      *
161      * @return an indexed xpath of this <code>Object</code>
162      */

163     public String JavaDoc getIndexedXPath();
164
165
166     /**
167      * Returns an element of this Object with the given name.
168      *
169      * @return an element of this Object with the given name.
170      */

171     public Object JavaDoc getElement(String JavaDoc elementName);
172
173
174     /**
175      * Returns an element of this Object with the given name and
176      * at a given index. This is the case when the given name represents
177      * an array element
178      *
179      * @return an element of this Object with the given name and index.
180      */

181     public Object JavaDoc getElement(String JavaDoc elementName, int index);
182
183
184     /**
185      * Returns an array element of this Object with the given name.
186      *
187      * @return an array element of this Object with the given name.
188      */

189     public Object JavaDoc [] getElements(String JavaDoc elementName);
190
191
192     /**
193      * Returns the <code>Method</code> object, for the given method of this
194      * Object.
195      *
196      * @return the <code>Method</code> object, for the given method of this
197      * Object.
198      */

199     public Method JavaDoc getMethod(String JavaDoc methodName);
200
201
202     /**
203      * Invokes given method on this Object
204      *
205      * @return an Object returned by the invoked method.
206      */

207     public Object JavaDoc invoke(Method JavaDoc method);
208 }
209
Popular Tags