01: /**
02: * $Id: ValidationException.java,v 1.1 2005/06/24 17:30:12 rakeshn Exp $
03: * Copyright 2002 Sun Microsystems, Inc. All
04: * rights reserved. Use of this product is subject
05: * to license terms. Federal Acquisitions:
06: * Commercial Software -- Government Users
07: * Subject to Standard License Terms and
08: * Conditions.
09: *
10: * Sun, Sun Microsystems, the Sun logo, and iPlanet
11: * are trademarks or registered trademarks of Sun Microsystems,
12: * Inc. in the United States and other countries.
13: */package com.sun.ssoadapter.impl;
14:
15: import java.util.Locale;
16: import java.util.MissingResourceException;
17: import java.util.ResourceBundle;
18:
19: /**
20: * This class implements exception functionality
21: * that flags SSOAdapter configuration validation errors.
22: *
23: * @version 1.0
24: * @see com.sun.ssoadapter.SSOAdapterFactory
25: * @see com.sun.ssoadapter.SSOAdapter
26: *
27: */
28:
29: public class ValidationException extends Exception {
30:
31: /**
32: * the Error Msg
33: */
34: private String errorMessageID = null;
35:
36: /**
37: * Default Constructor
38: */
39: public ValidationException() {
40: super ();
41: }
42:
43: /**
44: *
45: * @param s Error Message
46: */
47: public ValidationException(String s) {
48: super (s);
49: }
50:
51: /**
52: *
53: * @param s Error Message
54: */
55: public void setErrorMessageID(String s) {
56: errorMessageID = s;
57: }
58:
59: /**
60: *
61: * @return ErrorMessage
62: */
63: public String getErrorMessageID() {
64: return errorMessageID;
65: }
66:
67: /**
68: *
69: * @param baseName
70: * @param locale
71: * @return localizedMessage as String
72: */
73: public String getLocalizedMessage(String baseName, Locale locale) {
74: String lmsg = null;
75: ResourceBundle bundle = null;
76:
77: if (locale == null) {
78: locale = Locale.getDefault();
79: }
80:
81: try {
82: bundle = ResourceBundle.getBundle(baseName, locale);
83: lmsg = bundle.getString(getErrorMessageID());
84: } catch (NullPointerException npe) {
85: lmsg = "";
86: } catch (MissingResourceException mre) {
87: lmsg = "";
88: }
89:
90: return lmsg;
91: }
92:
93: }
|