Class JepMessages

java.lang.Object
com.singularsys.jep.JepMessages

public class JepMessages extends Object
Class to handle externalisation of error messages. Uses a bundle name of "com.singularsys.jep.messages"

Note the format for missing resources is !key! which is used in FunctionSet.put(String, PostfixMathCommandI) and FunctionTable.addFunctionIfSet(String, java.util.function.Supplier) to check if a resource is missing.

Since:
3.5
See Also:
  • Method Details

    • getString

      public static String getString(String key)
      Gets the message associated with a given string.
      Parameters:
      key - key to message
      Returns:
      the message associated with the key, or !key! if no match is found
    • format

      public static String format(String key, Object... args)
      Gets a message and uses that to format its arguments.
      Parameters:
      key - key to message which is a format string used by MessageFormat.format(String, Object...)
      args - set of arguments to be passed to the format
      Returns:
      Message format applied to arguments
    • addBundle

      public static void addBundle(ResourceBundle bundle)
      Adds a resource bundle to the list of bundles to search for messages. The bundles are searched in the order they were added, with the default bundle searched first.
      Parameters:
      bundle - the bundle to add
      Since:
      Jep 4.1
    • addBundle

      public static void addBundle(String bundleName)
      Adds a resource bundle to the list of bundles to search for messages. The bundles are searched in the order they were added, with the default bundle searched first. For example
      JepMessages.addBundle("com.singularsys.extensions.messages");
      
      Since:
      Jep 4.1
    • getStringFromAdditionalBundles

      public static String getStringFromAdditionalBundles(String key)
      Searches the standard bundle and any additional bundles for a message with the given key, returning the first match. If no match is found, returns !key!.
      Parameters:
      key - search key for message
      Returns:
      the message associated with the key, or !key! if no match is found
      Since:
      Jep 4.1
    • getAdditionalBundles

      public static List<ResourceBundle> getAdditionalBundles()
      Gets the list of additional bundles. This can be modified to change the order of the list in which bundles are searched.
      Returns:
      the list of additional bundles
      Since:
      Jep 4.1