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 Type Validation Exception. This exception is almost exactly the same as
18: * DataTypeValidationException, but it is for the cases when the field of the composite datatype
19: * has had a problem and we do know the name of the field which was attempted to be populated. */
20: public class DataTypeFieldValidationException extends
21: DataTypeValidationException {
22: private String mFieldName = null;
23:
24: /** Constructs DataTypeFieldValidationException object which does not carry message */
25: public DataTypeFieldValidationException(String pFieldName) {
26: super ();
27: mFieldName = pFieldName;
28: }
29:
30: /** Constructs DataTypeFieldValidationException object which not carry message */
31: public DataTypeFieldValidationException(String pFieldName,
32: String pMessage) {
33: super (pMessage);
34: mFieldName = pFieldName;
35: }
36:
37: /** Constructs DataTypeFieldValidationException with message and cause */
38: public DataTypeFieldValidationException(String pFieldName,
39: String pMessage, Throwable pCause) {
40: super (pMessage, pCause);
41: mFieldName = pFieldName;
42: }
43:
44: /** Constructs DataTypeFieldValidationException with field name and cause.
45: * This version will automatically generate the mesage */
46: public DataTypeFieldValidationException(String pFieldName,
47: Throwable pCause) {
48: super ("Supplied value is not valid for the " + pFieldName
49: + " field.", pCause);
50: mFieldName = pFieldName;
51: }
52:
53: /** Retrieves the field name the validation exception has occurred on */
54: public String getFieldName() {
55: return mFieldName;
56: }
57:
58: /** Generates readable validation message. Overriden so it does not output cause (cause makes message less readable by the end user) */
59: public String getMessage() {
60: if (mFieldName != null)
61: return super .getMessageWithCause() + " (FieldName: "
62: + mFieldName + ")";
63: return super.getMessageWithCause();
64: }
65: }
|