|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object logahawk.formatters.AbstractArgumentFormatter logahawk.formatters.CollectionArgFormatter logahawk.formatters.ConcatCollectionArgFormatter
@Immutable public class ConcatCollectionArgFormatter
Concatonates all objects in the Collection
s together into a single String. This is a good formatter when you
are trying to build a sentence as opposed to a list. The flexibility of this formatter allows it to create results
with or without line breaks.
For a list containing the strings "Alpha", "Beta", and "Gamma", and no separator, the output will look like:
AlphaBetaGammaFor a list containing the strings "Alpha", "Beta", and "Gamma", and a single space separator, the output will look like:
Alpha Beta Gamma
Field Summary | |
---|---|
protected String |
prefix
Prefix to be prepended to each item in the output. |
protected String |
separator
Separator between items in the output. |
protected String |
suffix
Prefix to be appended to each item in the output. |
Fields inherited from class logahawk.formatters.AbstractArgumentFormatter |
---|
indentor |
Constructor Summary | |
---|---|
ConcatCollectionArgFormatter()
|
|
ConcatCollectionArgFormatter(String separator)
|
|
ConcatCollectionArgFormatter(String separator,
String prefix,
String suffix)
|
Method Summary | |
---|---|
StringBuilder |
createStringBuilder(List<String> values)
Creates a StringBuilder of the appropriate size to avoid re-allocation. |
String |
format(List<String> values)
Formats the provided object into a list of objects, displaying the index before each item. |
String |
format(Object obj,
Collection<ArgumentFormatter> formatters,
int indentLevel)
Formats the provided object into a list of objects, displaying the index before each item. |
Methods inherited from class logahawk.formatters.CollectionArgFormatter |
---|
canFormat |
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 |
---|
protected final String separator
protected final String prefix
protected final String suffix
Constructor Detail |
---|
public ConcatCollectionArgFormatter()
public ConcatCollectionArgFormatter(String separator)
public ConcatCollectionArgFormatter(String separator, String prefix, String suffix)
Method Detail |
---|
public String format(Object obj, Collection<ArgumentFormatter> formatters, int indentLevel)
AbstractArgumentFormatter.getChildObjectFormat(java.lang.Object, java.util.Collection, int)
.
public String format(List<String> values)
AbstractArgumentFormatter.getChildObjectFormat(java.lang.Object, java.util.Collection, int)
.
public StringBuilder createStringBuilder(List<String> values)
StringBuilder
of the appropriate size to avoid re-allocation. While this method requires a full
scan of the list, the savings are generally worth it because of the number of times re-allocation could occur and
the linear cost of re-allocation. We are trading one guaranteed O(N) operations (scanning the list) with an unknown
number of O(N) operations (re-allocations).
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |