Class MoreTextBuilder

java.lang.Object
org.refcodes.textual.MoreTextBuilder
All Implemented Interfaces:
org.refcodes.mixin.ColumnWidthAccessor, org.refcodes.mixin.ColumnWidthAccessor.ColumnWidthBuilder<MoreTextBuilder>, org.refcodes.mixin.ColumnWidthAccessor.ColumnWidthMutator, org.refcodes.mixin.ColumnWidthAccessor.ColumnWidthProperty, Text<MoreTextBuilder>, TextAccessor, TextAccessor.TextBuilder<Text<MoreTextBuilder>>, TextAccessor.TextMutator, TextAccessor.TextProperty, TextAccessor.TextProvider

public class MoreTextBuilder
extends Object
implements Text<MoreTextBuilder>, org.refcodes.mixin.ColumnWidthAccessor.ColumnWidthProperty, org.refcodes.mixin.ColumnWidthAccessor.ColumnWidthBuilder<MoreTextBuilder>
A builder for processing a text with the given width applied and the given MoreTextMode applied.
  • Constructor Details

    • MoreTextBuilder

      public MoreTextBuilder()
  • Method Details

    • getMoreText

      public String getMoreText()
      Retrieves the more text from the more text property.
      Returns:
      The more text stored by the more text property.
    • setMoreText

      public void setMoreText​(String aMoreText)
      Sets the more text for the more text property.
      Parameters:
      aMoreText - The more text to be stored by the more text mode property.
    • getColumnWidth

      public int getColumnWidth()
      Specified by:
      getColumnWidth in interface org.refcodes.mixin.ColumnWidthAccessor
    • setColumnWidth

      public void setColumnWidth​(int aColumnWidth)
      Specified by:
      setColumnWidth in interface org.refcodes.mixin.ColumnWidthAccessor.ColumnWidthMutator
    • withColumnWidth

      public MoreTextBuilder withColumnWidth​(int aColumnWidth)
      Specified by:
      withColumnWidth in interface org.refcodes.mixin.ColumnWidthAccessor.ColumnWidthBuilder<MoreTextBuilder>
    • getMoreTextMode

      public MoreTextMode getMoreTextMode()
      Retrieves the more text mode from the more text mode property.
      Returns:
      The more text mode stored by the more text mode property.
    • setMoreTextMode

      public void setMoreTextMode​(MoreTextMode aMoreTextMode)
      Sets the more text mode for the more text mode property.
      Parameters:
      aMoreTextMode - The more text mode to be stored by the more text 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<MoreTextBuilder>
      Parameters:
      aText - The text to be processed.
      Returns:
      The according resulting String array
    • withMoreTextMode

      public MoreTextBuilder withMoreTextMode​(MoreTextMode aMoreTextMode)
      Sets the more text mode for the more text mode property.
      Parameters:
      aMoreTextMode - the more text mode
      Returns:
      The builder for applying multiple build operations.
    • withMoreText

      public MoreTextBuilder withMoreText​(String aMoreText)
      Sets the more text for the more text property.
      Parameters:
      aMoreText - the more text
      Returns:
      The builder for applying multiple build operations.
    • toString

      public String toString() throws IllegalStateException
      The String being build by the builder upon the settings of the attributes.
      Specified by:
      toString in interface TextAccessor.TextProvider
      Returns:
      The according resulting String
      Throws:
      IllegalStateException - Thrown in case more than one text line has been set via the Text.withText(String...) or TextAccessor.TextMutator.setText(String...) methods.
    • asMoreText

      public static String[] asMoreText​(String[] aText, int aLength, String aMore, MoreTextMode aMoreTextMode)
      The text array is "mored" depending on the provided MoreTextMode. It is assumed that the text does not contain any ANSI escape codes, else asMoreText(String[], int, String, MoreTextMode, boolean) In case it is MoreTextMode.NONE, then the text is returned untouched. In case it is MoreTextMode.LEFT, then the text is "mored" to the left. In case it is MoreTextMode.RIGHT, then the text is "mored" the the right.
      Parameters:
      aText - The text array to be truncated.
      aLength - The length to be reached.
      aMore - The text to be prepended to the left in case the text was longer than the required length.
      aMoreTextMode - The MoreTextMode specifying on how to truncate the text.
      Returns:
      The accordingly "mored" text array.
    • asMoreText

      public static String[] asMoreText​(String[] aText, int aLength, String aMore, MoreTextMode aMoreTextMode, boolean hasAnsiEscapeCodes)
      The text array is "mored" depending on the provided MoreTextMode. In case it is MoreTextMode.NONE, then the text is returned untouched. In case it is MoreTextMode.LEFT, then the text is "mored" to the left. In case it is MoreTextMode.RIGHT, then the text is "mored" the the right.
      Parameters:
      aText - The text array to be truncated.
      aLength - The length to be reached.
      aMore - The text to be prepended to the left in case the text was longer than the required length.
      aMoreTextMode - The MoreTextMode specifying on how to truncate the text.
      hasAnsiEscapeCodes - Whether to take any (non printable) ANSI escape codes into account which would, when not being considered, cause wrong results.
      Returns:
      The accordingly "mored" text array.
    • asMoreText

      public static String asMoreText​(String aText, int aLength, String aMore, MoreTextMode aMoreTextMode)
      The text is "mored" depending on the provided MoreTextMode. It is assumed that the text does not contain any ANSI escape codes, else asMoreText(String, int, String, MoreTextMode, boolean) In case it is MoreTextMode.NONE, then the text is returned untouched. In case it is MoreTextMode.LEFT, then the text is "mored" to the left. In case it is MoreTextMode.RIGHT, then the text is "mored" the the right.
      Parameters:
      aText - The text array to be truncated.
      aLength - The length to be reached.
      aMore - The text to be prepended to the left in case the text was longer than the required length.
      aMoreTextMode - The MoreTextMode specifying on how to truncate the text.
      Returns:
      The accordingly "mored" text array.
    • asMoreText

      public static String asMoreText​(String aText, int aLength, String aMore, MoreTextMode aMoreTextMode, boolean hasAnsiEscapeCodes)
      The text is "mored" depending on the provided MoreTextMode. In case it is MoreTextMode.NONE, then the text is returned untouched. In case it is MoreTextMode.LEFT, then the text is "mored" to the left. In case it is MoreTextMode.RIGHT, then the text is "mored" the the right.
      Parameters:
      aText - The text to be truncated.
      aLength - The length to be reached.
      aMore - The text to be prepended to the left in case the text was longer than the required length.
      aMoreTextMode - The MoreTextMode specifying on how to truncate the text.
      hasAnsiEscapeCodes - Whether to take any (non printable) ANSI escape codes into account which would, when not being considered, cause wrong results.
      Returns:
      The accordingly "mored" text.
    • 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 MoreTextBuilder 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 MoreTextBuilder 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​(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