org.apache.commons.math3.exception.util
public class ExceptionContext extends Object implements Serializable
ExceptionContext
interface.
All Commons Math exceptions delegate the interface's methods to this class.Modifier and Type | Field and Description |
---|---|
private Map<String,Object> |
context
Arbitrary context information.
|
private List<Object[]> |
msgArguments
Various informations that enrich the informative message.
|
private List<Localizable> |
msgPatterns
Various informations that enrich the informative message.
|
private static long |
serialVersionUID
Serializable version Id.
|
private Throwable |
throwable
The throwable to which this context refers to.
|
Constructor and Description |
---|
ExceptionContext(Throwable throwable)
Simple constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addMessage(Localizable pattern,
Object... arguments)
Adds a message.
|
private String |
buildMessage(Locale locale,
String separator)
Builds a message string.
|
private void |
deSerializeContext(ObjectInputStream in)
Deserialize
context . |
private void |
deSerializeMessages(ObjectInputStream in)
Deserialize
msgPatterns and msgArguments . |
Set<String> |
getKeys()
Gets all the keys stored in the exception
|
String |
getLocalizedMessage()
Gets the message in the default locale.
|
String |
getMessage()
Gets the default message.
|
String |
getMessage(Locale locale)
Gets the message in a specified locale.
|
String |
getMessage(Locale locale,
String separator)
Gets the message in a specified locale.
|
Throwable |
getThrowable()
Get a reference to the exception to which the context relates.
|
Object |
getValue(String key)
Gets the value associated to the given context key.
|
private String |
nonSerializableReplacement(Object obj)
Replaces a non-serializable object with an error message string.
|
private void |
readObject(ObjectInputStream in)
Deserialize this object from the given stream.
|
private void |
serializeContext(ObjectOutputStream out)
Serialize
context . |
private void |
serializeMessages(ObjectOutputStream out)
Serialize
msgPatterns and msgArguments . |
void |
setValue(String key,
Object value)
Sets the context (key, value) pair.
|
private void |
writeObject(ObjectOutputStream out)
Serialize this object to the given stream.
|
private static final long serialVersionUID
private Throwable throwable
private List<Localizable> msgPatterns
private List<Object[]> msgArguments
msgPatterns
.public ExceptionContext(Throwable throwable)
throwable
- the exception this context refers toopublic Throwable getThrowable()
public void addMessage(Localizable pattern, Object... arguments)
pattern
- Message pattern.arguments
- Values for replacing the placeholders in the message
pattern.public void setValue(String key, Object value)
key
- Context key (not null).value
- Context value.public Object getValue(String key)
key
- Context key.null
if the key does not exist.public Set<String> getKeys()
public String getMessage()
public String getLocalizedMessage()
public String getMessage(Locale locale)
locale
- Locale in which the message should be translated.public String getMessage(Locale locale, String separator)
locale
- Locale in which the message should be translated.separator
- Separator inserted between the message parts.private String buildMessage(Locale locale, String separator)
locale
- Locale in which the message should be translated.separator
- Message separator.private void writeObject(ObjectOutputStream out) throws IOException
out
- Stream.IOException
- This should never happen.private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
in
- Stream.IOException
- This should never happen.ClassNotFoundException
- This should never happen.private void serializeMessages(ObjectOutputStream out) throws IOException
msgPatterns
and msgArguments
.out
- Stream.IOException
- This should never happen.private void deSerializeMessages(ObjectInputStream in) throws IOException, ClassNotFoundException
msgPatterns
and msgArguments
.in
- Stream.IOException
- This should never happen.ClassNotFoundException
- This should never happen.private void serializeContext(ObjectOutputStream out) throws IOException
context
.out
- Stream.IOException
- This should never happen.private void deSerializeContext(ObjectInputStream in) throws IOException, ClassNotFoundException
context
.in
- Stream.IOException
- This should never happen.ClassNotFoundException
- This should never happen.Copyright (c) 2003-2013 Apache Software Foundation