KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis > i18n > 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.i18n;
18
19 import java.util.Locale JavaDoc;
20 import java.util.MissingResourceException JavaDoc;
21 import java.util.ResourceBundle JavaDoc;
22
23
24 /**
25  * @see org.apache.axis.i18n.Messages
26  *
27  * FUNCTIONAL TEMPLATE for Messages classes.
28  *
29  * Copy this template to your package.
30  *
31  * For subpackages of org.apache.axis.*, the internal constants
32  * are set appropriately. To adapt this scheme to an extension project
33  * (package prefix differs from org.apache.axis.*), edit the projectName
34  * attribute. The others shouldn't need to be changed unless this is
35  * being adapted to a non-AXIS related project..
36  *
37  * @author Richard A. Sitze (rsitze@us.ibm.com)
38  * @author Karl Moss (kmoss@macromedia.com)
39  * @author Glen Daniels (gdaniels@apache.org)
40  */

41 public class Messages {
42     private static final Class JavaDoc thisClass = Messages.class;
43
44     private static final String JavaDoc projectName = MessagesConstants.projectName;
45
46     private static final String JavaDoc resourceName = MessagesConstants.resourceName;
47     private static final Locale JavaDoc locale = MessagesConstants.locale;
48
49     private static final String JavaDoc packageName = getPackage(thisClass.getName());
50     private static final ClassLoader JavaDoc classLoader = thisClass.getClassLoader();
51
52     private static final ResourceBundle JavaDoc parent =
53         (MessagesConstants.rootPackageName == packageName)
54         ? null
55         : MessagesConstants.rootBundle;
56
57
58     /***** NO NEED TO CHANGE ANYTHING BELOW *****/
59
60     private static final MessageBundle messageBundle =
61         new MessageBundle(projectName, packageName, resourceName,
62                                      locale, classLoader, parent);
63
64     /**
65       * Get a message from resource.properties from the package of the given object.
66       * @param key The resource key
67       * @return The formatted message
68       */

69     public static String JavaDoc getMessage(String JavaDoc key)
70         throws MissingResourceException JavaDoc
71     {
72         return messageBundle.getMessage(key);
73     }
74
75     /**
76       * Get a message from resource.properties from the package of the given object.
77       * @param key The resource key
78       * @param arg0 The argument to place in variable {0}
79       * @return The formatted message
80       */

81     public static String JavaDoc getMessage(String JavaDoc key, String JavaDoc arg0)
82         throws MissingResourceException JavaDoc
83     {
84         return messageBundle.getMessage(key, arg0);
85     }
86
87     /**
88       * Get a message from resource.properties from the package of the given object.
89       * @param key The resource key
90       * @param arg0 The argument to place in variable {0}
91       * @param arg1 The argument to place in variable {1}
92       * @return The formatted message
93       */

94     public static String JavaDoc getMessage(String JavaDoc key, String JavaDoc arg0, String JavaDoc arg1)
95         throws MissingResourceException JavaDoc
96     {
97         return messageBundle.getMessage(key, arg0, arg1);
98     }
99
100     /**
101       * Get a message from resource.properties from the package of the given object.
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 key The resource key
117       * @param arg0 The argument to place in variable {0}
118       * @param arg1 The argument to place in variable {1}
119       * @param arg2 The argument to place in variable {2}
120       * @param arg3 The argument to place in variable {3}
121       * @return The formatted message
122       */

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

139     public static String JavaDoc getMessage(String JavaDoc key, String JavaDoc arg0, String JavaDoc arg1, String JavaDoc arg2, String JavaDoc arg3, String JavaDoc arg4)
140         throws MissingResourceException JavaDoc
141     {
142         return messageBundle.getMessage(key, arg0, arg1, arg2, arg3, arg4);
143     }
144
145     /**
146       * Get a message from resource.properties from the package of the given object.
147       * @param key The resource key
148       * @param args An array of objects to place in corresponding variables
149       * @return The formatted message
150       */

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