logahawk.formatters
Class MultiLineCollectionArgFormatter
java.lang.Object
logahawk.formatters.AbstractArgumentFormatter
logahawk.formatters.CollectionArgFormatter
logahawk.formatters.AbstractCollectionArgFormatter
logahawk.formatters.MultiLineCollectionArgFormatter
- All Implemented Interfaces:
- ArgumentFormatter
@Immutable
public class MultiLineCollectionArgFormatter
- extends AbstractCollectionArgFormatter
Writes each object in the Collection
s on a single line. Each line also prints an index to increase
readability. For a list containing the strings "Alpha", "Beta", and "Gamma", the output will look like:
(3 items in collection)
[0] Alpha
[1] Beta
[2] Gama
This class sets AbstractCollectionArgFormatter.formatSingleSpecial
to true, so a list with a single item will be treated as if it were just
that single item.
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
MultiLineCollectionArgFormatter
public MultiLineCollectionArgFormatter()
MultiLineCollectionArgFormatter
public MultiLineCollectionArgFormatter(int maxItems)
format
public String format(Object obj,
Collection<ArgumentFormatter> formatters,
int indentLevel)
- Formats the provided object into a list of objects, displaying the index before each item. The provided formatters
will be used to format each item, using
AbstractArgumentFormatter.getChildObjectFormat(java.lang.Object, java.util.Collection, int)
. If there is only
one item, this will simply format that one item and return it, without all the index and other formatting. (This is
allows this formatter to quietly disappear in the single item case.) If no items are in the collection, an empty
string will be returned.
formatObj
protected String formatObj(Object obj,
int index,
Collection<ArgumentFormatter> formatters,
int indentLevel)
- Description copied from class:
AbstractCollectionArgFormatter
- Formats a single object at the provided index. The default implementation simply calls
AbstractArgumentFormatter.getChildObjectFormat(Object, Collection, int)
.
- Overrides:
formatObj
in class AbstractCollectionArgFormatter
index
- The 0-based index of this item in the original collection.indentLevel
- The indent will be one larger than the caller, there is no need to increment by one.