|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.openide.util.NbBundle
public class NbBundle
Convenience class permitting easy loading of localized resources of various sorts. Extends the functionality of the default Java resource support, and interacts better with class loaders in a multiple-loader system.
Example usage:
package com.mycom;
public class Foo {
// Search for tag Foo_theMessage in /com/mycom/Bundle.properties:
private static String theMessage =
NbBundle.getMessage
(Foo.class, "Foo_theMessage");
// Might also look in /com/mycom/Bundle_de.properties, etc.
}
Nested Class Summary | |
---|---|
static interface |
NbBundle.ClassLoaderFinder
Deprecated. Useless. |
Constructor Summary | |
---|---|
NbBundle()
Deprecated. There is no reason to instantiate or subclass this class. All methods in it are static. |
Method Summary | ||
---|---|---|
static java.lang.String |
getBranding()
Get the current branding token. |
|
static java.util.ResourceBundle |
getBundle(java.lang.Class clazz)
Get a resource bundle in the same package as the provided class, with the default locale/branding and the class' own classloader. |
|
static java.util.ResourceBundle |
getBundle(java.lang.String baseName)
Get a resource bundle with the default class loader and locale/branding. |
|
static java.util.ResourceBundle |
getBundle(java.lang.String baseName,
java.util.Locale locale)
Get a resource bundle with the default class loader and branding. |
|
static java.util.ResourceBundle |
getBundle(java.lang.String baseName,
java.util.Locale locale,
java.lang.ClassLoader loader)
Get a resource bundle the hard way. |
|
static java.net.URL |
getLocalizedFile(java.lang.String baseName,
java.lang.String ext)
Deprecated. Use the nbresloc URL protocol instead. This method does a poor
job of handling resources such as /some.dir/res.txt or
/some/res.txt.sample. |
|
static java.net.URL |
getLocalizedFile(java.lang.String baseName,
java.lang.String ext,
java.util.Locale locale)
Deprecated. Use the nbresloc URL protocol instead. This method does a poor
job of handling resources such as /some.dir/res.txt or
/some/res.txt.sample. |
|
static java.net.URL |
getLocalizedFile(java.lang.String baseName,
java.lang.String ext,
java.util.Locale locale,
java.lang.ClassLoader loader)
Deprecated. Use the nbresloc URL protocol instead. This method does a poor
job of handling resources such as /some.dir/res.txt or
/some/res.txt.sample. |
|
static java.lang.String |
getLocalizedValue(java.util.jar.Attributes attr,
java.util.jar.Attributes.Name key)
Find a localized and/or branded value in a JAR manifest in the default system locale. |
|
static java.lang.String |
getLocalizedValue(java.util.jar.Attributes attr,
java.util.jar.Attributes.Name key,
java.util.Locale locale)
Find a localized and/or branded value in a JAR manifest. |
|
static
|
getLocalizedValue(java.util.Map<java.lang.String,T> table,
java.lang.String key)
Find a localized and/or branded value for a given key in the default system locale. |
|
static
|
getLocalizedValue(java.util.Map<java.lang.String,T> table,
java.lang.String key,
java.util.Locale locale)
Find a localized and/or branded value for a given key and locale. |
|
static java.util.Iterator<java.lang.String> |
getLocalizingSuffixes()
Get a list of all suffixes used to search for localized/branded resources. |
|
static java.lang.String |
getMessage(java.lang.Class clazz,
java.lang.String resName)
Finds a localized and/or branded string in a bundle. |
|
static java.lang.String |
getMessage(java.lang.Class clazz,
java.lang.String resName,
java.lang.Object param1)
Finds a localized and/or branded string in a bundle and formats the message by passing requested parameters. |
|
static java.lang.String |
getMessage(java.lang.Class clazz,
java.lang.String resName,
java.lang.Object[] arr)
Finds a localized and/or branded string in a bundle and formats the message by passing requested parameters. |
|
static java.lang.String |
getMessage(java.lang.Class clazz,
java.lang.String resName,
java.lang.Object param1,
java.lang.Object param2)
Finds a localized and/or branded string in a bundle and formats the message by passing requested parameters. |
|
static java.lang.String |
getMessage(java.lang.Class clazz,
java.lang.String resName,
java.lang.Object param1,
java.lang.Object param2,
java.lang.Object param3)
Finds a localized and/or branded string in a bundle and formats the message by passing requested parameters. |
|
static void |
setBranding(java.lang.String bt)
Set the current branding token. |
|
static void |
setClassLoaderFinder(NbBundle.ClassLoaderFinder loaderFinder)
Deprecated. Useless. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
@Deprecated public NbBundle()
Method Detail |
---|
public static java.lang.String getBranding()
null
for nonepublic static void setBranding(java.lang.String bt) throws java.lang.IllegalArgumentException
[a-z][a-z0-9]*(_[a-z][a-z0-9]*)*
This is normally only called by NetBeans startup code and unit tests.
Currently the branding may be specified by passing the --branding
command-line option to the launcher.
bt
- the new branding, or null
to clear
java.lang.IllegalArgumentException
- if in an incorrect format@Deprecated public static java.net.URL getLocalizedFile(java.lang.String baseName, java.lang.String ext) throws java.util.MissingResourceException
nbresloc
URL protocol instead. This method does a poor
job of handling resources such as /some.dir/res.txt or
/some/res.txt.sample.
Note that use of this call is similar to using the URL protocol nbresloc
(which may in fact be implemented using the fuller form of the method).
The extension may be null, in which case no final dot will be appended. If it is the empty string, the resource will end in a dot.
baseName
- base name of file, as dot-separated path (e.g. some.dir.File
)ext
- extension of file (or null
)
java.util.MissingResourceException
- if not found@Deprecated public static java.net.URL getLocalizedFile(java.lang.String baseName, java.lang.String ext, java.util.Locale locale) throws java.util.MissingResourceException
nbresloc
URL protocol instead. This method does a poor
job of handling resources such as /some.dir/res.txt or
/some/res.txt.sample.
baseName
- base name of file, as dot-separated path (e.g. some.dir.File
)ext
- extension of file (or null
)locale
- locale of file
java.util.MissingResourceException
- if not found@Deprecated public static java.net.URL getLocalizedFile(java.lang.String baseName, java.lang.String ext, java.util.Locale locale, java.lang.ClassLoader loader) throws java.util.MissingResourceException
nbresloc
URL protocol instead. This method does a poor
job of handling resources such as /some.dir/res.txt or
/some/res.txt.sample.
baseName
- base name of file, as dot-separated path (e.g. some.dir.File
)ext
- extension of file (or null
)locale
- locale of fileloader
- class loader to use
java.util.MissingResourceException
- if not foundpublic static <T> T getLocalizedValue(java.util.Map<java.lang.String,T> table, java.lang.String key, java.util.Locale locale)
findLocalizedValue (hashTable, "keyName", new Locale ("cs_CZ"))
This would return the first non-null
value obtained from the following tests:
hashTable.get ("keyName_cs_CZ")
hashTable.get ("keyName_cs")
hashTable.get ("keyName")
table
- mapping from localized strings to objectskey
- the key to look forlocale
- the locale to use
null
if no key matchespublic static <T> T getLocalizedValue(java.util.Map<java.lang.String,T> table, java.lang.String key)
table
- mapping from localized strings to objectskey
- the key to look for
null
if no key matchesgetLocalizedValue(Map,String,Locale)
public static java.lang.String getLocalizedValue(java.util.jar.Attributes attr, java.util.jar.Attributes.Name key, java.util.Locale locale)
attr
- the manifest attributeskey
- the key to look for (case-insensitive)locale
- the locale to use
null
public static java.lang.String getLocalizedValue(java.util.jar.Attributes attr, java.util.jar.Attributes.Name key)
attr
- the manifest attributeskey
- the key to look for (case-insensitive)
null
public static final java.util.ResourceBundle getBundle(java.lang.String baseName) throws java.util.MissingResourceException
getBundle(Class)
is generally
safer when used from a module as this method relies on the module's
classloader to currently be part of the system classloader. NetBeans
does add enabled modules to this classloader, however calls to
this variant of the method made in ModuleInstall.validate,
or made soon after a module is uninstalled (due to background threads)
could fail unexpectedly.
baseName
- bundle basename
java.util.MissingResourceException
- if the bundle does not existpublic static java.util.ResourceBundle getBundle(java.lang.Class clazz) throws java.util.MissingResourceException
clazz
- the class to take the package name from
java.util.MissingResourceException
- if the bundle does not existpublic static final java.util.ResourceBundle getBundle(java.lang.String baseName, java.util.Locale locale) throws java.util.MissingResourceException
baseName
- bundle basenamelocale
- the locale to use (but still uses default branding
)
java.util.MissingResourceException
- if the bundle does not existpublic static final java.util.ResourceBundle getBundle(java.lang.String baseName, java.util.Locale locale, java.lang.ClassLoader loader) throws java.util.MissingResourceException
baseName
- bundle basenamelocale
- the locale to use (but still uses default branding
)loader
- the class loader to use
java.util.MissingResourceException
- if the bundle does not existpublic static java.lang.String getMessage(java.lang.Class clazz, java.lang.String resName) throws java.util.MissingResourceException
clazz
- the class to use to locate the bundleresName
- name of the resource to look for
java.util.MissingResourceException
- if either the bundle or the string cannot be foundpublic static java.lang.String getMessage(java.lang.Class clazz, java.lang.String resName, java.lang.Object param1) throws java.util.MissingResourceException
clazz
- the class to use to locate the bundleresName
- name of the resource to look forparam1
- the argument to use when formatting the message
java.util.MissingResourceException
- if either the bundle or the string cannot be foundMessageFormat.format(String,Object[])
public static java.lang.String getMessage(java.lang.Class clazz, java.lang.String resName, java.lang.Object param1, java.lang.Object param2) throws java.util.MissingResourceException
clazz
- the class to use to locate the bundleresName
- name of the resource to look forparam1
- the argument to use when formatting the messageparam2
- the second argument to use for formatting
java.util.MissingResourceException
- if either the bundle or the string cannot be foundMessageFormat.format(String,Object[])
public static java.lang.String getMessage(java.lang.Class clazz, java.lang.String resName, java.lang.Object param1, java.lang.Object param2, java.lang.Object param3) throws java.util.MissingResourceException
clazz
- the class to use to locate the bundleresName
- name of the resource to look forparam1
- the argument to use when formatting the messageparam2
- the second argument to use for formattingparam3
- the third argument to use for formatting
java.util.MissingResourceException
- if either the bundle or the string cannot be foundMessageFormat.format(String,Object[])
public static java.lang.String getMessage(java.lang.Class clazz, java.lang.String resName, java.lang.Object[] arr) throws java.util.MissingResourceException
clazz
- the class to use to locate the bundleresName
- name of the resource to look forarr
- array of parameters to use for formatting the message
java.util.MissingResourceException
- if either the bundle or the string cannot be foundMessageFormat.format(String,Object[])
public static java.util.Iterator<java.lang.String> getLocalizingSuffixes()
NbBundle
methods use as the search order.
For example, when getBranding()
returns branding
and the default locale is German, you might get a sequence such as:
String
@Deprecated public static void setClassLoaderFinder(NbBundle.ClassLoaderFinder loaderFinder)
loaderFinder
- ignored
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |