KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > ext > swing > Resources


1 /*
2
3    Copyright 1999-2003 The Apache Software Foundation
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    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
19 package org.apache.batik.ext.swing;
20
21 import java.util.Locale JavaDoc;
22 import java.util.MissingResourceException JavaDoc;
23
24 import org.apache.batik.i18n.LocalizableSupport;
25 import org.apache.batik.util.gui.resource.ResourceManager;
26
27 /**
28  * This class manages the message for the Swing extensions.
29  *
30  * @author <a HREF="mailto:vhardy@apache.org">Vincent Hardy</a>
31  * @version $Id: Resources.java,v 1.6 2004/10/30 18:38:05 deweese Exp $
32  */

33 public class Resources {
34
35     /**
36      * This class does not need to be instantiated.
37      */

38     protected Resources() { }
39
40     /**
41      * The error messages bundle class name.
42      */

43     protected final static String JavaDoc RESOURCES =
44         "org.apache.batik.ext.swing.resources.Messages";
45
46     /**
47      * The localizable support for the error messages.
48      */

49     protected static LocalizableSupport localizableSupport =
50         new LocalizableSupport(RESOURCES, Resources.class.getClassLoader());
51
52     /**
53      * The resource manager to decode messages.
54      */

55     protected static ResourceManager resourceManager =
56         new ResourceManager(localizableSupport.getResourceBundle());
57
58     /**
59      * Implements {@link org.apache.batik.i18n.Localizable#setLocale(Locale)}.
60      */

61     public static void setLocale(Locale JavaDoc l) {
62         localizableSupport.setLocale(l);
63         resourceManager = new ResourceManager(localizableSupport.getResourceBundle());
64     }
65
66     /**
67      * Implements {@link org.apache.batik.i18n.Localizable#getLocale()}.
68      */

69     public static Locale JavaDoc getLocale() {
70         return localizableSupport.getLocale();
71     }
72
73     /**
74      * Implements {@link
75      * org.apache.batik.i18n.Localizable#formatMessage(String,Object[])}.
76      */

77     public static String JavaDoc formatMessage(String JavaDoc key, Object JavaDoc[] args)
78         throws MissingResourceException JavaDoc {
79         return localizableSupport.formatMessage(key, args);
80     }
81
82     public static String JavaDoc getString(String JavaDoc key)
83         throws MissingResourceException JavaDoc {
84         return resourceManager.getString(key);
85     }
86
87     public static int getInteger(String JavaDoc key)
88         throws MissingResourceException JavaDoc {
89         return resourceManager.getInteger(key);
90     }
91 }
92
Popular Tags