KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openharmonise > vfs > metadata > ValidationResult


1 /*
2  * The contents of this file are subject to the
3  * Mozilla Public License Version 1.1 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at http://www.mozilla.org/MPL/
6  *
7  * Software distributed under the License is distributed on an "AS IS"
8  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
9  * See the License for the specific language governing rights and
10  * limitations under the License.
11  *
12  * The Initial Developer of the Original Code is Simulacra Media Ltd.
13  * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
14  *
15  * All Rights Reserved.
16  *
17  * Contributor(s):
18  */

19 package org.openharmonise.vfs.metadata;
20
21 import java.util.ArrayList JavaDoc;
22 import java.util.List JavaDoc;
23
24 /**
25  * A ValidationResult is returned from the validation of values in
26  * {@link Domain} and {@link Range} objects.
27  *
28  * @author Matthew Large
29  * @version $Revision: 1.1 $
30  *
31  */

32 public class ValidationResult {
33
34     /**
35      * List of validation results that are part of this validation result. For exmaple from compound properties which will recurse the validation down to the sub properties.
36      */

37     private ArrayList JavaDoc m_aNestedResults = new ArrayList JavaDoc(3);
38     
39     /**
40      * true if the overall result is valid.
41      */

42     private boolean m_bValid = true;
43     
44     /**
45      * Message associated to this validation result.
46      */

47     private String JavaDoc m_sMessage = "";
48
49     /**
50      *
51      */

52     public ValidationResult() {
53         super();
54     }
55
56     /**
57      * Contructs a new validation result.
58      *
59      * @param bValid true if the result is valid
60      * @param sMessage Message
61      */

62     public ValidationResult(boolean bValid, String JavaDoc sMessage) {
63         super();
64         this.m_bValid = bValid;
65         this.m_sMessage = sMessage;
66     }
67     
68     /**
69      * Sets the message associated to this validation result.
70      *
71      * @param sMessage Message
72      */

73     public void setMessage(String JavaDoc sMessage) {
74         this.m_sMessage = sMessage;
75     }
76     
77     /**
78      * Sets whether or not this validation result is valid.
79      *
80      * @param bValid true if the result is valid
81      */

82     public void setValid(boolean bValid) {
83         this.m_bValid = bValid;
84     }
85     
86     /**
87      * Returns the message associated to this validation result.
88      *
89      * @return Message
90      */

91     public String JavaDoc getMessage() {
92         return this.m_sMessage;
93     }
94     
95     /**
96      * Checks if this result is valid.
97      *
98      * @return true if this result is valid
99      */

100     public boolean isValid() {
101         return this.m_bValid;
102     }
103     
104     /**
105      * Adds validation result which is part of this validation result.
106      *
107      * @param result Validation result to add
108      */

109     public void addNestedValidation(ValidationResult result) {
110         if(result.isValid() == false) {
111             m_bValid = false;
112         }
113         this.m_aNestedResults.add(result);
114     }
115     
116     /**
117      * Returns the validation results that are part of this validation
118      * result.
119      *
120      * @return List of {@link ValidationResult} objects
121      */

122     public List JavaDoc getNestedResults() {
123         return (List JavaDoc)this.m_aNestedResults.clone();
124     }
125
126 }
127
Popular Tags