Class ExceptionContext
java.lang.Object
org.apache.commons.math3.exception.util.ExceptionContext
- All Implemented Interfaces:
Serializable
Class that contains the actual implementation of the functionality mandated
by the
ExceptionContext
interface.
All Commons Math exceptions delegate the interface's methods to this class.- Since:
- 3.0
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addMessage
(Localizable pattern, Object... arguments) Adds a message.getKeys()
Gets all the keys stored in the exceptionGets the message in the default locale.Gets the default message.getMessage
(Locale locale) Gets the message in a specified locale.getMessage
(Locale locale, String separator) Gets the message in a specified locale.Get a reference to the exception to which the context relates.Gets the value associated to the given context key.void
Sets the context (key, value) pair.
-
Constructor Details
-
ExceptionContext
Simple constructor.- Parameters:
throwable
- the exception this context refers too
-
-
Method Details
-
getThrowable
Get a reference to the exception to which the context relates.- Returns:
- a reference to the exception to which the context relates
-
addMessage
Adds a message.- Parameters:
pattern
- Message pattern.arguments
- Values for replacing the placeholders in the message pattern.
-
setValue
Sets the context (key, value) pair. Keys are assumed to be unique within an instance. If the same key is assigned a new value, the previous one will be lost.- Parameters:
key
- Context key (not null).value
- Context value.
-
getValue
Gets the value associated to the given context key.- Parameters:
key
- Context key.- Returns:
- the context value or
null
if the key does not exist.
-
getKeys
Gets all the keys stored in the exception- Returns:
- the set of keys.
-
getMessage
Gets the default message.- Returns:
- the message.
-
getLocalizedMessage
Gets the message in the default locale.- Returns:
- the localized message.
-
getMessage
Gets the message in a specified locale.- Parameters:
locale
- Locale in which the message should be translated.- Returns:
- the localized message.
-
getMessage
Gets the message in a specified locale.- Parameters:
locale
- Locale in which the message should be translated.separator
- Separator inserted between the message parts.- Returns:
- the localized message.
-