Class DefaultExceptionContext
java.lang.Object
org.apache.commons.lang3.exception.DefaultExceptionContext
- All Implemented Interfaces:
- Serializable,- ExceptionContext
Default implementation of the context storing the label-value pairs for contexted exceptions.
 
This implementation is serializable, however this is dependent on the values that are added also being serializable.
- Since:
- 3.0
- See Also:
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionaddContextValue(String label, Object value) Adds a contextual label-value pair into this context.Retrieves the full list of label-value pairs defined in the contextual data.Retrieves the full set of labels defined in the contextual data.getContextValues(String label) Retrieves all the contextual data values associated with the label.getFirstContextValue(String label) Retrieves the first available contextual data value associated with the label.getFormattedExceptionMessage(String baseMessage) Builds the message containing the contextual information.setContextValue(String label, Object value) Sets a contextual label-value pair into this context.
- 
Constructor Details- 
DefaultExceptionContextpublic DefaultExceptionContext()Constructs a new instance.
 
- 
- 
Method Details- 
addContextValueAdds a contextual label-value pair into this context.The pair will be added to the context, independently of an already existing pair with the same label. - Specified by:
- addContextValuein interface- ExceptionContext
- Parameters:
- label- the label of the item to add,- nullnot recommended
- value- the value of item to add, may be- null
- Returns:
- this, for method chaining, not- null
 
- 
getContextEntriesRetrieves the full list of label-value pairs defined in the contextual data.- Specified by:
- getContextEntriesin interface- ExceptionContext
- Returns:
- the list of pairs, not null
 
- 
getContextLabelsRetrieves the full set of labels defined in the contextual data.- Specified by:
- getContextLabelsin interface- ExceptionContext
- Returns:
- the set of labels, not null
 
- 
getContextValuesRetrieves all the contextual data values associated with the label.- Specified by:
- getContextValuesin interface- ExceptionContext
- Parameters:
- label- the label to get the contextual values for, may be- null
- Returns:
- the contextual values associated with the label, never null
 
- 
getFirstContextValueRetrieves the first available contextual data value associated with the label.- Specified by:
- getFirstContextValuein interface- ExceptionContext
- Parameters:
- label- the label to get the contextual value for, may be- null
- Returns:
- the first contextual value associated with the label, may be null
 
- 
getFormattedExceptionMessageBuilds the message containing the contextual information.- Specified by:
- getFormattedExceptionMessagein interface- ExceptionContext
- Parameters:
- baseMessage- the base exception message without context information appended
- Returns:
- the exception message with context information appended, never null
 
- 
setContextValueSets a contextual label-value pair into this context.The pair will be added normally, but any existing label-value pair with the same label is removed from the context. - Specified by:
- setContextValuein interface- ExceptionContext
- Parameters:
- label- the label of the item to add,- nullnot recommended
- value- the value of item to add, may be- null
- Returns:
- this, for method chaining, not- null
 
 
-