• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Licensed to the Apache Software Foundation (ASF) under one or more
3  *  contributor license agreements.  See the NOTICE file distributed with
4  *  this work for additional information regarding copyright ownership.
5  *  The ASF licenses this file to You under the Apache License, Version 2.0
6  *  (the "License"); you may not use this file except in compliance with
7  *  the License.  You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an "AS IS" BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License.
16  */
17 
18 package java.util;
19 
20 
21 /**
22  * A {@code MissingResourceException} is thrown by ResourceBundle when a
23  * resource bundle cannot be found or a resource is missing from a resource
24  * bundle.
25  *
26  * @see ResourceBundle
27  * @see java.lang.RuntimeException
28  */
29 public class MissingResourceException extends RuntimeException {
30 
31     private static final long serialVersionUID = -4876345176062000401L;
32 
33     String className, key;
34 
35     /**
36      * Constructs a new {@code MissingResourceException} with the stack trace,
37      * message, the class name of the resource bundle and the name of the
38      * missing resource filled in.
39      *
40      * @param detailMessage
41      *           the detail message for the exception.
42      * @param className
43      *           the class name of the resource bundle.
44      * @param resourceName
45      *           the name of the missing resource.
46      */
MissingResourceException(String detailMessage, String className, String resourceName)47     public MissingResourceException(String detailMessage, String className,
48             String resourceName) {
49         super(detailMessage);
50         this.className = className;
51         key = resourceName;
52     }
53 
54     /**
55      * Returns the class name of the resource bundle from which a resource could
56      * not be found, or in the case of a missing resource, the name of the
57      * missing resource bundle.
58      *
59      * @return the class name of the resource bundle.
60      */
getClassName()61     public String getClassName() {
62         return className;
63     }
64 
65     /**
66      * Returns the name of the missing resource, or an empty string if the
67      * resource bundle is missing.
68      *
69      * @return the name of the missing resource.
70      */
getKey()71     public String getKey() {
72         return key;
73     }
74 
75 }
76