Packages

class TableFormatter extends AnyRef

Simple textual formatter for tabular data. This is intended to be used in text based user interfaces such as CLIs.

Example without headers

TableFormatter()
  .addRow("Apples", "25")
  .addRow("Pears", "10")
  .addRow("Bananas", "4")
  .print()

Would output:

Apples   25
Pears    10
Bananas  4

Example with headers

TableFormatter("Produce", "Remaining")
  .addRow("Apples", "25")
  .addRow("Pears", "10")
  .addRow("Bananas", "4")
  .print()

Would output:

| Produce | Remaining |
-----------------------
| Apples  | 25        |
| Pears   | 10        |
| Bananas | 4         |
Linear Supertypes
Known Subclasses
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. TableFormatter
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Instance Constructors

  1. new TableFormatter(headers: Option[Seq[String]], separator: String = " ", prefix: String = "", suffix: String = "", stripTrailingNewline: Boolean = false)

    headers

    optional column headers.

    separator

    separator to use between columns.

    prefix

    prefix to use before first column.

    suffix

    suffix to use after last column.

    stripTrailingNewline

    if true then no newline will be output after the last row.

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. def +=(columns: Seq[String]): TableFormatter

    Add a row to this table.

  4. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  5. def addRow(columns: String*): TableFormatter

    Add a row to this table.

  6. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  7. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @HotSpotIntrinsicCandidate() @native()
  8. val contents: Buffer[Seq[String]]
    Attributes
    protected
  9. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  10. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  11. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @HotSpotIntrinsicCandidate() @native()
  12. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @HotSpotIntrinsicCandidate() @native()
  13. val headers: Option[Seq[String]]
  14. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  15. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  16. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @HotSpotIntrinsicCandidate() @native()
  17. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @HotSpotIntrinsicCandidate() @native()
  18. val prefix: String
  19. def print(out: PrintStream): Unit

    Prints this table to the specified stream.

    Prints this table to the specified stream.

    out

    stream to print to.

  20. def print(): Unit

    Prints this table to stdout.

  21. def rows: Seq[Seq[String]]

    Current contents of this table.

    Current contents of this table.

    Annotations
    @SuppressWarnings()
  22. val separator: String
  23. val stripTrailingNewline: Boolean
  24. val suffix: String
  25. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  26. def toString(): String

    Formats the contents of this table and returns them as a string.

    Formats the contents of this table and returns them as a string.

    Definition Classes
    TableFormatter → AnyRef → Any
  27. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  28. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  29. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  30. def withPrefix(newPrefix: String): TableFormatter

    Creates a new TableFormatter, copying the settings from this and with the supplied prefix.

    Creates a new TableFormatter, copying the settings from this and with the supplied prefix.

    The rows in this table will not be copied to the new table.

    newPrefix

    prefix to use before first column.

    returns

    An empty table with the updated settings.

  31. def withSeparator(newSeparator: String): TableFormatter

    Creates a new TableFormatter, copying the settings from this and with the supplied separator.

    Creates a new TableFormatter, copying the settings from this and with the supplied separator.

    The rows in this table will not be copied to the new table.

    newSeparator

    separator to use between columns.

    returns

    An empty table with the updated settings.

  32. def withStripTrailingNewline: TableFormatter

    Creates a new TableFormatter, copying the settings from this and with stripTrailingNewline enabled.

    Creates a new TableFormatter, copying the settings from this and with stripTrailingNewline enabled.

    The rows in this table will not be copied to the new table.

    returns

    An empty table with the updated settings.

  33. def withSuffix(newSuffix: String): TableFormatter

    Creates a new TableFormatter, copying the settings from this and with the supplied suffix.

    Creates a new TableFormatter, copying the settings from this and with the supplied suffix.

    The rows in this table will not be copied to the new table.

    newSuffix

    suffix to use after last column.

    returns

    An empty table with the updated settings.

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable]) @Deprecated
    Deprecated

    (Since version 9)

Inherited from AnyRef

Inherited from Any

Ungrouped