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 |
- Alphabetic
- By Inheritance
- TableFormatter
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Instance Constructors
- 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
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- def +=(columns: Seq[String]): TableFormatter
Add a row to this table.
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def addRow(columns: String*): TableFormatter
Add a row to this table.
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @HotSpotIntrinsicCandidate() @native()
- val contents: Buffer[Seq[String]]
- Attributes
- protected
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @HotSpotIntrinsicCandidate() @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @HotSpotIntrinsicCandidate() @native()
- val headers: Option[Seq[String]]
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @HotSpotIntrinsicCandidate() @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @HotSpotIntrinsicCandidate() @native()
- val prefix: String
- def print(out: PrintStream): Unit
Prints this table to the specified stream.
Prints this table to the specified stream.
- out
stream to print to.
- def print(): Unit
Prints this table to stdout.
- def rows: Seq[Seq[String]]
Current contents of this table.
Current contents of this table.
- Annotations
- @SuppressWarnings()
- val separator: String
- val stripTrailingNewline: Boolean
- val suffix: String
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- 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
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- 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.
- 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.
- def withStripTrailingNewline: TableFormatter
Creates a new
TableFormatter
, copying the settings from this and withstripTrailingNewline
enabled.Creates a new
TableFormatter
, copying the settings from this and withstripTrailingNewline
enabled.The rows in this table will not be copied to the new table.
- returns
An empty table with the updated settings.
- 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.