com.virtuosotechnologies.lib.error
Class UserMessageExceptionFormatter

java.lang.Object
  extended bycom.virtuosotechnologies.lib.error.UserMessageExceptionFormatter
All Implemented Interfaces:
ExceptionFormatter

public class UserMessageExceptionFormatter
extends Object
implements ExceptionFormatter

Exception formatter that generates user-interpretable messages.

This class is fully synchronized and thread-safe.


Method Summary
static UserMessageExceptionFormatter createEmpty()
          Construct a formatter with no generators installed, and without a source of default generators.
static UserMessageExceptionFormatter createWithDefaults()
          Construct a formatter using the default global formatter as the parent.
static UserMessageExceptionFormatter createWithDefaults(UserMessageExceptionFormatter parent)
          Construct a formatter with the given source of default generators
 String format(Throwable ex, PropertySet properties)
          Generate a String representation of the given exception.
static UserMessageExceptionFormatter getGlobalFormatter()
          Get the global default formatter.
static void installGlobalDefaultUserMessageGenerator(UserMessageGenerator generator)
          Install a global default UserMessageGenerator
 void installUserMessageGenerator(UserMessageGenerator generator)
          Install a UserMessageGenerator
 boolean removeUserMessageGenerator(UserMessageGenerator generator)
          Remove a UserMessageGenerator
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getGlobalFormatter

public static UserMessageExceptionFormatter getGlobalFormatter()
Get the global default formatter. Serves as a repository for common UserMessageGenerators.

Returns:
the global formatter

installGlobalDefaultUserMessageGenerator

public static void installGlobalDefaultUserMessageGenerator(UserMessageGenerator generator)
Install a global default UserMessageGenerator

Parameters:
generator - UserMessageGenerator to add

createEmpty

public static UserMessageExceptionFormatter createEmpty()
Construct a formatter with no generators installed, and without a source of default generators.


createWithDefaults

public static UserMessageExceptionFormatter createWithDefaults()
Construct a formatter using the default global formatter as the parent.


createWithDefaults

public static UserMessageExceptionFormatter createWithDefaults(UserMessageExceptionFormatter parent)
Construct a formatter with the given source of default generators

Parameters:
parent - parent UserMessageExceptionFormatter, acting as a source for default generators

installUserMessageGenerator

public void installUserMessageGenerator(UserMessageGenerator generator)
Install a UserMessageGenerator

Parameters:
generator - UserMessageGenerator to add

removeUserMessageGenerator

public boolean removeUserMessageGenerator(UserMessageGenerator generator)
Remove a UserMessageGenerator

Parameters:
generator - UserMessageGenerator to remove
Returns:
true if generator removed

format

public String format(Throwable ex,
                     PropertySet properties)
Generate a String representation of the given exception.

Specified by:
format in interface ExceptionFormatter
Parameters:
ex - throwable
properties - formatter-specific properties.
Returns:
a formatted String.