Class KeyValueHorizontalAligner

java.lang.Object
org.springframework.shell.table.KeyValueHorizontalAligner
All Implemented Interfaces:
Aligner

public class KeyValueHorizontalAligner extends Object implements Aligner
A text alignment strategy that aligns text horizontally so that all instances of some special character(s) line up perfectly in a column.

Typically used to render numbers which may or may not have a decimal point, or series of key-value pairs

  • Constructor Details

    • KeyValueHorizontalAligner

      public KeyValueHorizontalAligner(String delimiter)
  • Method Details

    • align

      public String[] align(String[] text, int cellWidth, int cellHeight)
      Description copied from interface: Aligner
      Perform text alignment, returning a String array that MUST contain cellHeight lines, each of which MUST be cellWidth chars in length.

      Input array is guaranteed to contain lines that have length equal to cellWidth. There is no guarantee on the input number of lines though.

      Specified by:
      align in interface Aligner
      Parameters:
      text - the text to align
      cellWidth - the width of of the table cell
      cellHeight - the height of the table cell
      Returns:
      the aligned text, in a cellHeight element array