Packages

  • package root
    Definition Classes
    root
  • package t2

    Defines types to create, access, and print tables.

    Defines types to create, access, and print tables.

    Getting Started

    Below is an example of how to use TableBuilder and TableWriter. Using these utilities, it builds a Table and writes the content to stdout.

    // Build table with first row as table header
    val table = t2.TableBuilder()
      .add("#", "Effective Date", "Currency Code", "Exchange Rate")
      .add("1", "2021-01-04", "USD", "0.690236")
      .add("2", "2021-01-05", "USD", "0.690627")
      .add("3", "2021-01-06", "USD", "0.689332")
      .build()
    
    // Create table writer with supplied configuration
    val writer = t2.TableWriter(
      "ansiColorEnabled" -> "true",
      "tableBorderColor" -> "cyan",
      "tableHeaderColor" -> "black,yellowBackground",
      "bodyRuleColor"    -> "yellow",
      "rowHeaderEnabled" -> "true",
      "rowHeaderColor"   -> "bold,cyan",
      "columnRightAlign" -> "0,3" // Right align first and last columns
    )
    
    // Write table to stdout
    writer.write(System.out, table)

    The generated output would look something like the following if printed to a color-enabled terminal.

    ===================================================
      #  Effective Date  Currency Code  Exchange Rate  
    ---------------------------------------------------
      1  2021-01-04      USD                 0.690236
      2  2021-01-05      USD                 0.690627
      3  2021-01-06      USD                 0.689332
    ===================================================
    

    The table writer can be configured for changing such things as cell padding, character used for table borders, and more.

    Definition Classes
    root
  • Table
  • TableBuilder
  • TableWriter

object TableWriter

Provides TableWriter factory.

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. TableWriter
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. def apply(config: Map[String, String]): TableWriter

    Creates table writer with supplied configuration.

    Creates table writer with supplied configuration.

    Writer Configuration

    The following keys can be supplied to configure writer.

    Key

    Default Value

    ansiColorEnabled

    "false"

    defaultColor1

    AnsiColor.RESET

    leftMarginSize

    "0"

    rightMarginSize

    "0"

    tableBorderEnabled

    "true"

    tableBorderColor1

    defaultColor

    tableBorderChar

    "="

    tableHeaderEnabled

    "true"

    tableHeaderColor1

    defaultColor

    tableFooterEnabled

    "false"

    tableFooterColor1

    defaultColor

    bodyRuleEnabled

    "true"

    bodyRuleColor1

    defaultColor

    bodyRuleChar

    "-"

    rowHeaderEnabled

    "false"

    rowHeaderColor1

    defaultColor

    columnRightAlign2

    ""

    cellColor1

    defaultColor

    cellPadSize

    "1"

    cellSpaceSize

    "0"

    cellSpaceColor1

    ""

    maxValueSize

    "20"

    nullValue

    ""

    truncateEnabled

    "true"

    1 Defined as string of AnsiColor values.

    2 Defined as comma- or space-delimited list of column indexes.

    config

    writer configuration

    Note

    ANSI colors can also be suppplied as a comma- or space-delimited list of any combination of following values:

    • reset
    • bold
    • underlined
    • blink
    • reversed
    • invisible
    • black
    • red
    • green
    • yellow
    • blue
    • magenta
    • cyan
    • white
    • blackBackground
    • redBackground
    • greenBackground
    • yellowBackground
    • blueBackground
    • magentaBackground
    • cyanBackground
    • whiteBackground
  5. def apply(config: (String, String)*): TableWriter

    Creates table writer with supplied configuration.

    Creates table writer with supplied configuration.

    Writer Configuration

    The following keys can be supplied to configure writer.

    Key

    Default Value

    ansiColorEnabled

    "false"

    defaultColor1

    AnsiColor.RESET

    leftMarginSize

    "0"

    rightMarginSize

    "0"

    tableBorderEnabled

    "true"

    tableBorderColor1

    defaultColor

    tableBorderChar

    "="

    tableHeaderEnabled

    "true"

    tableHeaderColor1

    defaultColor

    tableFooterEnabled

    "false"

    tableFooterColor1

    defaultColor

    bodyRuleEnabled

    "true"

    bodyRuleColor1

    defaultColor

    bodyRuleChar

    "-"

    rowHeaderEnabled

    "false"

    rowHeaderColor1

    defaultColor

    columnRightAlign2

    ""

    cellColor1

    defaultColor

    cellPadSize

    "1"

    cellSpaceSize

    "0"

    cellSpaceColor1

    ""

    maxValueSize

    "20"

    nullValue

    ""

    truncateEnabled

    "true"

    1 Defined as string of AnsiColor values.

    2 Defined as comma- or space-delimited list of column indexes.

    config

    writer configuration

    Note

    ANSI colors can also be suppplied as a comma- or space-delimited list of any combination of following values:

    • reset
    • bold
    • underlined
    • blink
    • reversed
    • invisible
    • black
    • red
    • green
    • yellow
    • blue
    • magenta
    • cyan
    • white
    • blackBackground
    • redBackground
    • greenBackground
    • yellowBackground
    • blueBackground
    • magentaBackground
    • cyanBackground
    • whiteBackground
  6. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  7. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  8. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  9. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  10. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  11. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  12. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  13. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  14. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  15. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  16. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  17. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  18. def toString(): String
    Definition Classes
    AnyRef → Any
  19. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  20. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  21. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()

Inherited from AnyRef

Inherited from Any

Ungrouped