Class TextBorderBuilder

java.lang.Object
org.refcodes.textual.TextBorderBuilder
All Implemented Interfaces:
org.refcodes.graphical.BoxBorderModeAccessor, org.refcodes.graphical.BoxBorderModeAccessor.BoxBorderModeBuilder<TextBorderBuilder>, org.refcodes.graphical.BoxBorderModeAccessor.BoxBorderModeMutator, org.refcodes.graphical.BoxBorderModeAccessor.BoxBorderModeProperty, Text<TextBorderBuilder>, TextAccessor, TextAccessor.TextBuilder<Text<TextBorderBuilder>>, TextAccessor.TextMutator, TextAccessor.TextProperty, TextAccessor.TextProvider, TextBoxGridAccessor, TextBoxGridAccessor.TextBoxGridBuilder<TextBorderBuilder>, TextBoxGridAccessor.TextBoxGridMutator, TextBoxGridAccessor.TextBoxGridProperty

public class TextBorderBuilder extends Object implements org.refcodes.graphical.BoxBorderModeAccessor.BoxBorderModeProperty, org.refcodes.graphical.BoxBorderModeAccessor.BoxBorderModeBuilder<TextBorderBuilder>, TextBoxGridAccessor.TextBoxGridProperty, TextBoxGridAccessor.TextBoxGridBuilder<TextBorderBuilder>
"Draws" a border around a text. The text border can be provided by adjusting properties such as the TableStyle or the BoxBorderMode. When providing a TableStyle, then the TableStyle.getBody() characters are used to draw the border.
  • Constructor Details

    • TextBorderBuilder

      public TextBorderBuilder()
  • Method Details

    • setTextBoxStyle

      public void setTextBoxStyle(TextBoxStyle aTextBoxStyle)
      Convenience method for setTextBoxGrid(TextBoxGrid) to set the TextBoxGrid from a TextBoxStyle value
      Parameters:
      aTextBoxStyle - The TextBoxStyle which's TextBoxGrid is to be set.
    • withTextBoxStyle

      public TextBorderBuilder withTextBoxStyle(TextBoxStyle aTextBoxStyle)
      Convenience method for withTextBoxGrid(TextBoxGrid) to set the TextBoxGrid from a TextBoxStyle value
      Parameters:
      aTextBoxStyle - The TextBoxStyle which's TextBoxGrid is to be set.
      Returns:
      This instance as of the builder pattern,
    • withBorderChar

      public TextBorderBuilder withBorderChar(char aBorderChar)
      Sets the border char for the border char property.
      Parameters:
      aBorderChar - The border char to be stored by the text align mode property.
      Returns:
      The builder for applying multiple build operations.
    • withBorderWidth

      public TextBorderBuilder withBorderWidth(int aBorderWidth)
      Sets the border width for the border width property.
      Parameters:
      aBorderWidth - The border width to be stored by the text align mode property.
      Returns:
      The builder for applying multiple build operations.
    • getBoxBorderMode

      public org.refcodes.graphical.BoxBorderMode getBoxBorderMode()
      Specified by:
      getBoxBorderMode in interface org.refcodes.graphical.BoxBorderModeAccessor
    • setBoxBorderMode

      public void setBoxBorderMode(org.refcodes.graphical.BoxBorderMode aBoxBorderMode)
      Specified by:
      setBoxBorderMode in interface org.refcodes.graphical.BoxBorderModeAccessor.BoxBorderModeMutator
    • withBoxBorderMode

      public TextBorderBuilder withBoxBorderMode(org.refcodes.graphical.BoxBorderMode aBoxBorderMode)
      Specified by:
      withBoxBorderMode in interface org.refcodes.graphical.BoxBorderModeAccessor.BoxBorderModeBuilder<TextBorderBuilder>
    • getTextBoxGrid

      public TextBoxGrid getTextBoxGrid()
      Gets the currently set TextBoxGrid being used.
      Specified by:
      getTextBoxGrid in interface TextBoxGridAccessor
      Returns:
      The currently configured TextBoxGrids.
    • setTextBoxGrid

      public void setTextBoxGrid(TextBoxGrid aTextBoxGrid)
      Sets the TextBoxGrid to be used.
      Specified by:
      setTextBoxGrid in interface TextBoxGridAccessor.TextBoxGridMutator
      Parameters:
      aTextBoxGrid - The TextBoxGrid to be stored by the TextBoxGrid property.
    • withTextBoxGrid

      public TextBorderBuilder withTextBoxGrid(TextBoxGrid aTextBoxGrid)
      Sets the rows TextBoxGrid to use returns this builder as of the Builder-Pattern.
      Specified by:
      withTextBoxGrid in interface TextBoxGridAccessor.TextBoxGridBuilder<TextBorderBuilder>
      Parameters:
      aTextBoxGrid - The TextBoxGrid to be used.
      Returns:
      This TextBoxGridAccessor.TextBoxGridBuilder instance to continue configuration.
    • withTextBoxGrid

      public TextBorderBuilder withTextBoxGrid(TextBoxStyle aTextBoxStyle)
      Sets the rows TextBoxGrid to use returns this builder as of the Builder-Pattern.
      Specified by:
      withTextBoxGrid in interface TextBoxGridAccessor.TextBoxGridBuilder<TextBorderBuilder>
      Parameters:
      aTextBoxStyle - The TextBoxStyle to be used.
      Returns:
      This TextBoxGridAccessor.TextBoxGridBuilder instance to continue configuration.
    • getBorderChar

      public char getBorderChar()
      Retrieves the border char from the border char property.
      Returns:
      The border char stored by the border char property.
    • setBorderChar

      public void setBorderChar(char aBorderChar)
      Sets the border char for the border char property.
      Parameters:
      aBorderChar - The border char to be stored by the text align mode property.
    • getBorderWidth

      public int getBorderWidth()
      Retrieves the border width from the border width property.
      Returns:
      The border width stored by the border width property.
    • setBorderWidth

      public void setBorderWidth(int aBorderWidth)
      Sets the border width for the border width property.
      Parameters:
      aBorderWidth - The border width to be stored by the text align mode property.
    • toStrings

      public String[] toStrings()
      The Strings being build by the builder upon the settings of the attributes.
      Specified by:
      toStrings in interface TextAccessor.TextProvider
      Returns:
      The according resulting String array
    • toStrings

      public String[] toStrings(String... aText)
      Race condition safe shortcut for using Text.withText(String...) followed by TextAccessor.TextProvider.toStrings(). Implementation requirements: This method must not(!) be implemented by calling Text.withText(String...) followed by TextAccessor.TextProvider.toStrings() (do not change the text property) as this would not be thread safe!
      Specified by:
      toStrings in interface Text<TextBorderBuilder>
      Parameters:
      aText - The text to be processed.
      Returns:
      The according resulting String array
    • toLeftBorder

      protected static String[] toLeftBorder(String[] aText, int aBorderWidth, char aBorderChar)
      Adds the according border with the given char and the provided witdh to the provided text.
      Parameters:
      aText - The text to which the border is to be applied.
      aBorderWidth - The width of the border to be drawn.
      aBorderChar - The character of the border to be drawn.
      Returns:
      The text with the according border being applied.
    • toRightBorder

      protected static String[] toRightBorder(String[] aText, int aBorderWidth, char aBorderChar)
      Adds the according border with the given char and the provided width to the provided text.
      Parameters:
      aText - The text to which the border is to be applied.
      aBorderWidth - The width of the border to be drawn.
      aBorderChar - The character of the border to be drawn.
      Returns:
      The text with the according border being applied.
    • toTopBorder

      protected static String[] toTopBorder(String[] aText, int aBorderWidth, char aBorderChar)
      Adds the according border with the given char and the provided width to the provided text.
      Parameters:
      aText - The text to which the border is to be applied.
      aBorderWidth - The width of the border to be drawn.
      aBorderChar - The character of the border to be drawn.
      Returns:
      The text with the according border being applied.
    • toBottomBorder

      protected static String[] toBottomBorder(String[] aText, int aBorderWidth, char aBorderChar)
      Adds the according border with the given char and the provided width to the provided text.
      Parameters:
      aText - The text to which the border is to be applied.
      aBorderWidth - The width of the border to be drawn.
      aBorderChar - The character of the border to be drawn.
      Returns:
      The text with the according border being applied.
    • toBorder

      public static String[] toBorder(String[] aText, int aBorderWidth, char aBorderChar, org.refcodes.graphical.BoxBorderMode aBoxBorderMode)
      Adds the according border with the given char and the provided width to the provided text.
      Parameters:
      aText - The text to which the border is to be applied.
      aBorderWidth - The width of the border to be drawn.
      aBorderChar - The character of the border to be drawn.
      aBoxBorderMode - the box border mode
      Returns:
      The text with the according border being applied.
    • toBorder

      protected static String[] toBorder(String[] aText, char aTopLeftBorderChar, char aTopRightBorderChar, char aBottomLeftBorderChar, char aBottomRightBorderChar, char aTopBorderChar, char aRightBorderChar, char aBottomBorderChar, char aLeftBorderChar, org.refcodes.graphical.BoxBorderMode aBoxBorderMode)
      Adds a predefined border according border to the provided text.
      Parameters:
      aText - The text to which the border is to be applied.
      aTopLeftBorderChar - The top left border's character.
      aTopRightBorderChar - The top right border's character.
      aBottomLeftBorderChar - The bottom left border's character.
      aBottomRightBorderChar - The bottom right border's character.
      aTopBorderChar - the top border char
      aRightBorderChar - the right border char
      aBottomBorderChar - the bottom border char
      aLeftBorderChar - the left border char
      aBoxBorderMode - the box border mode
      Returns:
      The text with the according border being applied.
    • toSingleBorder

      protected static String[] toSingleBorder(String[] aText)
      Adds a predefined "single-line" border to the provided text.
      Parameters:
      aText - The text to which the border is to be applied.
      Returns:
      The text with the according border being applied.
    • toDoubleBorder

      protected static String[] toDoubleBorder(String[] aText)
      Adds a predefined "double-line" border to the provided text.
      Parameters:
      aText - The text to which the border is to be applied.
      Returns:
      The text with the according border being applied.
    • toAsciiBorder

      protected static String[] toAsciiBorder(String[] aText)
      Adds a predefined "single-line" border to the provided text.
      Parameters:
      aText - The text to which the border is to be applied.
      Returns:
      The text with the according border being applied.
    • toLine

      protected static String toLine(int aLength, char aFillChar)
      Returns a String with the given length and containing only the provided fill character.
      Parameters:
      aLength - The length to be reached.
      aFillChar - The char to be used for filling up
      Returns:
      The String filled with the fill character till the provided length.
    • getText

      public String[] getText()
      Retrieves the text from the text property.
      Specified by:
      getText in interface TextAccessor
      Returns:
      The text stored by the text property.
    • setText

      public void setText(String... aText)
      Sets the text for the text property.
      Specified by:
      setText in interface TextAccessor.TextMutator
      Parameters:
      aText - The text to be stored by the text property.
    • withText

      public TextBorderBuilder withText(String... aText)
      With text.
      Specified by:
      withText in interface Text<B extends Text<B>>
      Specified by:
      withText in interface TextAccessor.TextBuilder<B extends Text<B>>
      Parameters:
      aText - the text
      Returns:
      the b
    • withText

      public TextBorderBuilder withText(Collection<String> aText)
      With text.
      Specified by:
      withText in interface TextAccessor.TextBuilder<B extends Text<B>>
      Parameters:
      aText - the text
      Returns:
      the b
    • toString

      public String toString()
      The String being build by the builder upon the settings of the attributes. In case more then one line has been set as input and the functionality of the builder is applied to each line in separate, then this method returns all of them lines concatenated with a line break between each of them (implementation depended).
      Specified by:
      toString in interface TextAccessor.TextProvider
      Overrides:
      toString in class Object
      Returns:
      The according resulting String
    • toString

      public String toString(String... aText)
      Race condition safe shortcut for using Text.withText(String...) followed by TextAccessor.TextProvider.toString(). Implementation requirements: This method must not(!) be implemented by calling Text.withText(String...) followed by TextAccessor.TextProvider.toString() (do not change the text property) as this would not be thread safe!
      Specified by:
      toString in interface Text<B extends Text<B>>
      Parameters:
      aText - The text to be processed.
      Returns:
      The according resulting String