01: /* Copyright 2004 The JA-SIG Collaborative. All rights reserved.
02: * See license distributed with this file and
03: * available online at http://www.uportal.org/license.html
04: */
05:
06: package org.jasig.portal.properties;
07:
08: /**
09: * This is an undeclared (Runtime) exception to be thrown by the
10: * PropertiesManager when a property is requested but cannot be
11: * parsed and returned as the desired type.
12: * @author andrew.petro@yale.edu
13: * @version $Revision: 35625 $ $Date: 2005-04-18 18:18:38 -0700 (Mon, 18 Apr 2005) $
14: * @since uPortal 2.4
15: */
16: public class BadPropertyException extends RuntimeException {
17:
18: /** The name of the property */
19: private final String propertyName;
20:
21: /** The value of the property */
22: private final String propertyValue;
23:
24: /** The desired type, as which the property could not be parsed. */
25: private final String desiredType;
26:
27: /**
28: * Instantiate a new BadPropertyException.
29: * @param propertyName - the name of the property
30: * @param propertyValue - the bad value of the property.
31: * @param desiredType - the name of the desired type which the value wasn't, making it bad.
32: */
33: public BadPropertyException(String propertyName,
34: String propertyValue, String desiredType) {
35: this .propertyName = propertyName;
36: this .propertyValue = propertyValue;
37: this .desiredType = desiredType;
38: }
39:
40: /**
41: * Instantiate a new BadPropertyException with the given underlying cause.
42: * @param propertyName - the name of the property
43: * @param propertyValue - the bad value of the property.
44: * @param desiredType - the name of the desired type which the value wasn't, making it bad.
45: * @param cause - underlying cause
46: */
47: public BadPropertyException(String propertyName,
48: String propertyValue, String desiredType, Throwable cause) {
49: super (cause);
50: this .propertyName = propertyName;
51: this .propertyValue = propertyValue;
52: this .desiredType = desiredType;
53: }
54:
55: public String getMessage() {
56: return "The property [" + this .propertyName + "] had value ["
57: + this .propertyValue
58: + "] which could not be parsed as type ["
59: + this .desiredType + "].";
60: }
61:
62: public String getLocalizedMessage() {
63: return getMessage();
64: }
65:
66: /**
67: * Get the desired type as which the property could not be parsed.
68: * @return Returns the desiredType.
69: */
70: public String getDesiredType() {
71: return this .desiredType;
72: }
73:
74: /**
75: * Get the name of the bad property.
76: * @return Returns the propertyName.
77: */
78: public String getPropertyName() {
79: return this .propertyName;
80: }
81:
82: /**
83: * Get the actual value of the property.
84: * @return Returns the propertyValue.
85: */
86: public String getPropertyValue() {
87: return this.propertyValue;
88: }
89: }
|