01: /**
02: * Objective Database Abstraction Layer (ODAL)
03: * Copyright (c) 2004, The ODAL Development Group
04: * All rights reserved.
05: * For definition of the ODAL Development Group please refer to LICENCE.txt file
06: *
07: * Distributable under LGPL license.
08: * See terms of license at gnu.org.
09: */package com.completex.objective.components.persistency;
10:
11: import com.completex.objective.components.persistency.rule.RuleException;
12: import com.completex.objective.components.persistency.rule.RuntimeRuleException;
13:
14: /**
15: * @author Gennady Krizhevsky
16: */
17: public class RecordValidationException extends OdalPersistencyException {
18:
19: private RuleException[] elementExceptions;
20:
21: public RecordValidationException(
22: RuntimeRuleException runtimeRuleException) {
23: if (runtimeRuleException != null
24: && runtimeRuleException.hasElementExceptions()) {
25: this .elementExceptions = runtimeRuleException
26: .getElementExceptions();
27: }
28: }
29:
30: public RecordValidationException(String reason) {
31: super (reason);
32: }
33:
34: public RecordValidationException(String reason,
35: RecordValidationException recordValidationException) {
36: super (
37: reason != null ? reason
38: : (recordValidationException != null ? recordValidationException
39: .getMessage()
40: : null));
41: if (recordValidationException != null) {
42: this .elementExceptions = recordValidationException
43: .getElementExceptions();
44: }
45: }
46:
47: public RuleException[] getElementExceptions() {
48: return elementExceptions;
49: }
50:
51: public String getMessage() {
52: String super Message = super MessageWoNull();
53: String localMessage = !"".equals(super Message) ? super Message
54: + RuleException.NL : super Message;
55: return hasElementExceptions() ? localMessage + getFullMessage()
56: : localMessage;
57: }
58:
59: private String super MessageWoNull() {
60: return super .getMessage() == null ? "" : super .getMessage();
61: }
62:
63: public String getFullMessage() {
64: String message = hasElementExceptions() ? ""
65: : super MessageWoNull();
66: return RuleException.getFullMessage(elementExceptions, message);
67: }
68:
69: public String getFullDetailedMessage() {
70: return RuleException.getFullDetailedMessage(elementExceptions,
71: super MessageWoNull());
72: }
73:
74: public boolean hasElementExceptions() {
75: return elementExceptions != null
76: && elementExceptions.length > 0;
77: }
78: }
|