java.lang.Object
org.refcodes.textual.TextBlockBuilder
- All Implemented Interfaces:
org.refcodes.mixin.ColumnWidthAccessor
,org.refcodes.mixin.ColumnWidthAccessor.ColumnWidthBuilder<TextBlockBuilder>
,org.refcodes.mixin.ColumnWidthAccessor.ColumnWidthMutator
,org.refcodes.mixin.ColumnWidthAccessor.ColumnWidthProperty
,FillCharAccessor
,FillCharAccessor.FillCharBuilder<TextBlockBuilder>
,FillCharAccessor.FillCharMutator
,FillCharAccessor.FillCharProperty
,HorizAlignTextModeAccessor
,HorizAlignTextModeAccessor.HorizAlignTextModeBuilder<TextBlockBuilder>
,HorizAlignTextModeAccessor.HorizAlignTextModeMutator
,HorizAlignTextModeAccessor.HorizAlignTextModeProperty
,Text<TextBlockBuilder>
,TextAccessor
,TextAccessor.TextBuilder<Text<TextBlockBuilder>>
,TextAccessor.TextMutator
,TextAccessor.TextProperty
,TextAccessor.TextProvider
public class TextBlockBuilder
extends Object
implements FillCharAccessor.FillCharProperty, FillCharAccessor.FillCharBuilder<TextBlockBuilder>, org.refcodes.mixin.ColumnWidthAccessor.ColumnWidthBuilder<TextBlockBuilder>, org.refcodes.mixin.ColumnWidthAccessor.ColumnWidthProperty, HorizAlignTextModeAccessor.HorizAlignTextModeProperty, HorizAlignTextModeAccessor.HorizAlignTextModeBuilder<TextBlockBuilder>
Builds a text block according to the configuration. E.g. the
HorizAlignTextMode
or the SplitTextMode
can be configured as
well as the desired column width (as of setColumnWidth(int)
).-
Nested Class Summary
Nested classes/interfaces inherited from interface org.refcodes.mixin.ColumnWidthAccessor
org.refcodes.mixin.ColumnWidthAccessor.ColumnWidthBuilder<B extends org.refcodes.mixin.ColumnWidthAccessor.ColumnWidthBuilder<B>>, org.refcodes.mixin.ColumnWidthAccessor.ColumnWidthMutator, org.refcodes.mixin.ColumnWidthAccessor.ColumnWidthProperty
Nested classes/interfaces inherited from interface org.refcodes.textual.FillCharAccessor
FillCharAccessor.FillCharBuilder<B extends FillCharAccessor.FillCharBuilder<B>>, FillCharAccessor.FillCharMutator, FillCharAccessor.FillCharProperty
Nested classes/interfaces inherited from interface org.refcodes.textual.HorizAlignTextModeAccessor
HorizAlignTextModeAccessor.HorizAlignTextModeBuilder<B extends HorizAlignTextModeAccessor.HorizAlignTextModeBuilder<B>>, HorizAlignTextModeAccessor.HorizAlignTextModeMutator, HorizAlignTextModeAccessor.HorizAlignTextModeProperty
Nested classes/interfaces inherited from interface org.refcodes.textual.TextAccessor
TextAccessor.TextBuilder<B extends TextAccessor.TextBuilder<B>>, TextAccessor.TextMutator, TextAccessor.TextProperty, TextAccessor.TextProvider
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String[]
asTextBlock
(String[] aText, int aColumnWidth) static String[]
asTextBlock
(String[] aText, int aColumnWidth, boolean hasAnsiEscapeCodes) static String[]
asTextBlock
(String[] aText, int aColumnWidth, HorizAlignTextMode aHorizAlignTextMode) static String[]
asTextBlock
(String[] aText, int aColumnWidth, HorizAlignTextMode aHorizAlignTextMode, boolean hasAnsiEscapeCodes) static String[]
asTextBlock
(String[] aText, int aColumnWidth, HorizAlignTextMode aHorizAlignTextMode, SplitTextMode aSplitTextMode, char aFillChar) static String[]
asTextBlock
(String[] aText, int aColumnWidth, HorizAlignTextMode aHorizAlignTextMode, SplitTextMode aSplitTextMode, char aFillChar, boolean hasAnsiEscapeCodes) static String[]
asTextBlock
(String[] aText, int aColumnWidth, SplitTextMode aSplitTextMode) static String[]
asTextBlock
(String[] aText, int aColumnWidth, SplitTextMode aSplitTextMode, boolean hasAnsiEscapeCodes) static String[]
asTextBlock
(String aText, int aColumnWidth) static String[]
asTextBlock
(String aText, int aColumnWidth, boolean hasAnsiEscapeCodes) static String[]
asTextBlock
(String aText, int aColumnWidth, HorizAlignTextMode aHorizAlignTextMode) static String[]
asTextBlock
(String aText, int aColumnWidth, HorizAlignTextMode aHorizAlignTextMode, boolean hasAnsiEscapeCodes) static String[]
asTextBlock
(String aText, int aColumnWidth, HorizAlignTextMode aHorizAlignTextMode, SplitTextMode aSplitTextMode, char aFillChar) static String[]
asTextBlock
(String aText, int aColumnWidth, HorizAlignTextMode aHorizAlignTextMode, SplitTextMode aSplitTextMode, char aFillChar, boolean hasAnsiEscapeCodes) static String[]
asTextBlock
(String aText, int aColumnWidth, SplitTextMode aSplitTextMode) static String[]
asTextBlock
(String aText, int aColumnWidth, SplitTextMode aSplitTextMode, boolean hasAnsiEscapeCodes) int
char
Retrieves the fill char from the fill char property.Retrieves the horizontal align text mode from the horizontal align text mode property.Retrieves the split text mode from the split text mode property.String[]
getText()
Retrieves the text from the text property.void
setColumnWidth
(int aColumnWidth) void
setFillChar
(char aFillChar) Sets the fill char for the fill char property.void
setHorizAlignTextMode
(HorizAlignTextMode aHorizAlignTextMode) Sets the horizontal align text mode for the horizontal align text mode property.void
setSplitTextMode
(SplitTextMode aSplitTextMode) Sets the split text mode for the split text mode property.void
Sets the text for the text property.toString()
TheString
being build by the builder upon the settings of the attributes.Race condition safe shortcut for usingText.withText(String...)
followed byTextAccessor.TextProvider.toString()
.String[]
TheString
s being build by the builder upon the settings of the attributes.String[]
Race condition safe shortcut for usingText.withText(String...)
followed byTextAccessor.TextProvider.toStrings()
.withColumnWidth
(int aColumnWidth) withFillChar
(char aFillChar) Sets the fill char for the fill char property.withHorizAlignTextMode
(HorizAlignTextMode aHorizAlignTextMode) Sets the align text mode for the align text mode property.withSplitTextMode
(SplitTextMode aSplitTextMode) Sets the split text mode for the split text mode property.With text.withText
(Collection<String> aText) With text.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.refcodes.mixin.ColumnWidthAccessor.ColumnWidthProperty
letColumnWidth
Methods inherited from interface org.refcodes.textual.FillCharAccessor.FillCharProperty
letFillChar
Methods inherited from interface org.refcodes.textual.HorizAlignTextModeAccessor.HorizAlignTextModeProperty
letHorizAlignTextMode
Methods inherited from interface org.refcodes.textual.TextAccessor.TextMutator
setText
Methods inherited from interface org.refcodes.textual.TextAccessor.TextProperty
letText, letText
-
Field Details
-
LINE_BREAKS
Characters indicating a line break when found inside aString
.
-
-
Constructor Details
-
TextBlockBuilder
public TextBlockBuilder()
-
-
Method Details
-
getFillChar
public char getFillChar()Retrieves the fill char from the fill char property.- Specified by:
getFillChar
in interfaceFillCharAccessor
- 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 interfaceFillCharAccessor.FillCharMutator
- Parameters:
aFillChar
- The fill char to be stored by the fill char property.
-
withColumnWidth
- Specified by:
withColumnWidth
in interfaceorg.refcodes.mixin.ColumnWidthAccessor.ColumnWidthBuilder<TextBlockBuilder>
-
setColumnWidth
public void setColumnWidth(int aColumnWidth) - Specified by:
setColumnWidth
in interfaceorg.refcodes.mixin.ColumnWidthAccessor.ColumnWidthMutator
-
getColumnWidth
public int getColumnWidth()- Specified by:
getColumnWidth
in interfaceorg.refcodes.mixin.ColumnWidthAccessor
-
setHorizAlignTextMode
Sets the horizontal align text mode for the horizontal align text mode property.- Specified by:
setHorizAlignTextMode
in interfaceHorizAlignTextModeAccessor.HorizAlignTextModeMutator
- Parameters:
aHorizAlignTextMode
- The horizontal align text mode to be stored by the font style property.
-
getHorizAlignTextMode
Retrieves the horizontal align text mode from the horizontal align text mode property.- Specified by:
getHorizAlignTextMode
in interfaceHorizAlignTextModeAccessor
- Returns:
- The horizontal align text mode stored by the horizontal align text mode property.
-
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
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.
-
toStrings
TheString
s being build by the builder upon the settings of the attributes.- Specified by:
toStrings
in interfaceTextAccessor.TextProvider
- Returns:
- The according resulting
String
array
-
toStrings
Race condition safe shortcut for usingText.withText(String...)
followed byTextAccessor.TextProvider.toStrings()
. Implementation requirements: This method must not(!) be implemented by callingText.withText(String...)
followed byTextAccessor.TextProvider.toStrings()
(do not change the text property) as this would not be thread safe!- Specified by:
toStrings
in interfaceText<TextBlockBuilder>
- Parameters:
aText
- The text to be processed.- Returns:
- The according resulting
String
array
-
withHorizAlignTextMode
Sets the align text mode for the align text mode property.- Specified by:
withHorizAlignTextMode
in interfaceHorizAlignTextModeAccessor.HorizAlignTextModeBuilder<TextBlockBuilder>
- Parameters:
aHorizAlignTextMode
- The align text mode to be stored by the align text mode property.- Returns:
- The builder for applying multiple build operations.
-
withFillChar
Sets the fill char for the fill char property.- Specified by:
withFillChar
in interfaceFillCharAccessor.FillCharBuilder<TextBlockBuilder>
- Parameters:
aFillChar
- The fill char to be stored by the fill char property.- Returns:
- The builder for applying multiple build operations.
-
withSplitTextMode
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
-
asTextBlock
Cuts theString
into subString
instances with the maximum given length. The array of the resultingString
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
- TheString
text line to be cut into subString
instances (String
array).aColumnWidth
- The maximum length of a line returned in theString
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 theString
into subString
instances with the maximum given length. The array of the resultingString
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
- TheString
text line to be cut into subString
instances (String
array).aColumnWidth
- The maximum length of a line returned in theString
array.aHorizAlignTextMode
- TheHorizAlignTextMode
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 theString
into subString
instances with the maximum given length. The array of the resultingString
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
- TheString
text line to be cut into subString
instances (String
array).aColumnWidth
- The maximum length of a line returned in theString
array.aHorizAlignTextMode
- TheHorizAlignTextMode
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 theString
.- Returns:
- A
String
array with the subString
instances.
-
asTextBlock
-
asTextBlock
Cuts theString
array into subString
instances with the maximum given length. The array of the resultingString
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
- TheString
text line to be cut into subString
instances (String
array).aColumnWidth
- The maximum length of a line returned in theString
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 theString
array into subString
instances with the maximum given length. The array of the resultingString
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
- TheString
text line to be cut into subString
instances (String
array).aColumnWidth
- The maximum length of a line returned in theString
array.aHorizAlignTextMode
- TheHorizAlignTextMode
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 theString
array into subString
instances with the maximum given length. The array of the resultingString
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
- TheString
text line to be cut into subString
instances (String
array).aColumnWidth
- The maximum length of a line returned in theString
array.aHorizAlignTextMode
- TheHorizAlignTextMode
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 theString
.- Returns:
- A
String
array with the subString
instances.
-
asTextBlock
Cuts theString
into subString
instances with the maximum given length. The array of the resultingString
instances is returned.- Parameters:
aText
- TheString
text line to be cut into subString
instances (String
array).aColumnWidth
- The maximum length of a line returned in theString
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 theString
into subString
instances with the maximum given length. The array of the resultingString
instances is returned.- Parameters:
aText
- TheString
text line to be cut into subString
instances (String
array).aColumnWidth
- The maximum length of a line returned in theString
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 theString
into subString
instances with the maximum given length. The array of the resultingString
instances is returned.- Parameters:
aText
- TheString
text line to be cut into subString
instances (String
array).aColumnWidth
- The maximum length of a line returned in theString
array.aHorizAlignTextMode
- TheHorizAlignTextMode
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 theString
into subString
instances with the maximum given length. The array of the resultingString
instances is returned.- Parameters:
aText
- TheString
text line to be cut into subString
instances (String
array).aColumnWidth
- The maximum length of a line returned in theString
array.aHorizAlignTextMode
- TheHorizAlignTextMode
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 theString
.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
Cuts theString
array into subString
instances with the maximum given length. The array of the resultingString
instances is returned.- Parameters:
aText
- TheString
text line to be cut into subString
instances (String
array).aColumnWidth
- The maximum length of a line returned in theString
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 theString
array into subString
instances with the maximum given length. The array of the resultingString
instances is returned.- Parameters:
aText
- TheString
text line to be cut into subString
instances (String
array).aColumnWidth
- The maximum length of a line returned in theString
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 theString
array into subString
instances with the maximum given length. The array of the resultingString
instances is returned.- Parameters:
aText
- TheString
text line to be cut into subString
instances (String
array).aColumnWidth
- The maximum length of a line returned in theString
array.aHorizAlignTextMode
- TheHorizAlignTextMode
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 theString
array into subString
instances with the maximum given length. The array of the resultingString
instances is returned.- Parameters:
aText
- TheString
text line to be cut into subString
instances (String
array).aColumnWidth
- The maximum length of a line returned in theString
array.aHorizAlignTextMode
- TheHorizAlignTextMode
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 theString
.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
Retrieves the text from the text property.- Specified by:
getText
in interfaceTextAccessor
- Returns:
- The text stored by the text property.
-
setText
Sets the text for the text property.- Specified by:
setText
in interfaceTextAccessor.TextMutator
- Parameters:
aText
- The text to be stored by the text property.
-
withText
With text. -
withText
With text.- Specified by:
withText
in interfaceTextAccessor.TextBuilder<B extends Text<B>>
- Parameters:
aText
- the text- Returns:
- the b
-
toString
TheString
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 interfaceTextAccessor.TextProvider
- Overrides:
toString
in classObject
- Returns:
- The according resulting
String
-
toString
Race condition safe shortcut for usingText.withText(String...)
followed byTextAccessor.TextProvider.toString()
. Implementation requirements: This method must not(!) be implemented by callingText.withText(String...)
followed byTextAccessor.TextProvider.toString()
(do not change the text property) as this would not be thread safe!
-