public final class TabularUtility extends Object
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 separator
Delimiter.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.
|
public static <T> Header<T> toHeader(String[] aColumnKeys, ColumnFactory<T> aColumnFactory)
Object
.T
- the generic typeaColumnKeys
- 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 as Date
. If null is passed
then just ObjectColumn
instances for type Object.class are
created.public static <T> Header<T> toHeader(Collection<String> aColumnKeys, ColumnFactory<T> aColumnFactory)
Object
.T
- the generic typeaColumnKeys
- 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 as Date
. If null is passed
then just ObjectColumn
instances for type Object
are created.public static String toString(Record<?> aRecord)
aRecord
- The record for which to create a string.public static String toString(Record<?> aRecord, char aSeparator, DateTimeFormatter[] aDateFormats)
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.public static String toSeparatedValues(Record<?> aRecord)
Delimiter.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 '\').aRecord
- The record from which to generate separated values.public static String toSeparatedValues(Record<?> aRecord, char aDelimiter)
aRecord
- The record from which to generate separated values.aDelimiter
- The delimiter to use when separating the values.Copyright © 2021. All rights reserved.