|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.pentaho.reporting.libraries.base.util.ResourceBundleSupport
public class ResourceBundleSupport
An utility class to ease up using property-file resource bundles.
The class support references within the resource bundle set to minimize the occurence of duplicate keys. References are given in the format:a.key.name=@referenced.keyA lookup to a key in an other resource bundle should be written by
a.key.name=@@resourcebundle_name@referenced.key
Constructor Summary | |
---|---|
ResourceBundleSupport(Locale locale,
ResourceBundle resourceBundle)
Creates a new instance. |
|
ResourceBundleSupport(Locale locale,
String baseName)
Creates a new instance. |
|
ResourceBundleSupport(ResourceBundle resourceBundle)
Creates a new instance. |
|
ResourceBundleSupport(String baseName)
Creates a new instance. |
Method Summary | |
---|---|
JMenu |
createMenu(String keyPrefix)
Returns a JMenu created from a resource bundle definition. |
String |
formatMessage(String key,
Object parameter)
Formats the message stored in the resource bundle (using a MessageFormat). |
String |
formatMessage(String key,
Object[] parameters)
Formats the message stored in the resource bundle (using a MessageFormat). |
String |
formatMessage(String key,
Object par1,
Object par2)
Formats the message stored in the resource bundle (using a MessageFormat). |
Icon |
getIcon(String key)
Returns an unscaled icon. |
Icon |
getIcon(String key,
boolean large)
Returns an scaled icon suitable for buttons or menus. |
KeyStroke |
getKeyStroke(String key)
Returns the keystroke stored at the given resourcebundle key. |
KeyStroke |
getKeyStroke(String key,
int mask)
Returns the keystroke stored at the given resourcebundle key. |
Locale |
getLocale()
Returns the current locale for this resource bundle. |
Integer |
getMnemonic(String key)
Returns the mnemonic stored at the given resourcebundle key. |
KeyStroke |
getOptionalKeyStroke(String key)
Returns the keystroke stored at the given resourcebundle key. |
KeyStroke |
getOptionalKeyStroke(String key,
int mask)
Returns the keystroke stored at the given resourcebundle key. |
Integer |
getOptionalMnemonic(String key)
Returns the mnemonic stored at the given resourcebundle key. |
URL |
getResourceURL(String key)
Returns a URL pointing to a resource located in the classpath. |
String |
getString(String key)
Gets a string for the given key from this resource bundle or one of its parents. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ResourceBundleSupport(Locale locale, String baseName)
locale
- the locale that should be used to load the resource-bundle.baseName
- the base name of the resource bundle, a fully qualified
class namepublic ResourceBundleSupport(Locale locale, ResourceBundle resourceBundle)
locale
- the locale for which the resource bundle is
created.resourceBundle
- the resourcebundlepublic ResourceBundleSupport(String baseName)
baseName
- the base name of the resource bundle, a fully qualified
class namepublic ResourceBundleSupport(ResourceBundle resourceBundle)
resourceBundle
- the resourcebundleMethod Detail |
---|
public String getString(String key)
key
- the key for the desired string
NullPointerException
- if key
is null
MissingResourceException
- if no object for the given key can be
found
ClassCastException
- if the object found for the given key is
not a stringpublic Icon getIcon(String key, boolean large)
key
- the name of the resource bundle keylarge
- true, if the image should be scaled to 24x24, or false for
16x16
public Icon getIcon(String key)
key
- the name of the resource bundle key
public Integer getMnemonic(String key)
a.resourcebundle.key=ENTER an.other.resourcebundle.key=\n
key
- the resourcebundle key
public Integer getOptionalMnemonic(String key)
a.resourcebundle.key=ENTER an.other.resourcebundle.key=\n
key
- the resourcebundle key
public KeyStroke getKeyStroke(String key)
a.resourcebundle.key=VK_A an.other.resourcebundle.key=a
key
- the resourcebundle key
Toolkit.getMenuShortcutKeyMask()
public KeyStroke getOptionalKeyStroke(String key)
a.resourcebundle.key=VK_A an.other.resourcebundle.key=a
key
- the resourcebundle key
Toolkit.getMenuShortcutKeyMask()
public KeyStroke getKeyStroke(String key, int mask)
a.resourcebundle.key=VK_A an.other.resourcebundle.key=a
key
- the resourcebundle keymask
- the key-moifier mask to be used to create the keystroke.
Toolkit.getMenuShortcutKeyMask()
public KeyStroke getOptionalKeyStroke(String key, int mask)
a.resourcebundle.key=VK_A an.other.resourcebundle.key=a
key
- the resourcebundle keymask
- the key-moifier mask to be used to create the keystroke.
Toolkit.getMenuShortcutKeyMask()
public JMenu createMenu(String keyPrefix)
# define the file menu menu.file.name=File menu.file.mnemonic=FThe menu definition above can be used to create the menu by calling
createMenu ("menu.file")
.
keyPrefix
- the common prefix for that menu
public URL getResourceURL(String key)
mainmenu.logo=org/jfree/resources/logo.gifThe URL for that file can be queried with:
getResource("mainmenu.logo");
.
key
- the key for the resource
public String formatMessage(String key, Object parameter)
key
- the resourcebundle keyparameter
- the parameter for the message
public String formatMessage(String key, Object par1, Object par2)
key
- the resourcebundle keypar1
- the first parameter for the messagepar2
- the second parameter for the message
public String formatMessage(String key, Object[] parameters)
key
- the resourcebundle keyparameters
- the parameter collection for the message
public Locale getLocale()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |