01: /*--------------------------------------------------------------------------*
02: | Copyright (C) 2006 Christopher Kohlhaas |
03: | |
04: | This program is free software; you can redistribute it and/or modify |
05: | it under the terms of the GNU General Public License as published by the |
06: | Free Software Foundation. A copy of the license has been included with |
07: | these distribution in the COPYING file, if not go to www.fsf.org |
08: | |
09: | As a special exception, you are granted the permissions to link this |
10: | program with every library, which license fulfills the Open Source |
11: | Definition as published by the Open Source Initiative (OSI). |
12: *--------------------------------------------------------------------------*/
13: package org.rapla.components.xmlbundle;
14:
15: import java.net.URL;
16: import java.util.Locale;
17: import java.util.MissingResourceException;
18:
19: import javax.swing.ImageIcon;
20:
21: /**The interface provides access to a resourcebundle that
22: can be defined in XML or as an java-object.
23: Example Usage:
24: <pre>
25: I18nBundle i18n = (I18nBundle)serviceManager.lookup(I18nBundle.ROLE);
26: i18n.getString("yes"); // will get the translation for yes.
27: </pre>
28: */
29:
30: public interface I18nBundle {
31: String ROLE = I18nBundle.class.getName();
32:
33: /** same as </code>format(key,new Object[] {obj1});</code>
34: @see #format(String,Object[])
35: */
36: String format(String key, Object obj1)
37: throws MissingResourceException;
38:
39: /** same as </code>format(key,new Object[] {obj1, obj2});</code>
40: @see #format(String,Object[])
41: */
42: String format(String key, Object obj1, Object obj2)
43: throws MissingResourceException;
44:
45: /** same as
46: <code>
47: (new MessageFormat(getString(key))).format(obj);
48: </code>
49: @see java.text.MessageFormat
50: */
51: String format(String key, Object[] obj)
52: throws MissingResourceException;
53:
54: /** returns the specified icon from the image-resource-file.
55: @throws MissingResourceException if not found or can't be loaded.
56: */
57: ImageIcon getIcon(String key) throws MissingResourceException;
58:
59: /** returns the specified string from the selected resource-file.
60: @throws MissingResourceException if not found or can't be loaded.
61: */
62: String getString(String key) throws MissingResourceException;
63:
64: /** returns the URL of a resource, with the specified key. Use this method to directly
65: * access the Image Resources instead of creating an Icon.*/
66: URL getResource(String key) throws MissingResourceException;
67:
68: /** @return the selected language. */
69: String getLang();
70:
71: /** @return the selected Locale. */
72: Locale getLocale();
73: }
|