Class TabularUtility


  • public final class TabularUtility
    extends Object
    Utility for listing specific functionality.
    • Method Detail

      • toHeader

        public 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. The data type of the header columns will be Object.
        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 as Date. If null is passed then just ObjectColumn 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 be Object.
        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 as Date. If null is passed then just ObjectColumn instances for type Object are created.
        Returns:
        A header constructed from the given column names.
      • toString

        public static String toString​(Record<?> aRecord)
        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

        public static String toSeparatedValues​(Record<?> aRecord)
        Returns a separated values representation of the implementing collection by separating each item with the default separator 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 '\').
        Parameters:
        aRecord - The record from which to generate separated values.
        Returns:
        The aDelimiter separated string.
      • toSeparatedValues

        public static String toSeparatedValues​(Record<?> aRecord,
                                               char aDelimiter)
        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.