1 /*
2 * Copyright 2006-2016 The JGUIraffe Team.
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 package net.sf.jguiraffe.gui.forms;
17
18 import java.util.Set;
19
20 import net.sf.jguiraffe.transform.ValidationResult;
21
22 /**
23 * <p>
24 * Definition of an interface for describing results of a form validation.
25 * </p>
26 * <p>
27 * This interface is closely related to the
28 * <code>{@link net.sf.jguiraffe.transform.ValidationResult ValidationResult}</code>
29 * interface from the <code>transform</code> package. The difference is that
30 * it does not represent results of a single field's validation, but can contain
31 * multiple result objects for an arbitrary number of fields. So it can easily
32 * be checked, which fields of a form are valid and which are not, and for
33 * fields with invalid data the corresponding error messages can be retrieved.
34 * </p>
35 * <p>
36 * Basically objects implementing this interface can be seen as composite
37 * validation result objects. By providing the name of a field the corresponding
38 * <code>ValidationResult</code> object can be obtained. There are also
39 * methods for testing if the whole validation was successful or for retrieving
40 * only the names of the fields that contain invalid data.
41 * </p>
42 *
43 * @author Oliver Heger
44 * @version $Id: FormValidatorResults.java 205 2012-01-29 18:29:57Z oheger $
45 */
46 public interface FormValidatorResults
47 {
48 /**
49 * Checks if the whole validation was successful. If this method returns
50 * <b>true </b>, there are no form fields that caused validation errors.
51 *
52 * @return a flag if the validation of the form was successful
53 */
54 boolean isValid();
55
56 /**
57 * Returns a set with the names of all fields, for which result objects are
58 * stored in this object.
59 *
60 * @return a set with the names of all available fields
61 */
62 Set<String> getFieldNames();
63
64 /**
65 * Returns a set with the names of only those fields, for which validation
66 * has failed.
67 *
68 * @return a set with the names of the error fields
69 */
70 Set<String> getErrorFieldNames();
71
72 /**
73 * Returns the <code>ValidationResult</code> object for the specified
74 * field. This object can then be used to check if validation of this field
75 * was successful or to retrieve all available error messages.
76 *
77 * @param field the name of the desired field
78 * @return the validation result object for this field
79 */
80 ValidationResult getResultsFor(String field);
81 }