KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > sun > validation > Validatee


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

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

68 public interface Validatee {
69     /*
70     Every Validatee has a corresponding Validator object and this object
71     knows how to validate its Validatee. Validator maintains a list of
72     Constraints that needs to be applied for each of the element of its
73     Validatee. Constraint objects are built using files, ConstraintsFile
74     and Validation File.
75     ValidationManager is an object that constructs Validator objects for all
76     the Validatees. ValidationManager maintains a map of xpaths to Validators.
77     It constructs this by reading Validation File. Validation File specifies
78     Constraints to be applied to the elements.
79     */

80
81     /**
82      * Returns the list of names, of all the leaf elements
83      * of this <code>Object</code>.
84      *
85      * @return the list of names, of all the leaf elements
86      * of this <code>Object</code>.
87      */

88     public ArrayList JavaDoc getElementNames();
89
90
91     /**
92      * Returns the list of dtd names, of all the leaf elements
93      * of this <code>Object</code>.
94      *
95      * @return the list of dtd names, of all the leaf elements
96      * of this <code>Object</code>.
97      */

98     public ArrayList JavaDoc getElementDtdNames();
99
100
101     /**
102      * Tells if the given element is an index property(array).
103      *
104      * @return true if the given element is an index property(array)
105      */

106     public boolean isIndexed(String JavaDoc elementName);
107
108
109     /**
110      * Gets a Cardinal for the given element of this <code>Object</code>.
111      * Cardinal could be one of the following four :
112      * MANDATORY, OPTIONAL(?), MANDATORY ARRAY(+) or OPTIONAL ARRAY(*)
113      *
114      * @return a Cardinal for the given element of this <code>Object</code>
115      */

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

126     public int getCardinal();
127
128
129     /**
130      * Determines whether the given element is a bean or
131      * a property(leaf element).
132      *
133      * @return <code>true</code> if the given element is a bean.
134      */

135     public boolean isBeanElement(String JavaDoc elementName);
136
137
138     /**
139      * Gets xpath of this <code>Object</code>.
140      * xpath uniquely identifies an element in xml
141      *
142      * @return the xpath of this <code>Object</code>
143      */

144     public String JavaDoc getXPath();
145
146
147     /**
148      * Gets an indexed-xpath of this <code>Object</code>.
149      * indexed-xpath uniquely identifies an element in xml in case of + , *
150      * Cardinalities.
151      *
152      * @return an indexed xpath of this <code>Object</code>
153      */

154     public String JavaDoc getIndexedXPath();
155
156
157     /**
158      * Returns an element of this Object with the given name.
159      *
160      * @return an element of this Object with the given name.
161      */

162     public Object JavaDoc getElement(String JavaDoc elementName);
163
164
165     /**
166      * Returns an element of this Object with the given name and
167      * at a given index. This is the case when the given name represents
168      * an array element
169      *
170      * @return an element of this Object with the given name and index.
171      */

172     public Object JavaDoc getElement(String JavaDoc elementName, int index);
173
174
175     /**
176      * Returns an array element of this Object with the given name.
177      *
178      * @return an array element of this Object with the given name.
179      */

180     public Object JavaDoc [] getElements(String JavaDoc elementName);
181
182
183     /**
184      * Returns the <code>Method</code> object, for the given method of this
185      * Object.
186      *
187      * @return the <code>Method</code> object, for the given method of this
188      * Object.
189      */

190     public Method JavaDoc getMethod(String JavaDoc methodName);
191
192
193     /**
194      * Invokes given method on this Object
195      *
196      * @return an Object returned by the invoked method.
197      */

198     public Object JavaDoc invoke(Method JavaDoc method);
199 }
200
Popular Tags