01: // THIS SOFTWARE IS PROVIDED BY SOFTARIS PTY.LTD. AND OTHER METABOSS
02: // CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
03: // BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
04: // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTARIS PTY.LTD.
05: // OR OTHER METABOSS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
06: // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
07: // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
08: // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
09: // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
10: // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
11: // EVEN IF SOFTARIS PTY.LTD. OR OTHER METABOSS CONTRIBUTORS ARE ADVISED OF THE
12: // POSSIBILITY OF SUCH DAMAGE.
13: //
14: // Copyright 2000-2005 © Softaris Pty.Ltd. All Rights Reserved.
15: package com.metaboss.enterprise.datatypes;
16:
17: /** Specialised Data Types exception. This exception is thrown when
18: * datatype validation has failed because validation constraint evaluation has failed.
19: * Note that this is checked exception, which has to be caught by calling program.
20: * It is normally thrown from constraint validation code. */
21: public class DataTypeConstraintValidationException extends
22: DataTypeException {
23: private String mConstraintId = null;
24: private String mConstrainedClassName = null;
25: private String mFieldName = null;
26:
27: /** Constructs DataTypeConstraintValidationException object which does carry field level constraint details */
28: public DataTypeConstraintValidationException(String pConstraintId,
29: String pConstrainedClassName, String pErrorMessage,
30: String pFieldName) {
31: super (pErrorMessage);
32: mConstraintId = pConstraintId;
33: mConstrainedClassName = pConstrainedClassName;
34: mFieldName = pFieldName;
35: }
36:
37: /** Constructs DataTypeConstraintValidationException object which does carry top level constraint details */
38: public DataTypeConstraintValidationException(String pConstraintId,
39: String pConstrainedClassName, String pErrorMessage) {
40: super (pErrorMessage);
41: mConstraintId = pConstraintId;
42: mConstrainedClassName = pConstrainedClassName;
43: mFieldName = null;
44: }
45:
46: /** Getter for the ConstraintId attribute */
47: public String getConstraintId() {
48: return mConstraintId;
49: }
50:
51: /** Getter for the ConstrainedClassName attribute */
52: public String getConstrainedClassName() {
53: return mConstrainedClassName;
54: }
55:
56: /** Getter for the FieldName attribute */
57: public String getFieldName() {
58: return mFieldName;
59: }
60:
61: /** Generates readable validation message. Overriden so it does not output cause (cause makes message less readable by the end user) */
62: public String getMessage() {
63: if (mFieldName != null)
64: return super .getMessageWithCause() + " (FieldName: "
65: + mFieldName + ")";
66: return super.getMessageWithCause();
67: }
68: }
|