KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis > utils > Messages


1 /*
2  * Copyright 2001-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.axis.utils;
18
19 import org.apache.axis.i18n.MessageBundle;
20 import org.apache.axis.i18n.MessagesConstants;
21
22 import java.util.Locale JavaDoc;
23 import java.util.MissingResourceException JavaDoc;
24 import java.util.ResourceBundle JavaDoc;
25
26 /**
27  * @see org.apache.axis.i18n.Messages
28  *
29  * @author Richard A. Sitze (rsitze@us.ibm.com)
30  * @author Karl Moss (kmoss@macromedia.com)
31  * @author Glen Daniels (gdaniels@apache.org)
32  */

33 public class Messages {
34     private static final Class JavaDoc thisClass = Messages.class;
35
36     private static final String JavaDoc projectName = MessagesConstants.projectName;
37
38     private static final String JavaDoc resourceName = MessagesConstants.resourceName;
39     private static final Locale JavaDoc locale = MessagesConstants.locale;
40
41     private static final String JavaDoc packageName = getPackage(thisClass.getName());
42     private static final ClassLoader JavaDoc classLoader = thisClass.getClassLoader();
43
44     private static final ResourceBundle JavaDoc parent =
45         (MessagesConstants.rootPackageName == packageName)
46         ? null
47         : MessagesConstants.rootBundle;
48
49
50     /***** NO NEED TO CHANGE ANYTHING BELOW *****/
51
52     private static final MessageBundle messageBundle =
53         new MessageBundle(projectName, packageName, resourceName,
54                                      locale, classLoader, parent);
55
56     /**
57       * Get a message from resource.properties from the package of the given object.
58       * @param caller The calling object, used to get the package name and class loader
59       * @param locale The locale
60       * @param key The resource key
61       * @return The formatted message
62       */

63     public static String JavaDoc getMessage(String JavaDoc key)
64         throws MissingResourceException JavaDoc
65     {
66         return messageBundle.getMessage(key);
67     }
68
69     /**
70       * Get a message from resource.properties from the package of the given object.
71       * @param caller The calling object, used to get the package name and class loader
72       * @param locale The locale
73       * @param key The resource key
74       * @param arg0 The argument to place in variable {0}
75       * @return The formatted message
76       */

77     public static String JavaDoc getMessage(String JavaDoc key, String JavaDoc arg0)
78         throws MissingResourceException JavaDoc
79     {
80         return messageBundle.getMessage(key, arg0);
81     }
82
83     /**
84       * Get a message from resource.properties from the package of the given object.
85       * @param caller The calling object, used to get the package name and class loader
86       * @param locale The locale
87       * @param key The resource key
88       * @param arg0 The argument to place in variable {0}
89       * @param arg1 The argument to place in variable {1}
90       * @return The formatted message
91       */

92     public static String JavaDoc getMessage(String JavaDoc key, String JavaDoc arg0, String JavaDoc arg1)
93         throws MissingResourceException JavaDoc
94     {
95         return messageBundle.getMessage(key, arg0, arg1);
96     }
97
98     /**
99       * Get a message from resource.properties from the package of the given object.
100       * @param caller The calling object, used to get the package name and class loader
101       * @param locale The locale
102       * @param key The resource key
103       * @param arg0 The argument to place in variable {0}
104       * @param arg1 The argument to place in variable {1}
105       * @param arg2 The argument to place in variable {2}
106       * @return The formatted message
107       */

108     public static String JavaDoc getMessage(String JavaDoc key, String JavaDoc arg0, String JavaDoc arg1, String JavaDoc arg2)
109         throws MissingResourceException JavaDoc
110     {
111         return messageBundle.getMessage(key, arg0, arg1, arg2);
112     }
113
114     /**
115       * Get a message from resource.properties from the package of the given object.
116       * @param caller The calling object, used to get the package name and class loader
117       * @param locale The locale
118       * @param key The resource key
119       * @param arg0 The argument to place in variable {0}
120       * @param arg1 The argument to place in variable {1}
121       * @param arg2 The argument to place in variable {2}
122       * @param arg3 The argument to place in variable {3}
123       * @return The formatted message
124       */

125     public static String JavaDoc getMessage(String JavaDoc key, String JavaDoc arg0, String JavaDoc arg1, String JavaDoc arg2, String JavaDoc arg3)
126         throws MissingResourceException JavaDoc
127     {
128         return messageBundle.getMessage(key, arg0, arg1, arg2, arg3);
129     }
130
131     /**
132       * Get a message from resource.properties from the package of the given object.
133       * @param caller The calling object, used to get the package name and class loader
134       * @param locale The locale
135       * @param key The resource key
136       * @param arg0 The argument to place in variable {0}
137       * @param arg1 The argument to place in variable {1}
138       * @param arg2 The argument to place in variable {2}
139       * @param arg3 The argument to place in variable {3}
140       * @param arg4 The argument to place in variable {4}
141       * @return The formatted message
142       */

143     public static String JavaDoc getMessage(String JavaDoc key, String JavaDoc arg0, String JavaDoc arg1, String JavaDoc arg2, String JavaDoc arg3, String JavaDoc arg4)
144         throws MissingResourceException JavaDoc
145     {
146         return messageBundle.getMessage(key, arg0, arg1, arg2, arg3, arg4);
147     }
148
149     /**
150       * Get a message from resource.properties from the package of the given object.
151       * @param caller The calling object, used to get the package name and class loader
152       * @param locale The locale
153       * @param key The resource key
154       * @param array An array of objects to place in corresponding variables
155       * @return The formatted message
156       */

157     public static String JavaDoc getMessage(String JavaDoc key, String JavaDoc[] args)
158         throws MissingResourceException JavaDoc
159     {
160         return messageBundle.getMessage(key, args);
161     }
162     
163     public static ResourceBundle JavaDoc getResourceBundle() {
164         return messageBundle.getResourceBundle();
165     }
166     
167     public static MessageBundle getMessageBundle() {
168         return messageBundle;
169     }
170
171     private static final String JavaDoc getPackage(String JavaDoc name) {
172         return name.substring(0, name.lastIndexOf('.')).intern();
173     }
174 }
175
Popular Tags