KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > axis > i18n > Messages


1 /*
2  * The Apache Software License, Version 1.1
3  *
4  *
5  * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
6  * reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in
17  * the documentation and/or other materials provided with the
18  * distribution.
19  *
20  * 3. The end-user documentation included with the redistribution,
21  * if any, must include the following acknowledgment:
22  * "This product includes software developed by the
23  * Apache Software Foundation (http://www.apache.org/)."
24  * Alternately, this acknowledgment may appear in the software itself,
25  * if and wherever such third-party acknowledgments normally appear.
26  *
27  * 4. The names "Axis" and "Apache Software Foundation" must
28  * not be used to endorse or promote products derived from this
29  * software without prior written permission. For written
30  * permission, please contact apache@apache.org.
31  *
32  * 5. Products derived from this software may not be called "Apache",
33  * nor may "Apache" appear in their name, without prior written
34  * permission of the Apache Software Foundation.
35  *
36  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
37  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
38  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
39  * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
40  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
42  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
43  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
44  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
45  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
46  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47  * SUCH DAMAGE.
48  * ====================================================================
49  *
50  * This software consists of voluntary contributions made by many
51  * individuals on behalf of the Apache Software Foundation. For more
52  * information on the Apache Software Foundation, please see
53  * <http://www.apache.org/>.
54  */

55
56 package org.jboss.axis.i18n;
57
58 import java.util.Locale JavaDoc;
59 import java.util.MissingResourceException JavaDoc;
60 import java.util.ResourceBundle JavaDoc;
61
62
63 /**
64  * @author Richard A. Sitze (rsitze@us.ibm.com)
65  * @author Karl Moss (kmoss@macromedia.com)
66  * @author Glen Daniels (gdaniels@macromedia.com)
67  * @see org.jboss.axis.i18n.Messages
68  * <p/>
69  * FUNCTIONAL TEMPLATE for Messages classes.
70  * <p/>
71  * Copy this template to your package.
72  * <p/>
73  * For subpackages of org.jboss.axis.*, the internal constants
74  * are set appropriately. To adapt this scheme to an extension project
75  * (package prefix differs from org.jboss.axis.*), edit the projectName
76  * attribute. The others shouldn't need to be changed unless this is
77  * being adapted to a non-AXIS related project..
78  */

79 public class Messages
80 {
81    private static final Class JavaDoc thisClass = Messages.class;
82
83    private static final String JavaDoc projectName = MessagesConstants.projectName;
84
85    private static final String JavaDoc resourceName = MessagesConstants.resourceName;
86    private static final Locale JavaDoc locale = MessagesConstants.locale;
87
88    private static final String JavaDoc packageName = getPackage(thisClass.getName());
89    private static final ClassLoader JavaDoc classLoader = thisClass.getClassLoader();
90
91    private static final ResourceBundle JavaDoc parent =
92            (MessagesConstants.rootPackageName == packageName)
93            ? null
94            : MessagesConstants.rootBundle;
95
96
97    /**
98     * ** NO NEED TO CHANGE ANYTHING BELOW ****
99     */

100
101    private static final MessageBundle messageBundle =
102            new MessageBundle(projectName, packageName, resourceName,
103                    locale, classLoader, parent);
104
105    /**
106     * Get a message from resource.properties from the package of the given object.
107     *
108     * @param caller The calling object, used to get the package name and class loader
109     * @param locale The locale
110     * @param key The resource key
111     * @return The formatted message
112     */

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

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

144    public static String JavaDoc getMessage(String JavaDoc key, String JavaDoc arg0, String JavaDoc arg1)
145            throws MissingResourceException JavaDoc
146    {
147       return messageBundle.getMessage(key, arg0, arg1);
148    }
149
150    /**
151     * Get a message from resource.properties from the package of the given object.
152     *
153     * @param caller The calling object, used to get the package name and class loader
154     * @param locale The locale
155     * @param key The resource key
156     * @param arg0 The argument to place in variable {0}
157     * @param arg1 The argument to place in variable {1}
158     * @param arg2 The argument to place in variable {2}
159     * @return The formatted message
160     */

161    public static String JavaDoc getMessage(String JavaDoc key, String JavaDoc arg0, String JavaDoc arg1, String JavaDoc arg2)
162            throws MissingResourceException JavaDoc
163    {
164       return messageBundle.getMessage(key, arg0, arg1, arg2);
165    }
166
167    /**
168     * Get a message from resource.properties from the package of the given object.
169     *
170     * @param caller The calling object, used to get the package name and class loader
171     * @param locale The locale
172     * @param key The resource key
173     * @param arg0 The argument to place in variable {0}
174     * @param arg1 The argument to place in variable {1}
175     * @param arg2 The argument to place in variable {2}
176     * @param arg3 The argument to place in variable {3}
177     * @return The formatted message
178     */

179    public static String JavaDoc getMessage(String JavaDoc key, String JavaDoc arg0, String JavaDoc arg1, String JavaDoc arg2, String JavaDoc arg3)
180            throws MissingResourceException JavaDoc
181    {
182       return messageBundle.getMessage(key, arg0, arg1, arg2, arg3);
183    }
184
185    /**
186     * Get a message from resource.properties from the package of the given object.
187     *
188     * @param caller The calling object, used to get the package name and class loader
189     * @param locale The locale
190     * @param key The resource key
191     * @param arg0 The argument to place in variable {0}
192     * @param arg1 The argument to place in variable {1}
193     * @param arg2 The argument to place in variable {2}
194     * @param arg3 The argument to place in variable {3}
195     * @param arg4 The argument to place in variable {4}
196     * @return The formatted message
197     */

198    public static String JavaDoc getMessage(String JavaDoc key, String JavaDoc arg0, String JavaDoc arg1, String JavaDoc arg2, String JavaDoc arg3, String JavaDoc arg4)
199            throws MissingResourceException JavaDoc
200    {
201       return messageBundle.getMessage(key, arg0, arg1, arg2, arg3, arg4);
202    }
203
204    /**
205     * Get a message from resource.properties from the package of the given object.
206     *
207     * @param caller The calling object, used to get the package name and class loader
208     * @param locale The locale
209     * @param key The resource key
210     * @param array An array of objects to place in corresponding variables
211     * @return The formatted message
212     */

213    public static String JavaDoc getMessage(String JavaDoc key, String JavaDoc[] args)
214            throws MissingResourceException JavaDoc
215    {
216       return messageBundle.getMessage(key, args);
217    }
218
219    public static ResourceBundle JavaDoc getResourceBundle()
220    {
221       return messageBundle.getResourceBundle();
222    }
223
224    public static MessageBundle getMessageBundle()
225    {
226       return messageBundle;
227    }
228
229    private static final String JavaDoc getPackage(String JavaDoc name)
230    {
231       return name.substring(0, name.lastIndexOf('.')).intern();
232    }
233 }
234
Popular Tags