Class BundleUtil


  • public class BundleUtil
    extends Object
    • Field Detail

      • pluginId

        protected final String pluginId
    • Constructor Detail

      • BundleUtil

        public BundleUtil​(String pluginId,
                          String bundleName,
                          ResourceBundle bundle)
        Construct an instance of this class by specifying the plugin ID.
        Parameters:
        pluginId - the identifier of the plugin for which this utility is being instantiated
        bundleName - the name of the resource bundle; used for problem reporting purposes only
        bundle - the resource bundle
    • Method Detail

      • getBundleUtil

        public static BundleUtil getBundleUtil​(Class<?> clazz)
        Return the BundleUtil for the class. The bundle must be in the same package or a parent package of the class.
        Parameters:
        clazz -
      • getString

        public String getString​(String key)
        Get the string identified by the given key and localized to the current locale.
        Parameters:
        key - the key in the resource file
        Returns:
        the localized String, or "Missing message: " + key + " in: " + this.bundleName if the string could not be found in the current locale, or "No message available" if the key is null.
      • keyExists

        public boolean keyExists​(String key)
        Determines if the given key exists in the resource file.
        Parameters:
        key - the key in the resource file
        Returns:
        True if the key exists.
        Since:
        4.0
      • getString

        public String getString​(String key,
                                List parameters)
        Get the string identified by the given key and localized to the current locale, and replace placeholders in the localized string with the string form of the parameters.
        Parameters:
        key - the key in the resource file
        parameters - the list of parameters that should replace placeholders in the localized string (e.g., "{0}", "{1}", etc.)
        Returns:
        the localized String, or "Missing message: " + key + " in: " + this.bundleName if the string could not be found in the current locale, or "No message available" if the key is null.
      • getString

        public String getString​(String key,
                                Object... parameters)
        Get the string identified by the given key and localized to the current locale, and replace placeholders in the localized string with the string form of the parameters.
        Parameters:
        key - the key in the resource file
        parameters - the list of parameters that should replace placeholders in the localized string (e.g., "{0}", "{1}", etc.)
        Returns:
        the localized String, or "Missing message: " + key + " in: " + this.bundleName if the string could not be found in the current locale, or "No message available" if the key is null.
      • getStringOrKey

        public String getStringOrKey​(String key)