logahawk.formatters
Class ThrowableArgFormatter

java.lang.Object
  extended by logahawk.formatters.AbstractArgumentFormatter
      extended by logahawk.formatters.ThrowableArgFormatter
All Implemented Interfaces:
ArgumentFormatter

@Immutable
public class ThrowableArgFormatter
extends AbstractArgumentFormatter

This formatter can handle "Throwable" objects -- namely Exceptions.


Nested Class Summary
static class ThrowableArgFormatter.ThrowablePlusMessage
          This is a specialized class that contains an Throwable and a user String message.
 
Field Summary
protected  ConcatCollectionArgFormatter concat
          Used to merge the formatted lines into one big String with the appropriate new lines.
 
Fields inherited from class logahawk.formatters.AbstractArgumentFormatter
indentor
 
Constructor Summary
ThrowableArgFormatter()
           
 
Method Summary
 boolean canFormat(Object obj)
          This should return true only if this can provide a useful formatting for this type of object.
 String format(Object obj, Collection<ArgumentFormatter> formatters, int indentLevel)
          This converts the object into a String that represent the object.
protected  List<String> formatStackTrace(StackTraceElement[] stack)
          This method will format the StackTrace according to our indention rules.
 
Methods inherited from class logahawk.formatters.AbstractArgumentFormatter
findFormatter, getChildObjectFormat, getIndentor, setIndentor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

concat

protected final ConcatCollectionArgFormatter concat
Used to merge the formatted lines into one big String with the appropriate new lines.

Constructor Detail

ThrowableArgFormatter

public ThrowableArgFormatter()
Method Detail

canFormat

public boolean canFormat(Object obj)
Description copied from interface: ArgumentFormatter
This should return true only if this can provide a useful formatting for this type of object.


format

public String format(Object obj,
                     Collection<ArgumentFormatter> formatters,
                     int indentLevel)
Description copied from interface: ArgumentFormatter
This converts the object into a String that represent the object. The String may contain line breaks, but should not include a trailing line break. The first line of the result should NOT include any indentation, that should be handled by the calling class. If the object is complex and contains other objects, this ArgumentFormatter may use the provided list of ArgumentFormatter objects to find a more appropriate formatter. To make things look nice, the "indentLevel" is provided. The indent level should always be incremented by one when calling downward into other ArgumentFormatters.


formatStackTrace

protected List<String> formatStackTrace(StackTraceElement[] stack)
This method will format the StackTrace according to our indention rules. This will add the indent to all lines once, including the first line, so that the final indenting does't double-count.