Class Bundle
- Direct Known Subclasses:
Bundle,Bundle,Bundle,Bundle,Bundle,Bundle,Bundle,Bundle,Bundle,Bundle,Bundle,Bundle,Bundle,Bundle,Bundle,Bundle,Bundle,Bundle
Convention is to provide a subclass of this same name in each package, working off the local resource bundle name, usually 'package.Bundle' stored in a Bundle.properties file.
This is the root of a tree of classes that are chained through class-static members so that they each do a search as a request works up the inheritance tree.
Only package-scope methods exposed are from the class, forcing all requests for strings to be a the package level.
To add this to a new package, copy exactly a subclass file such as jmri.jmrit.Bundle, and change three places:
- The import statement at the top
- The extends clause in the class definition statement
- The resource pathname assigned to the name variable, which must be set to null if there are no local resources.
This file is part of JMRI.
JMRI is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. See the "COPYING" file for a copy of this license.
JMRI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- Since:
- 3.3.1
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Stringstatic StringformatMessage(String message, Object... subs) Formats a message string with parameters.protected static Bundle(package private) static StringgetMessage(String key) Provides a translated string for a given key from the package resource bundle or parent.(package private) static StringgetMessage(String key, Object... subs) Merges user data with a translated string for a given key from the package resource bundle or parent.(package private) static StringgetMessage(Locale locale, String key) Provides a translated string for a given key in a given locale from the package resource bundle or parent.(package private) static StringgetMessage(Locale locale, String key, Object... subs) Merges user data with a translated string for a given key in a given locale from the package resource bundle or parent.handleGetMessage(String key) This method handles the inheritance tree.handleGetMessage(String key, Object[] subs) Merges user data with a translated string for a given key from the package resource bundle or parent.handleGetMessage(Locale locale, String key) This method handles the inheritance tree.handleGetMessage(Locale locale, String key, Object[] subs) Merges user data with a translated string for a given key in a given locale from the package resource bundle or parent.protected String
-
Constructor Details
-
Bundle
public Bundle()
-
-
Method Details
-
getMessage
Provides a translated string for a given key from the package resource bundle or parent.Note that this is intentionally package-local access.
- Parameters:
key- Bundle key to be translated- Returns:
- Internationalized text
-
getMessage
Provides a translated string for a given key in a given locale from the package resource bundle or parent.Note that this is intentionally package-local access.
- Parameters:
locale- The locale to be usedkey- Bundle key to be translated- Returns:
- Internationalized text
-
getMessage
Merges user data with a translated string for a given key from the package resource bundle or parent.Uses the transformation conventions of the Java MessageFormat utility.
Note that this is intentionally package-local access.
- Parameters:
key- Bundle key to be translatedsubs- One or more objects to be inserted into the message- Returns:
- Internationalized text
- See Also:
-
getMessage
Merges user data with a translated string for a given key in a given locale from the package resource bundle or parent.Uses the transformation conventions of the Java MessageFormat utility.
Note that this is intentionally package-local access.
- Parameters:
locale- The locale to be usedkey- Bundle key to be translatedsubs- One or more objects to be inserted into the message- Returns:
- Internationalized text
- See Also:
-
handleGetMessage
This method handles the inheritance tree. At lower levels, it reflects upwards on failure. Once it reaches this root class, it will throw a MissingResourceException in the key can't be found via the local definition of retry().- Parameters:
key- Bundle key to be translated- Returns:
- Internationalized text
- Throws:
MissingResourceException- if message cannot be found
-
handleGetMessage
This method handles the inheritance tree. At lower levels, it reflects upwards on failure. Once it reaches this root class, it will throw a MissingResourceException in the key can't be found via the local definition of retry().- Parameters:
locale- The locale to be usedkey- Bundle key to be translated- Returns:
- Internationalized text
- Throws:
MissingResourceException- if message cannot be found
-
handleGetMessage
Merges user data with a translated string for a given key from the package resource bundle or parent.Uses the transformation conventions of the Java MessageFormat utility.
- Parameters:
key- Bundle key to be translatedsubs- Array of objects to be inserted into the message- Returns:
- Internationalized text
- See Also:
-
handleGetMessage
Merges user data with a translated string for a given key in a given locale from the package resource bundle or parent.Uses the transformation conventions of the Java MessageFormat utility.
- Parameters:
locale- The locale to be usedkey- Bundle key to be translatedsubs- Array of objects to be inserted into the message- Returns:
- Internationalized text
- See Also:
-
formatMessage
Formats a message string with parameters.It's used when a message is fetched from a foreign bundle.
- Parameters:
message- The message to be formattedsubs- Array of objects to be inserted into the message- Returns:
- The formatted message
-
retry
- Throws:
MissingResourceException
-
bundleName
-
getBundle
-