logahawk.formatters
Class AbstractArgumentFormatter

java.lang.Object
  extended by logahawk.formatters.AbstractArgumentFormatter
All Implemented Interfaces:
ArgumentFormatter
Direct Known Subclasses:
CollectionArgFormatter, ParentObjectArgFormatter, SwingArgFormatter, ThrowableArgFormatter, XmlNodeArgFormatter

@ThreadSafe
public abstract class AbstractArgumentFormatter
extends Object
implements ArgumentFormatter

Useful base class for ArgumentFormatters.


Field Summary
protected  AtomicReference<Indentor> indentor
           
 
Constructor Summary
protected AbstractArgumentFormatter()
           
 
Method Summary
protected  ArgumentFormatter findFormatter(Object obj, Collection<ArgumentFormatter> formatters)
          Returns the first ArgumentFormatter whose canFormat() returns true for the provided object.
protected  String getChildObjectFormat(Object obj, Collection<ArgumentFormatter> formatters, int indentLevel)
          Formats the provided object using the provided ArgumentFormatters.
 Indentor getIndentor()
          The Indentor used by this class.
 void setIndentor(Indentor indentor)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface logahawk.formatters.ArgumentFormatter
canFormat, format
 

Field Detail

indentor

protected AtomicReference<Indentor> indentor
Constructor Detail

AbstractArgumentFormatter

protected AbstractArgumentFormatter()
Method Detail

getIndentor

public Indentor getIndentor()
The Indentor used by this class. The default value is SimpleIndentor.SPACE_4.


setIndentor

public void setIndentor(Indentor indentor)

findFormatter

protected ArgumentFormatter findFormatter(Object obj,
                                          Collection<ArgumentFormatter> formatters)
Returns the first ArgumentFormatter whose canFormat() returns true for the provided object. This may return null if no ArgumentFormatter can be found.


getChildObjectFormat

protected String getChildObjectFormat(Object obj,
                                      Collection<ArgumentFormatter> formatters,
                                      int indentLevel)
Formats the provided object using the provided ArgumentFormatters. This will use findFormatter() to find the ArgumentFormatter that will be used. This will return null if no ArgumentFormatter is found.

Parameters:
indentLevel - This will likely be 1 or greater since it will be used to format child objects. (The first object would have the value 0 from the Logger or ArgumentFormatterContainer.)
See Also:
Indentor