Package wt.util.resource
Class WTListResourceBundle
java.lang.Object
java.util.ResourceBundle
java.util.ListResourceBundle
wt.util.resource.WTListResourceBundle
- Direct Known Subclasses:
relationResource,relationResource_ja,WfCustomEventTypeResource,WfCustomEventTypeResource_ja,workItemAttributeResource,workItemAttributeResource_ja
An extension of
ListResourceBundle which builds getContents() from
RBEntry-annotated "public static final String" properties. This class serves
as an alternative to the usage of rbInfo files for StringResourceInfo
resource bundles, and should be preferred over the rbInfo format because it uses
true Java files which are both understood by IDEs and which offer greater validation, better
completion, and improved error checking than was possible using the rbInfo bundle
definition format.
To use, simply create a file similar to the following (complete) example:
package demo;
import wt.util.resource.*;
@RBUUID("demo.demoResource")
public class demoResource extends WTListResourceBundle {
@RBEntry("This is the localized text with a single substitution: \"{0}\".")
@RBComment("A demonstration entry.")
@RBArgComment0("Any string...")
public static final String DEMO_STRING = "0";
}
Note that the following validations occur when using this class:
- compiler: annotations are present on the proper elements
- compiler: annotation values are properly specified
- compiler: field names are unique
- load-time: if class represents the default locale, that
RBUUIDis present - load-time: if class represents the default locale, that it ends with
Resource,RB, orMessages(unless annotated vithRBNameException) - load-time: the class contains no declared methods
- load-time: every field is a "
public static final String" with anRBEntryannotation - load-time: each entry's value is unique (these become the keys in the
getContents()'sObject[][].
For text tailoring documentation, see <WT_HOME>/src/wt/util/resource/resourceCustomize.rbInfo.
Supported API: true
Extendable: true
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.ResourceBundle
ResourceBundle.Control -
Field Summary
Fields inherited from class java.util.ResourceBundle
parent -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor, which must be called by extending classes. -
Method Summary
Modifier and TypeMethodDescriptionbytegetCategory(String key) Returns theMessageCategory's byte value (seeMessageCategory.getByte()) if the entry with the given key has provided it via anRBCategoryannotation.Object[][]Returns all theRBEntry-annotated properties.Methods inherited from class java.util.ListResourceBundle
getKeys, handleGetObject, handleKeySetMethods inherited from class java.util.ResourceBundle
clearCache, clearCache, containsKey, getBaseBundleName, getBundle, getBundle, getBundle, getBundle, getBundle, getBundle, getBundle, getBundle, getLocale, getObject, getString, getStringArray, keySet, setParent
-
Constructor Details
-
WTListResourceBundle
public WTListResourceBundle()Default constructor, which must be called by extending classes. Constructs thegetContents()result by readingRBEntryannotations off declared fields.Note: see
WTListResourceBundlefor validations provided by this constructor. In particular, you will get aRuntimeExceptionif you do not meet the validations' criteria.
Supported API: true
-
-
Method Details
-
getContents
Returns all theRBEntry-annotated properties. For example, theWTListResourceBundle'sdemoBundlewould return:{ { "0", "This is the localized text with a single substitution: \"{0}"." } }
Caution: The method is called during packing and installation phase as well, thus if there are any logger.error in this method, that will cause the installation failure. So don't log any error in this method.
Supported API: true- Specified by:
getContentsin classListResourceBundle
-
getCategory
Returns theMessageCategory's byte value (seeMessageCategory.getByte()) if the entry with the given key has provided it via anRBCategoryannotation.Note: this API will throw a
MissingResourceExceptionif "key.category" is not found! This seems incorrect, but is in keeping with the behavior previously supplied byCategorizedListResourceBundle.
Supported API: true- See Also:
-