Class TextBlockBuilder

    • Field Detail

      • LINE_BREAKS

        public static final String LINE_BREAKS
        Characters indicating a line break when found inside a String.
    • Constructor Detail

      • TextBlockBuilder

        public TextBlockBuilder()
    • Method Detail

      • getFillChar

        public char getFillChar()
        Retrieves the fill char from the fill char property.
        Specified by:
        getFillChar in interface FillCharAccessor
        Returns:
        The fill char stored by the fill char property.
      • setFillChar

        public void setFillChar​(char aFillChar)
        Sets the fill char for the fill char property.
        Specified by:
        setFillChar in interface FillCharAccessor.FillCharMutator
        Parameters:
        aFillChar - The fill char to be stored by the fill char property.
      • withColumnWidth

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

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

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

        public HorizAlignTextMode getHorizAlignTextMode()
        Retrieves the horizontal align text mode from the horizontal align text mode property.
        Specified by:
        getHorizAlignTextMode in interface HorizAlignTextModeAccessor
        Returns:
        The horizontal align text mode stored by the horizontal align text mode property.
      • getSplitTextMode

        public SplitTextMode getSplitTextMode()
        Retrieves the split text mode from the split text mode property.
        Returns:
        The split text mode stored by the split text mode property.
      • setSplitTextMode

        public void setSplitTextMode​(SplitTextMode aSplitTextMode)
        Sets the split text mode for the split text mode property.
        Parameters:
        aSplitTextMode - The split text mode to be stored by the align text mode property.
      • withSplitTextMode

        public TextBlockBuilder withSplitTextMode​(SplitTextMode aSplitTextMode)
        Sets the split text mode for the split text mode property.
        Parameters:
        aSplitTextMode - The split text mode to be stored by the align text mode property.
        Returns:
        The builder for applying multiple build operations.
      • asTextBlock

        public static String[] asTextBlock​(String aText,
                                           int aColumnWidth)
        Cuts the String into subString instances with the maximum given length. The array of the resulting String instances is returned. It is assumed that the text does not contain any ANSI escape codes, else use the according method with the ANSI escape code flag.
        Parameters:
        aText - The String text line to be cut into sub String instances ( String array).
        aColumnWidth - The maximum length of a line returned in the String array.
        Returns:
        A String array with the subString instances.
      • asTextBlock

        public static String[] asTextBlock​(String aText,
                                           int aColumnWidth,
                                           SplitTextMode aSplitTextMode)
        Cuts the String into subString instances with the maximum given length. The array of the resulting String instances is returned. It is assumed that the text does not contain any ANSI escape codes, else use the according method with the ANSI escape code flag.
        Parameters:
        aText - The String text line to be cut into sub String instances ( String array).
        aColumnWidth - The maximum length of a line returned in the String array.
        aSplitTextMode - Depending on which value is passed, a line is split into subString instances preferably reckoning an end of a line ( SplitTextMode.AT_END_OF_LINE), preferably reckoning the spaces (SplitTextMode.AT_SPACE) or exactly reckoning a given width (SplitTextMode.AT_FIXED_WIDTH).
        Returns:
        A String array with the subString instances.
      • asTextBlock

        public static String[] asTextBlock​(String aText,
                                           int aColumnWidth,
                                           HorizAlignTextMode aHorizAlignTextMode)
        Cuts the String into subString instances with the maximum given length. The array of the resulting String instances is returned. It is assumed that the text does not contain any ANSI escape codes, else use the according method with the ANSI escape code flag.
        Parameters:
        aText - The String text line to be cut into sub String instances ( String array).
        aColumnWidth - The maximum length of a line returned in the String array.
        aHorizAlignTextMode - The HorizAlignTextMode specifies on how a line is to be aligned in the result.
        Returns:
        A String array with the subString instances.
      • asTextBlock

        public static String[] asTextBlock​(String aText,
                                           int aColumnWidth,
                                           HorizAlignTextMode aHorizAlignTextMode,
                                           SplitTextMode aSplitTextMode,
                                           char aFillChar)
        Cuts the String into subString instances with the maximum given length. The array of the resulting String instances is returned. It is assumed that the text does not contain any ANSI escape codes, else use the according method with the ANSI escape code flag.
        Parameters:
        aText - The String text line to be cut into sub String instances ( String array).
        aColumnWidth - The maximum length of a line returned in the String array.
        aHorizAlignTextMode - The HorizAlignTextMode specifies on how a line is to be aligned in the result.
        aSplitTextMode - Depending on which value is passed, a line is split into subString instances preferably reckoning an end of a line ( SplitTextMode.AT_END_OF_LINE), preferably reckoning the spaces (SplitTextMode.AT_SPACE) or exactly reckoning a given width (SplitTextMode.AT_FIXED_WIDTH).
        aFillChar - The fill char to be used when filling up the String.
        Returns:
        A String array with the subString instances.
      • asTextBlock

        public static String[] asTextBlock​(String[] aText,
                                           int aColumnWidth)
        Cuts the String array into subString instances with the maximum given length. The array of the resulting String instances is returned. It is assumed that the text does not contain any ANSI escape codes, else use the according method with the ANSI escape code flag.
        Parameters:
        aText - The String text line to be cut into sub String instances ( String array).
        aColumnWidth - The maximum length of a line returned in the String array.
        Returns:
        A String array with the subString instances.
      • asTextBlock

        public static String[] asTextBlock​(String[] aText,
                                           int aColumnWidth,
                                           SplitTextMode aSplitTextMode)
        Cuts the String array into subString instances with the maximum given length. The array of the resulting String instances is returned. It is assumed that the text does not contain any ANSI escape codes, else use the according method with the ANSI escape code flag.
        Parameters:
        aText - The String text line to be cut into sub String instances ( String array).
        aColumnWidth - The maximum length of a line returned in the String array.
        aSplitTextMode - Depending on which value is passed, a line is split into subString instances preferably reckoning an end of a line ( SplitTextMode.AT_END_OF_LINE), preferably reckoning the spaces (SplitTextMode.AT_SPACE) or exactly reckoning a given width (SplitTextMode.AT_FIXED_WIDTH).
        Returns:
        A String array with the subString instances.
      • asTextBlock

        public static String[] asTextBlock​(String[] aText,
                                           int aColumnWidth,
                                           HorizAlignTextMode aHorizAlignTextMode)
        Cuts the String array into subString instances with the maximum given length. The array of the resulting String instances is returned. It is assumed that the text does not contain any ANSI escape codes, else use the according method with the ANSI escape code flag.
        Parameters:
        aText - The String text line to be cut into sub String instances ( String array).
        aColumnWidth - The maximum length of a line returned in the String array.
        aHorizAlignTextMode - The HorizAlignTextMode specifies on how a line is to be aligned in the result.
        Returns:
        A String array with the subString instances.
      • asTextBlock

        public static String[] asTextBlock​(String[] aText,
                                           int aColumnWidth,
                                           HorizAlignTextMode aHorizAlignTextMode,
                                           SplitTextMode aSplitTextMode,
                                           char aFillChar)
        Cuts the String array into subString instances with the maximum given length. The array of the resulting String instances is returned. It is assumed that the text does not contain any ANSI escape codes, else use the according method with the ANSI escape code flag.
        Parameters:
        aText - The String text line to be cut into sub String instances ( String array).
        aColumnWidth - The maximum length of a line returned in the String array.
        aHorizAlignTextMode - The HorizAlignTextMode specifies on how a line is to be aligned in the result.
        aSplitTextMode - Depending on which value is passed, a line is split into subString instances preferably reckoning an end of a line ( SplitTextMode.AT_END_OF_LINE), preferably reckoning the spaces (SplitTextMode.AT_SPACE) or exactly reckoning a given width (SplitTextMode.AT_FIXED_WIDTH).
        aFillChar - The fill char to be used when filling up the String.
        Returns:
        A String array with the subString instances.
      • asTextBlock

        public static String[] asTextBlock​(String aText,
                                           int aColumnWidth,
                                           boolean hasAnsiEscapeCodes)
        Cuts the String into subString instances with the maximum given length. The array of the resulting String instances is returned.
        Parameters:
        aText - The String text line to be cut into sub String instances ( String array).
        aColumnWidth - The maximum length of a line returned in the String array.
        hasAnsiEscapeCodes - Whether to take any (non printable) ANSI escape codes into account which would, when not being considered, cause wrong results.
        Returns:
        A String array with the subString instances.
      • asTextBlock

        public static String[] asTextBlock​(String aText,
                                           int aColumnWidth,
                                           SplitTextMode aSplitTextMode,
                                           boolean hasAnsiEscapeCodes)
        Cuts the String into subString instances with the maximum given length. The array of the resulting String instances is returned.
        Parameters:
        aText - The String text line to be cut into sub String instances ( String array).
        aColumnWidth - The maximum length of a line returned in the String array.
        aSplitTextMode - Depending on which value is passed, a line is split into subString instances preferably reckoning an end of a line ( SplitTextMode.AT_END_OF_LINE), preferably reckoning the spaces (SplitTextMode.AT_SPACE) or exactly reckoning a given width (SplitTextMode.AT_FIXED_WIDTH).
        hasAnsiEscapeCodes - Whether to take any (non printable) ANSI escape codes into account which would, when not being considered, cause wrong results.
        Returns:
        A String array with the subString instances.
      • asTextBlock

        public static String[] asTextBlock​(String aText,
                                           int aColumnWidth,
                                           HorizAlignTextMode aHorizAlignTextMode,
                                           boolean hasAnsiEscapeCodes)
        Cuts the String into subString instances with the maximum given length. The array of the resulting String instances is returned.
        Parameters:
        aText - The String text line to be cut into sub String instances ( String array).
        aColumnWidth - The maximum length of a line returned in the String array.
        aHorizAlignTextMode - The HorizAlignTextMode specifies on how a line is to be aligned in the result.
        hasAnsiEscapeCodes - Whether to take any (non printable) ANSI escape codes into account which would, when not being considered, cause wrong results.
        Returns:
        A String array with the subString instances.
      • asTextBlock

        public static String[] asTextBlock​(String aText,
                                           int aColumnWidth,
                                           HorizAlignTextMode aHorizAlignTextMode,
                                           SplitTextMode aSplitTextMode,
                                           char aFillChar,
                                           boolean hasAnsiEscapeCodes)
        Cuts the String into subString instances with the maximum given length. The array of the resulting String instances is returned.
        Parameters:
        aText - The String text line to be cut into sub String instances ( String array).
        aColumnWidth - The maximum length of a line returned in the String array.
        aHorizAlignTextMode - The HorizAlignTextMode specifies on how a line is to be aligned in the result.
        aSplitTextMode - Depending on which value is passed, a line is split into subString instances preferably reckoning an end of a line ( SplitTextMode.AT_END_OF_LINE), preferably reckoning the spaces (SplitTextMode.AT_SPACE) or exactly reckoning a given width (SplitTextMode.AT_FIXED_WIDTH).
        aFillChar - The fill char to be used when filling up the String.
        hasAnsiEscapeCodes - Whether to take any (non printable) ANSI escape codes into account which would, when not being considered, cause wrong results.
        Returns:
        A String array with the subString instances.
      • asTextBlock

        public static String[] asTextBlock​(String[] aText,
                                           int aColumnWidth,
                                           boolean hasAnsiEscapeCodes)
        Cuts the String array into subString instances with the maximum given length. The array of the resulting String instances is returned.
        Parameters:
        aText - The String text line to be cut into sub String instances ( String array).
        aColumnWidth - The maximum length of a line returned in the String array.
        hasAnsiEscapeCodes - Whether to take any (non printable) ANSI escape codes into account which would, when not being considered, cause wrong results.
        Returns:
        A String array with the subString instances.
      • asTextBlock

        public static String[] asTextBlock​(String[] aText,
                                           int aColumnWidth,
                                           SplitTextMode aSplitTextMode,
                                           boolean hasAnsiEscapeCodes)
        Cuts the String array into subString instances with the maximum given length. The array of the resulting String instances is returned.
        Parameters:
        aText - The String text line to be cut into sub String instances ( String array).
        aColumnWidth - The maximum length of a line returned in the String array.
        aSplitTextMode - Depending on which value is passed, a line is split into subString instances preferably reckoning an end of a line ( SplitTextMode.AT_END_OF_LINE), preferably reckoning the spaces (SplitTextMode.AT_SPACE) or exactly reckoning a given width (SplitTextMode.AT_FIXED_WIDTH).
        hasAnsiEscapeCodes - Whether to take any (non printable) ANSI escape codes into account which would, when not being considered, cause wrong results.
        Returns:
        A String array with the subString instances.
      • asTextBlock

        public static String[] asTextBlock​(String[] aText,
                                           int aColumnWidth,
                                           HorizAlignTextMode aHorizAlignTextMode,
                                           boolean hasAnsiEscapeCodes)
        Cuts the String array into subString instances with the maximum given length. The array of the resulting String instances is returned.
        Parameters:
        aText - The String text line to be cut into sub String instances ( String array).
        aColumnWidth - The maximum length of a line returned in the String array.
        aHorizAlignTextMode - The HorizAlignTextMode specifies on how a line is to be aligned in the result.
        hasAnsiEscapeCodes - Whether to take any (non printable) ANSI escape codes into account which would, when not being considered, cause wrong results.
        Returns:
        A String array with the subString instances.
      • asTextBlock

        public static String[] asTextBlock​(String[] aText,
                                           int aColumnWidth,
                                           HorizAlignTextMode aHorizAlignTextMode,
                                           SplitTextMode aSplitTextMode,
                                           char aFillChar,
                                           boolean hasAnsiEscapeCodes)
        Cuts the String array into subString instances with the maximum given length. The array of the resulting String instances is returned.
        Parameters:
        aText - The String text line to be cut into sub String instances ( String array).
        aColumnWidth - The maximum length of a line returned in the String array.
        aHorizAlignTextMode - The HorizAlignTextMode specifies on how a line is to be aligned in the result.
        aSplitTextMode - Depending on which value is passed, a line is split into subString instances preferably reckoning an end of a line ( SplitTextMode.AT_END_OF_LINE), preferably reckoning the spaces (SplitTextMode.AT_SPACE) or exactly reckoning a given width (SplitTextMode.AT_FIXED_WIDTH).
        aFillChar - The fill char to be used when filling up the String.
        hasAnsiEscapeCodes - Whether to take any (non printable) ANSI escape codes into account which would, when not being considered, cause wrong results.
        Returns:
        A String array with the subString instances.
      • 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.
      • 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