| java.lang.Object org.openide.util.NbBundle
NbBundle | public class NbBundle extends Object (Code) | | 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(ClassString) NbBundle.getMessage (Foo.class, "Foo_theMessage");
// Might also look in /com/mycom/Bundle_de.properties, etc.
}
|
Inner Class :public static interface ClassLoaderFinder | |
Inner Class :final static class DebugLoader extends ClassLoader | |
Constructor Summary | |
public | NbBundle() Do not call. |
Method Summary | |
public static String | getBranding() Get the current branding token. | final public static ResourceBundle | getBundle(String baseName) Get a resource bundle with the default class loader and locale/branding.
Caution:
NbBundle.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. | public static ResourceBundle | getBundle(Class clazz) Get a resource bundle in the same package as the provided class,
with the default locale/branding and the class' own classloader. | final public static ResourceBundle | getBundle(String baseName, Locale locale) Get a resource bundle with the default class loader and branding. | final public static ResourceBundle | getBundle(String baseName, Locale locale, ClassLoader loader) Get a resource bundle the hard way. | public static synchronized URL | getLocalizedFile(String baseName, String ext) Get a localized and/or branded file in the default locale with the default class loader.
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.
Parameters: baseName - base name of file, as dot-separated path (e.g. | public static synchronized URL | getLocalizedFile(String baseName, String ext, Locale locale) Get a localized and/or branded file with the default class loader.
Parameters: baseName - base name of file, as dot-separated path (e.g. | public static synchronized URL | getLocalizedFile(String baseName, String ext, Locale locale, ClassLoader loader) Get a localized and/or branded file.
Parameters: baseName - base name of file, as dot-separated path (e.g. | public static T | getLocalizedValue(Map<String, T> table, String key, Locale locale) Find a localized and/or branded value for a given key and locale.
Scans through a map to find
the most localized match possible. | public static T | getLocalizedValue(Map<String, T> table, String key) Find a localized and/or branded value for a given key in the default system locale. | public static String | getLocalizedValue(Attributes attr, Attributes.Name key, Locale locale) Find a localized and/or branded value in a JAR manifest. | public static String | getLocalizedValue(Attributes attr, Attributes.Name key) Find a localized and/or branded value in a JAR manifest in the default system locale. | public static Iterator<String> | getLocalizingSuffixes() Get a list of all suffixes used to search for localized/branded resources. | public static String | getMessage(Class clazz, String resName) Finds a localized and/or branded string in a bundle. | public static String | getMessage(Class clazz, String resName, Object param1) Finds a localized and/or branded string in a bundle and formats the message
by passing requested parameters. | public static String | getMessage(Class clazz, String resName, Object param1, Object param2) Finds a localized and/or branded string in a bundle and formats the message
by passing requested parameters. | public static String | getMessage(Class clazz, String resName, Object param1, Object param2, Object param3) Finds a localized and/or branded string in a bundle and formats the message
by passing requested parameters. | public static String | getMessage(Class clazz, String resName, Object[] arr) Finds a localized and/or branded string in a bundle and formats the message
by passing requested parameters. | public static void | setBranding(String bt) Set the current branding token. | public static void | setClassLoaderFinder(ClassLoaderFinder loaderFinder) Do not use. |
localizedFileCache | final static Map<ClassLoader, Map<String, URL>> localizedFileCache(Code) | | Cache of URLs for localized files.
Keeps only weak references to the class loaders.
See Also: "#9275" |
NbBundle | public NbBundle()(Code) | | Do not call.
|
getBranding | public static String getBranding()(Code) | | Get the current branding token.
the branding, or null for none |
getBundle | final public static ResourceBundle getBundle(String baseName) throws MissingResourceException(Code) | | Get a resource bundle with the default class loader and locale/branding.
Caution:
NbBundle.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.
Parameters: baseName - bundle basename the resource bundle exception: MissingResourceException - if the bundle does not exist |
getBundle | public static ResourceBundle getBundle(Class clazz) throws MissingResourceException(Code) | | Get a resource bundle in the same package as the provided class,
with the default locale/branding and the class' own classloader.
This is the usual style of invocation.
Parameters: clazz - the class to take the package name from the resource bundle exception: MissingResourceException - if the bundle does not exist |
getLocalizedFile | public static synchronized URL getLocalizedFile(String baseName, String ext) throws MissingResourceException(Code) | | Get a localized and/or branded file in the default locale with the default class loader.
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.
Parameters: baseName - base name of file, as dot-separated path (e.g. some.dir.File ) Parameters: ext - extension of file (or null ) URL of matching localized file throws: MissingResourceException - if not found |
getLocalizedFile | public static synchronized URL getLocalizedFile(String baseName, String ext, Locale locale) throws MissingResourceException(Code) | | Get a localized and/or branded file with the default class loader.
Parameters: baseName - base name of file, as dot-separated path (e.g. some.dir.File ) Parameters: ext - extension of file (or null ) Parameters: locale - locale of file URL of matching localized file throws: MissingResourceException - if not found |
getLocalizedFile | public static synchronized URL getLocalizedFile(String baseName, String ext, Locale locale, ClassLoader loader) throws MissingResourceException(Code) | | Get a localized and/or branded file.
Parameters: baseName - base name of file, as dot-separated path (e.g. some.dir.File ) Parameters: ext - extension of file (or null ) Parameters: locale - locale of file Parameters: loader - class loader to use URL of matching localized file throws: MissingResourceException - if not found |
getLocalizedValue | public static T getLocalizedValue(Map<String, T> table, String key, Locale locale)(Code) | | Find a localized and/or branded value for a given key and locale.
Scans through a map to find
the most localized match possible. For example:
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")
Parameters: table - mapping from localized strings to objects Parameters: key - the key to look for Parameters: locale - the locale to use the localized object or null if no key matches |
getLocalizedValue | public static T getLocalizedValue(Map<String, T> table, String key)(Code) | | Find a localized and/or branded value for a given key in the default system locale.
Parameters: table - mapping from localized strings to objects Parameters: key - the key to look for the localized object or null if no key matches See Also: NbBundle.getLocalizedValue(Map,String,Locale) |
getLocalizedValue | public static String getLocalizedValue(Attributes attr, Attributes.Name key, Locale locale)(Code) | | Find a localized and/or branded value in a JAR manifest.
Parameters: attr - the manifest attributes Parameters: key - the key to look for (case-insensitive) Parameters: locale - the locale to use the value if found, else null |
getLocalizedValue | public static String getLocalizedValue(Attributes attr, Attributes.Name key)(Code) | | Find a localized and/or branded value in a JAR manifest in the default system locale.
Parameters: attr - the manifest attributes Parameters: key - the key to look for (case-insensitive) the value if found, else null |
getLocalizingSuffixes | public static Iterator<String> getLocalizingSuffixes()(Code) | | Get a list of all suffixes used to search for localized/branded resources.
Based on the default locale and branding, returns the list of suffixes
which various NbBundle methods use as the search order.
For example, when
NbBundle.getBranding returns branding
and the default locale is German, you might get a sequence such as:
- "_branding_de"
- "_branding"
- "_de"
- ""
a read-only iterator of type String since: 1.1.5 |
getMessage | public static String getMessage(Class clazz, String resName) throws MissingResourceException(Code) | | Finds a localized and/or branded string in a bundle.
Parameters: clazz - the class to use to locate the bundle Parameters: resName - name of the resource to look for the string associated with the resource throws: MissingResourceException - if either the bundle or the string cannot be found |
getMessage | public static String getMessage(Class clazz, String resName, Object param1, Object param2) throws MissingResourceException(Code) | | Finds a localized and/or branded string in a bundle and formats the message
by passing requested parameters.
Parameters: clazz - the class to use to locate the bundle Parameters: resName - name of the resource to look for Parameters: param1 - the argument to use when formatting the message Parameters: param2 - the second argument to use for formatting the string associated with the resource throws: MissingResourceException - if either the bundle or the string cannot be found See Also: java.text.MessageFormat.format(StringObject[]) |
getMessage | public static String getMessage(Class clazz, String resName, Object param1, Object param2, Object param3) throws MissingResourceException(Code) | | Finds a localized and/or branded string in a bundle and formats the message
by passing requested parameters.
Parameters: clazz - the class to use to locate the bundle Parameters: resName - name of the resource to look for Parameters: param1 - the argument to use when formatting the message Parameters: param2 - the second argument to use for formatting Parameters: param3 - the third argument to use for formatting the string associated with the resource throws: MissingResourceException - if either the bundle or the string cannot be found See Also: java.text.MessageFormat.format(StringObject[]) |
setBranding | public static void setBranding(String bt) throws IllegalArgumentException(Code) | | Set the current branding token.
The permitted format, as a regular expression:
[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.
Parameters: bt - the new branding, or null to clear throws: IllegalArgumentException - if in an incorrect format |
setClassLoaderFinder | public static void setClassLoaderFinder(ClassLoaderFinder loaderFinder)(Code) | | Do not use.
Parameters: loaderFinder - ignored |
|
|