01: /*
02: * Copyright 2006 Luca Garulli (luca.garulli@assetdata.it)
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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:
17: package org.romaframework.core.validation;
18:
19: import org.romaframework.core.exception.FieldErrorUserException;
20:
21: public class ValidationException extends FieldErrorUserException {
22: public ValidationException(Object iInstance, String iFieldName,
23: String iMessage, String iRefValue) {
24: super (iInstance, iFieldName, iMessage);
25: setRefValue(iRefValue);
26: }
27:
28: public ValidationException(Object iInstance, String iFieldName,
29: String iMessage, String iRefValue, Throwable cause) {
30: super (iInstance, iFieldName, iMessage, cause);
31: setRefValue(iRefValue);
32: }
33:
34: public String getRefValue() {
35: return refValue;
36: }
37:
38: private void setRefValue(String iRefValue) {
39: refValue = iRefValue;
40:
41: if (refValue != null) {
42: message.append(" (");
43: message.append(refValue);
44: message.append(')');
45: }
46: }
47:
48: @Override
49: public String toString() {
50: StringBuffer buffer = new StringBuffer(super .toString());
51: if (refValue != null) {
52: buffer.append(" refValue: ");
53: buffer.append(refValue);
54: }
55: return buffer.toString();
56: }
57:
58: protected String refValue;
59:
60: public static final String VALIDATION_POSTFIX = ".validation";
61: }
|