| MissingResourceException.java |
1 /*
2 * %W% %E%
3 *
4 * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
5 * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6 */
7
8 /*
9 * (C) Copyright Taligent, Inc. 1996, 1997 - All Rights Reserved
10 * (C) Copyright IBM Corp. 1996 - 1998 - All Rights Reserved
11 *
12 * The original version of this source code and documentation
13 * is copyrighted and owned by Taligent, Inc., a wholly-owned
14 * subsidiary of IBM. These materials are provided under terms
15 * of a License Agreement between Taligent and Sun. This technology
16 * is protected by multiple US and International patents.
17 *
18 * This notice and attribution to Taligent may not be removed.
19 * Taligent is a registered trademark of Taligent, Inc.
20 *
21 */
22
23 package java.util;
24
25 /**
26 * Signals that a resource is missing.
27 * @see java.lang.Exception
28 * @see ResourceBundle
29 * @version %I%, %G%
30 * @author Mark Davis
31 * @since JDK1.1
32 */
33 public
34 class MissingResourceException extends RuntimeException {
35
36 /**
37 * Constructs a MissingResourceException with the specified information.
38 * A detail message is a String that describes this particular exception.
39 * @param s the detail message
40 * @param className the name of the resource class
41 * @param key the key for the missing resource.
42 */
43 public MissingResourceException(String s, String className, String key) {
44 super(s);
45 this.className = className;
46 this.key = key;
47 }
48
49 /**
50 * Constructs a <code>MissingResourceException</code> with
51 * <code>message</code>, <code>className</code>, <code>key</code>,
52 * and <code>cause</code>. This constructor is package private for
53 * use by <code>ResourceBundle.getBundle</code>.
54 *
55 * @param message
56 * the detail message
57 * @param className
58 * the name of the resource class
59 * @param key
60 * the key for the missing resource.
61 * @param cause
62 * the cause (which is saved for later retrieval by the
63 * {@link Throwable.getCause()} method). (A null value is
64 * permitted, and indicates that the cause is nonexistent
65 * or unknown.)
66 */
67 MissingResourceException(String message, String className, String key, Throwable cause) {
68 super(message, cause);
69 this.className = className;
70 this.key = key;
71 }
72
73 /**
74 * Gets parameter passed by constructor.
75 *
76 * @return the name of the resource class
77 */
78 public String getClassName() {
79 return className;
80 }
81
82 /**
83 * Gets parameter passed by constructor.
84 *
85 * @return the key for the missing resource
86 */
87 public String getKey() {
88 return key;
89 }
90
91 //============ privates ============
92
93 // serialization compatibility with JDK1.1
94 private static final long serialVersionUID = -4876345176062000401L;
95
96 /**
97 * The class name of the resource bundle requested by the user.
98 * @serial
99 */
100 private String className;
101
102 /**
103 * The name of the specific resource requested by the user.
104 * @serial
105 */
106 private String key;
107 }
108