001: /*
002: * The contents of this file are subject to the
003: * Mozilla Public License Version 1.1 (the "License");
004: * you may not use this file except in compliance with the License.
005: * You may obtain a copy of the License at http://www.mozilla.org/MPL/
006: *
007: * Software distributed under the License is distributed on an "AS IS"
008: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
009: * See the License for the specific language governing rights and
010: * limitations under the License.
011: *
012: * The Initial Developer of the Original Code is Simulacra Media Ltd.
013: * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
014: *
015: * All Rights Reserved.
016: *
017: * Contributor(s):
018: */
019: package org.openharmonise.vfs.metadata;
020:
021: import java.util.ArrayList;
022: import java.util.List;
023:
024: /**
025: * A ValidationResult is returned from the validation of values in
026: * {@link Domain} and {@link Range} objects.
027: *
028: * @author Matthew Large
029: * @version $Revision: 1.1 $
030: *
031: */
032: public class ValidationResult {
033:
034: /**
035: * 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.
036: */
037: private ArrayList m_aNestedResults = new ArrayList(3);
038:
039: /**
040: * true if the overall result is valid.
041: */
042: private boolean m_bValid = true;
043:
044: /**
045: * Message associated to this validation result.
046: */
047: private String m_sMessage = "";
048:
049: /**
050: *
051: */
052: public ValidationResult() {
053: super ();
054: }
055:
056: /**
057: * Contructs a new validation result.
058: *
059: * @param bValid true if the result is valid
060: * @param sMessage Message
061: */
062: public ValidationResult(boolean bValid, String sMessage) {
063: super ();
064: this .m_bValid = bValid;
065: this .m_sMessage = sMessage;
066: }
067:
068: /**
069: * Sets the message associated to this validation result.
070: *
071: * @param sMessage Message
072: */
073: public void setMessage(String sMessage) {
074: this .m_sMessage = sMessage;
075: }
076:
077: /**
078: * Sets whether or not this validation result is valid.
079: *
080: * @param bValid true if the result is valid
081: */
082: public void setValid(boolean bValid) {
083: this .m_bValid = bValid;
084: }
085:
086: /**
087: * Returns the message associated to this validation result.
088: *
089: * @return Message
090: */
091: public String getMessage() {
092: return this .m_sMessage;
093: }
094:
095: /**
096: * Checks if this result is valid.
097: *
098: * @return true if this result is valid
099: */
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 getNestedResults() {
123: return (List) this.m_aNestedResults.clone();
124: }
125:
126: }
|