java.lang.Object
org.refcodes.tabular.TabularUtility
public final class TabularUtility extends Object
Utility for listing specific functionality.
-
Method Summary
Modifier and Type Method Description static <T> Header<T>
toHeader(String[] aColumnKeys, ColumnFactory<T> aColumnFactory)
Creates a header for a given string array with the column names to be used for the header.static <T> Header<T>
toHeader(Collection<String> aColumnKeys, ColumnFactory<T> aColumnFactory)
Creates a header for a given list of strings containing the column names to be used for the header.static String
toSeparatedValues(Record<?> aRecord)
Returns a separated values representation of the implementing collection by separating each item with the default separatorDelimiter.CSV
.static String
toSeparatedValues(Record<?> aRecord, char aDelimiter)
Returns a separated values representation of the implementing collection by separating each item with the given separator.static String
toString(Record<?> aRecord)
Creates the string representation from from the given record.static String
toString(Record<?> aRecord, char aSeparator, DateTimeFormatter[] aDateFormats)
Creates the string representation from from the given record.
-
Method Details
-
toHeader
Creates a header for a given string array with the column names to be used for the header. The data type of the header columns will beObject
.- Type Parameters:
T
- the generic type- Parameters:
aColumnKeys
- The column names to be use for the header.aColumnFactory
- creates column instances depending on the key passed. This is useful when special header keys are to have a dedicated type such asDate
. If null is passed then justObjectColumn
instances for type Object.class are created.- Returns:
- A header constructed from the given column names.
-
toHeader
public static <T> Header<T> toHeader(Collection<String> aColumnKeys, ColumnFactory<T> aColumnFactory)Creates a header for a given list of strings containing the column names to be used for the header. The data type of the header columns will beObject
.- Type Parameters:
T
- the generic type- Parameters:
aColumnKeys
- The column names to be use for the header.aColumnFactory
- creates column instances depending on the key passed. This is useful when special header keys are to have a dedicated type such asDate
. If null is passed then justObjectColumn
instances for typeObject
are created.- Returns:
- A header constructed from the given column names.
-
toString
Creates the string representation from from the given record. The key / value pairs of each item in the record are separated from each other with the assignment operator "=" and the items are separated from each other by the default CSV separator character and date objects are formatted with the default date format.- Parameters:
aRecord
- The record for which to create a string.- Returns:
- A string representation of the given record.
-
toString
public static String toString(Record<?> aRecord, char aSeparator, DateTimeFormatter[] aDateFormats)Creates the string representation from from the given record. The key / value pairs of each item in the record are separated from each other with the assignment operator "=" and the items are separated from each other by the given separator character.- Parameters:
aRecord
- The record for which to create a string.aSeparator
- The separator to separate the items (key/value-pairs) of the record from each other.aDateFormats
- The date formats to use when formatting date objects.- Returns:
- A string representation of the given record.
-
toSeparatedValues
Returns a separated values representation of the implementing collection by separating each item with the default separatorDelimiter.CSV
. The common CSV conventions are to be obeyed (although there is none CSV standard). In case a value's string representation contains the delimiter char, then this char must be escaped (i.e. by using the backslash '\').- Parameters:
aRecord
- The record from which to generate separated values.- Returns:
- The aDelimiter separated string.
-
toSeparatedValues
Returns a separated values representation of the implementing collection by separating each item with the given separator. The common CSV conventions are to be obeyed (although there is none CSV standard). In case a value's string representation contains the delimiter char, then this char must be escaped (i.e. by using the backslash '\').- Parameters:
aRecord
- The record from which to generate separated values.aDelimiter
- The delimiter to use when separating the values.- Returns:
- The aDelimiter separated string.
-