Package com.singularsys.jep
Class JepMessages
java.lang.Object
com.singularsys.jep.JepMessages
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 Summary
Modifier and TypeMethodDescriptionstatic voidAdds a resource bundle to the list of bundles to search for messages.static voidaddBundle(ResourceBundle bundle) Adds a resource bundle to the list of bundles to search for messages.static StringGets a message and uses that to format its arguments.static List<ResourceBundle> Gets the list of additional bundles.static StringGets the message associated with a given string.static StringSearches the standard bundle and any additional bundles for a message with the given key, returning the first match.
-
Method Details
-
getString
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
Gets a message and uses that to format its arguments.- Parameters:
key- key to message which is a format string used byMessageFormat.format(String, Object...)args- set of arguments to be passed to the format- Returns:
- Message format applied to arguments
-
addBundle
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
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 exampleJepMessages.addBundle("com.singularsys.extensions.messages");- Since:
- Jep 4.1
-
getStringFromAdditionalBundles
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
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
-