- 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 givenMoreTextMode
applied.
-
-
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.TextAccessor
TextAccessor.TextBuilder<B extends TextAccessor.TextBuilder<B>>, TextAccessor.TextMutator, TextAccessor.TextProperty, TextAccessor.TextProvider
-
-
Constructor Summary
Constructors Constructor Description MoreTextBuilder()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static String[]
asMoreText(String[] aText, int aLength, String aMore, MoreTextMode aMoreTextMode)
The text array is "mored" depending on the providedMoreTextMode
.static String[]
asMoreText(String[] aText, int aLength, String aMore, MoreTextMode aMoreTextMode, boolean hasAnsiEscapeCodes)
The text array is "mored" depending on the providedMoreTextMode
.static String
asMoreText(String aText, int aLength, String aMore, MoreTextMode aMoreTextMode)
The text is "mored" depending on the providedMoreTextMode
.static String
asMoreText(String aText, int aLength, String aMore, MoreTextMode aMoreTextMode, boolean hasAnsiEscapeCodes)
The text is "mored" depending on the providedMoreTextMode
.int
getColumnWidth()
String
getMoreText()
Retrieves the more text from the more text property.MoreTextMode
getMoreTextMode()
Retrieves the more text mode from the more text mode property.String[]
getText()
Retrieves the text from the text property.void
setColumnWidth(int aColumnWidth)
void
setMoreText(String aMoreText)
Sets the more text for the more text property.void
setMoreTextMode(MoreTextMode aMoreTextMode)
Sets the more text mode for the more text mode property.void
setText(String... aText)
Sets the text for the text property.String
toString()
TheString
being build by the builder upon the settings of the attributes.String
toString(String... aText)
Race condition safe shortcut for usingText.withText(String...)
followed byTextAccessor.TextProvider.toString()
.String[]
toStrings()
TheString
s being build by the builder upon the settings of the attributes.String[]
toStrings(String... aText)
Race condition safe shortcut for usingText.withText(String...)
followed byTextAccessor.TextProvider.toStrings()
.MoreTextBuilder
withColumnWidth(int aColumnWidth)
MoreTextBuilder
withMoreText(String aMoreText)
Sets the more text for the more text property.MoreTextBuilder
withMoreTextMode(MoreTextMode aMoreTextMode)
Sets the more text mode for the more text mode property.B
withText(String... aText)
With text.B
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.TextAccessor
getText
-
Methods inherited from interface org.refcodes.textual.TextAccessor.TextBuilder
withText
-
Methods inherited from interface org.refcodes.textual.TextAccessor.TextMutator
setText, setText
-
Methods inherited from interface org.refcodes.textual.TextAccessor.TextProperty
letText, letText
-
-
-
-
Method Detail
-
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 interfaceorg.refcodes.mixin.ColumnWidthAccessor
-
setColumnWidth
public void setColumnWidth(int aColumnWidth)
- Specified by:
setColumnWidth
in interfaceorg.refcodes.mixin.ColumnWidthAccessor.ColumnWidthMutator
-
withColumnWidth
public MoreTextBuilder withColumnWidth(int aColumnWidth)
- Specified by:
withColumnWidth
in interfaceorg.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()
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
public String[] toStrings(String... aText)
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<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
TheString
being build by the builder upon the settings of the attributes.- Specified by:
toString
in interfaceTextAccessor.TextProvider
- Returns:
- The according resulting
String
- Throws:
IllegalStateException
- Thrown in case more than one text line has been set via theText.withText(String...)
orTextAccessor.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 providedMoreTextMode
. It is assumed that the text does not contain any ANSI escape codes, elseasMoreText(String[], int, String, MoreTextMode, boolean)
In case it isMoreTextMode.NONE
, then the text is returned untouched. In case it isMoreTextMode.LEFT
, then the text is "mored" to the left. In case it isMoreTextMode.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
- TheMoreTextMode
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 providedMoreTextMode
. In case it isMoreTextMode.NONE
, then the text is returned untouched. In case it isMoreTextMode.LEFT
, then the text is "mored" to the left. In case it isMoreTextMode.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
- TheMoreTextMode
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 providedMoreTextMode
. It is assumed that the text does not contain any ANSI escape codes, elseasMoreText(String, int, String, MoreTextMode, boolean)
In case it isMoreTextMode.NONE
, then the text is returned untouched. In case it isMoreTextMode.LEFT
, then the text is "mored" to the left. In case it isMoreTextMode.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
- TheMoreTextMode
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 providedMoreTextMode
. In case it isMoreTextMode.NONE
, then the text is returned untouched. In case it isMoreTextMode.LEFT
, then the text is "mored" to the left. In case it isMoreTextMode.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
- TheMoreTextMode
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 interfaceTextAccessor
- 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 interfaceTextAccessor.TextMutator
- Parameters:
aText
- The text to be stored by the text property.
-
withText
public B withText(String... aText)
With text.
-
withText
public B withText(Collection<String> aText)
With text.- Specified by:
withText
in interfaceTextAccessor.TextBuilder<B extends Text<B>>
- Parameters:
aText
- the text- Returns:
- the b
-
toString
public String toString(String... aText)
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!
-
-