Class WTListResourceBundle

Direct Known Subclasses:
relationResource, relationResource_ja, WfCustomEventTypeResource, WfCustomEventTypeResource_ja, workItemAttributeResource, workItemAttributeResource_ja

public abstract class WTListResourceBundle extends ListResourceBundle
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 RBUUID is present
  • load-time: if class represents the default locale, that it ends with Resource, RB, or Messages (unless annotated vith RBNameException)
  • load-time: the class contains no declared methods
  • load-time: every field is a "public static final String" with an RBEntry annotation
  • load-time: each entry's value is unique (these become the keys in the getContents()'s Object[][].

For text tailoring documentation, see <WT_HOME>/src/wt/util/resource/resourceCustomize.rbInfo.

Supported API: true
Extendable: true

See Also:
  • Constructor Details

    • WTListResourceBundle

      public WTListResourceBundle()
      Default constructor, which must be called by extending classes. Constructs the getContents() result by reading RBEntry annotations off declared fields.

      Note: see WTListResourceBundle for validations provided by this constructor. In particular, you will get a RuntimeException if you do not meet the validations' criteria.

      Supported API: true

  • Method Details

    • getContents

      public Object[][] getContents()
      Returns all the RBEntry-annotated properties. For example, the WTListResourceBundle's demoBundle would 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:
      getContents in class ListResourceBundle
    • getCategory

      public byte getCategory(String key)
      Returns the MessageCategory's byte value (see MessageCategory.getByte()) if the entry with the given key has provided it via an RBCategory annotation.

      Note: this API will throw a MissingResourceException if "key.category" is not found! This seems incorrect, but is in keeping with the behavior previously supplied by CategorizedListResourceBundle.

      Supported API: true

      See Also: