01: /*
02:
03: Licensed to the Apache Software Foundation (ASF) under one or more
04: contributor license agreements. See the NOTICE file distributed with
05: this work for additional information regarding copyright ownership.
06: The ASF licenses this file to You under the Apache License, Version 2.0
07: (the "License"); you may not use this file except in compliance with
08: the License. You may obtain a copy of the License at
09:
10: http://www.apache.org/licenses/LICENSE-2.0
11:
12: Unless required by applicable law or agreed to in writing, software
13: distributed under the License is distributed on an "AS IS" BASIS,
14: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: See the License for the specific language governing permissions and
16: limitations under the License.
17:
18: */
19: package org.apache.batik.util;
20:
21: import java.util.Locale;
22: import java.util.MissingResourceException;
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 security utilities
29: *
30: * @author <a href="mailto:vhardy@apache.org">Vincent Hardy</a>
31: * @version $Id: Messages.java 478169 2006-11-22 14:23:24Z dvholten $
32: */
33: public class Messages {
34:
35: /**
36: * This class does not need to be instantiated.
37: */
38: protected Messages() {
39: }
40:
41: /**
42: * The error messages bundle class name.
43: */
44: protected static final String RESOURCES = "org.apache.batik.util.resources.Messages";
45:
46: /**
47: * The localizable support for the error messages.
48: */
49: protected static LocalizableSupport localizableSupport = new LocalizableSupport(
50: RESOURCES, Messages.class.getClassLoader());
51:
52: /**
53: * The resource manager to decode messages.
54: */
55: protected static ResourceManager resourceManager = new ResourceManager(
56: localizableSupport.getResourceBundle());
57:
58: /**
59: * Implements {@link org.apache.batik.i18n.Localizable#setLocale(Locale)}.
60: */
61: public static void setLocale(Locale l) {
62: localizableSupport.setLocale(l);
63: resourceManager = new ResourceManager(localizableSupport
64: .getResourceBundle());
65: }
66:
67: /**
68: * Implements {@link org.apache.batik.i18n.Localizable#getLocale()}.
69: */
70: public static Locale getLocale() {
71: return localizableSupport.getLocale();
72: }
73:
74: /**
75: * Implements {@link
76: * org.apache.batik.i18n.Localizable#formatMessage(String,Object[])}.
77: */
78: public static String formatMessage(String key, Object[] args)
79: throws MissingResourceException {
80: return localizableSupport.formatMessage(key, args);
81: }
82:
83: public static String getString(String key)
84: throws MissingResourceException {
85: return resourceManager.getString(key);
86: }
87:
88: public static int getInteger(String key)
89: throws MissingResourceException {
90: return resourceManager.getInteger(key);
91: }
92:
93: public static int getCharacter(String key)
94: throws MissingResourceException {
95: return resourceManager.getCharacter(key);
96: }
97: }
|