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.bo;
16:
17: /** Specialised BOLayer exception. Used in cases when underlying BO record has not been found in persistence layer */
18: public class BORecordNotFoundException extends BOException {
19: private String mRecordType;
20: private String[] mAttemptedIdentifierNames;
21: private String[] mAttemptedIdentifierValues;
22:
23: /** Hides default constructor*/
24: private BORecordNotFoundException() {
25: }
26:
27: /** Constructs BORecordNotFoundException
28: * @param pRecordType - the unique identifier of the type of the record, which was not found */
29: public BORecordNotFoundException(String pRecordType,
30: String[] pAttemptedIdentifierNames,
31: String[] pAttemptedIdentifierValues) {
32: mRecordType = pRecordType;
33: mAttemptedIdentifierNames = pAttemptedIdentifierNames;
34: mAttemptedIdentifierValues = pAttemptedIdentifierValues;
35: }
36:
37: /** Returns the unique identifier of the type of the record, which was not found */
38: public String getRecordType() {
39: return mRecordType;
40: }
41:
42: public String getMessage() {
43: String lReturn = "Instance of " + mRecordType
44: + " is not found.";
45: if (mAttemptedIdentifierNames != null) {
46: if (mAttemptedIdentifierNames.length == 1) {
47: lReturn += " Attempted identifier is "
48: + mAttemptedIdentifierNames[0] + "='"
49: + mAttemptedIdentifierValues[0] + "'.";
50: } else {
51: lReturn += " Attempted identifiers are : ";
52: for (int i = 0; i < mAttemptedIdentifierNames.length; i++) {
53: if (i > 0)
54: lReturn += ", ";
55: lReturn += mAttemptedIdentifierNames[i] + "='"
56: + mAttemptedIdentifierValues[i] + "'";
57: }
58: }
59: }
60: return lReturn;
61: }
62: }
|