- java.lang.Object
-
- org.refcodes.textual.HorizAlignTextBuilder
-
- All Implemented Interfaces:
org.refcodes.mixin.ColumnWidthAccessor
,org.refcodes.mixin.ColumnWidthAccessor.ColumnWidthBuilder<HorizAlignTextBuilder>
,org.refcodes.mixin.ColumnWidthAccessor.ColumnWidthMutator
,org.refcodes.mixin.ColumnWidthAccessor.ColumnWidthProperty
,FillCharAccessor
,FillCharAccessor.FillCharBuilder<HorizAlignTextBuilder>
,FillCharAccessor.FillCharMutator
,FillCharAccessor.FillCharProperty
,HorizAlignTextModeAccessor
,HorizAlignTextModeAccessor.HorizAlignTextModeBuilder<HorizAlignTextBuilder>
,HorizAlignTextModeAccessor.HorizAlignTextModeMutator
,HorizAlignTextModeAccessor.HorizAlignTextModeProperty
,Text<HorizAlignTextBuilder>
,TextAccessor
,TextAccessor.TextBuilder<Text<HorizAlignTextBuilder>>
,TextAccessor.TextMutator
,TextAccessor.TextProperty
,TextAccessor.TextProvider
public class HorizAlignTextBuilder extends Object implements FillCharAccessor.FillCharProperty, FillCharAccessor.FillCharBuilder<HorizAlignTextBuilder>, org.refcodes.mixin.ColumnWidthAccessor.ColumnWidthBuilder<HorizAlignTextBuilder>, org.refcodes.mixin.ColumnWidthAccessor.ColumnWidthProperty, Text<HorizAlignTextBuilder>, HorizAlignTextModeAccessor.HorizAlignTextModeProperty, HorizAlignTextModeAccessor.HorizAlignTextModeBuilder<HorizAlignTextBuilder>
Fills a text up on by appending the given char to the left or to the the right or inbetween till the given length is reached. How the text is aligned depends on the setting of theHorizAlignTextMode
attribute.
-
-
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
-
-
Constructor Summary
Constructors Constructor Description HorizAlignTextBuilder()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static String[]
asAligned(String[] aText, int aColumnWidth, char aFillChar, HorizAlignTextMode aHorizAlignTextMode)
Fills a text up as of the providedHorizAlignTextMode
with the give fill character till the given length is reached.static String[]
asAligned(String[] aText, int aColumnWidth, char aFillChar, HorizAlignTextMode aHorizAlignTextMode, boolean hasAnsiEscapeCodes)
Fills a text up as of the providedHorizAlignTextMode
with the give fill character till the given length is reached.static String
asAligned(String aText, int aColumnWidth, char aFillChar, HorizAlignTextMode aHorizAlignTextMode)
Fills a text up as of the providedHorizAlignTextMode
with the give fill character till the given length is reached.static String
asAligned(String aText, int aColumnWidth, char aFillChar, HorizAlignTextMode aHorizAlignTextMode, boolean hasAnsiEscapeCodes)
Fills a text up as of the providedHorizAlignTextMode
with the give fill character till the given length is reached.static String
asAligned(String aText, int aColumnWidth, HorizAlignTextMode aHorizAlignTextMode)
Fills a text up as of the providedHorizAlignTextMode
with a space " " till the given length is reached.static String
asAligned(String aText, int aColumnWidth, HorizAlignTextMode aHorizAlignTextMode, boolean hasAnsiEscapeCodes)
Fills a text up as of the providedHorizAlignTextMode
with a space " " character till the given length is reached.int
getColumnWidth()
char
getFillChar()
Retrieves the fill char from the fill char property.HorizAlignTextMode
getHorizAlignTextMode()
Retrieves the horizontal align text mode from the horizontal align 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
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()
.HorizAlignTextBuilder
withColumnWidth(int aColumnWidth)
HorizAlignTextBuilder
withFillChar(char aFillChar)
Sets the fill char for the fill char property.HorizAlignTextBuilder
withHorizAlignTextMode(HorizAlignTextMode aHorizAlignTextMode)
Sets the align text mode for the align 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.FillCharAccessor.FillCharProperty
letFillChar
-
Methods inherited from interface org.refcodes.textual.HorizAlignTextModeAccessor.HorizAlignTextModeProperty
letHorizAlignTextMode
-
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
-
Methods inherited from interface org.refcodes.textual.TextAccessor.TextProvider
toString
-
-
-
-
Method Detail
-
withColumnWidth
public HorizAlignTextBuilder withColumnWidth(int aColumnWidth)
- Specified by:
withColumnWidth
in interfaceorg.refcodes.mixin.ColumnWidthAccessor.ColumnWidthBuilder<HorizAlignTextBuilder>
-
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
public void setHorizAlignTextMode(HorizAlignTextMode aHorizAlignTextMode)
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
public HorizAlignTextMode 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.
-
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.
-
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<HorizAlignTextBuilder>
- Parameters:
aText
- The text to be processed.- Returns:
- The according resulting
String
array
-
withHorizAlignTextMode
public HorizAlignTextBuilder withHorizAlignTextMode(HorizAlignTextMode aHorizAlignTextMode)
Sets the align text mode for the align text mode property.- Specified by:
withHorizAlignTextMode
in interfaceHorizAlignTextModeAccessor.HorizAlignTextModeBuilder<HorizAlignTextBuilder>
- Parameters:
aHorizAlignTextMode
- The align text mode to be stored by the align text mode property.- Returns:
- The builder for applying multiple build operations.
-
withFillChar
public HorizAlignTextBuilder withFillChar(char aFillChar)
Sets the fill char for the fill char property.- Specified by:
withFillChar
in interfaceFillCharAccessor.FillCharBuilder<HorizAlignTextBuilder>
- Parameters:
aFillChar
- The fill char to be stored by the fill char property.- Returns:
- The builder for applying multiple build operations.
-
asAligned
public static String asAligned(String aText, int aColumnWidth, HorizAlignTextMode aHorizAlignTextMode)
Fills a text up as of the providedHorizAlignTextMode
with a space " " till the given length is reached. 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 text to be filled up or aligned.aColumnWidth
- The length to be reached.aHorizAlignTextMode
- the horiz align text mode- Returns:
- A
String
filled up with the given char till the width is reached or theString
untouched in case noHorizAlignTextMode
parameter has been provided..
-
asAligned
public static String asAligned(String aText, int aColumnWidth, char aFillChar, HorizAlignTextMode aHorizAlignTextMode)
Fills a text up as of the providedHorizAlignTextMode
with the give fill character till the given length is reached. 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 text to be filled up or aligned.aColumnWidth
- The length to be reached.aFillChar
- The char to be used for filling upaHorizAlignTextMode
- the horiz align text mode- Returns:
- A
String
filled up with the given char till the width is reached or theString
untouched in case noHorizAlignTextMode
parameter has been provided..
-
asAligned
public static String[] asAligned(String[] aText, int aColumnWidth, char aFillChar, HorizAlignTextMode aHorizAlignTextMode)
Fills a text up as of the providedHorizAlignTextMode
with the give fill character till the given length is reached. 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 text array to be filled up or aligned.aColumnWidth
- The length to be reached.aFillChar
- The char to be used for filling upaHorizAlignTextMode
- the horiz align text mode- Returns:
- A
String
filled up with the given char till the width is reached or theString
untouched in case noHorizAlignTextMode
parameter has been provided..
-
asAligned
public static String asAligned(String aText, int aColumnWidth, HorizAlignTextMode aHorizAlignTextMode, boolean hasAnsiEscapeCodes)
Fills a text up as of the providedHorizAlignTextMode
with a space " " character till the given length is reached.- Parameters:
aText
- The text to be filled up or aligned.aColumnWidth
- The length to be reached.aHorizAlignTextMode
- the horiz align text modehasAnsiEscapeCodes
- Whether to take any (non printable) ANSI escape codes into account which would, when not being considered, cause wrong results.- Returns:
- A
String
filled up with the given char till the width is reached or theString
untouched in case noHorizAlignTextMode
parameter has been provided..
-
asAligned
public static String asAligned(String aText, int aColumnWidth, char aFillChar, HorizAlignTextMode aHorizAlignTextMode, boolean hasAnsiEscapeCodes)
Fills a text up as of the providedHorizAlignTextMode
with the give fill character till the given length is reached.- Parameters:
aText
- The text to be filled up or aligned.aColumnWidth
- The length to be reached.aFillChar
- The char to be used for filling upaHorizAlignTextMode
- the horiz align text modehasAnsiEscapeCodes
- Whether to take any (non printable) ANSI escape codes into account which would, when not being considered, cause wrong results.- Returns:
- A
String
filled up with the given char till the width is reached or theString
untouched in case noHorizAlignTextMode
parameter has been provided..
-
asAligned
public static String[] asAligned(String[] aText, int aColumnWidth, char aFillChar, HorizAlignTextMode aHorizAlignTextMode, boolean hasAnsiEscapeCodes)
Fills a text up as of the providedHorizAlignTextMode
with the give fill character till the given length is reached.- Parameters:
aText
- The text array to be filled up or aligned.aColumnWidth
- The length to be reached.aFillChar
- The char to be used for filling upaHorizAlignTextMode
- the horiz align text modehasAnsiEscapeCodes
- Whether to take any (non printable) ANSI escape codes into account which would, when not being considered, cause wrong results.- Returns:
- A
String
filled up with the given char till the width is reached or theString
untouched in case noHorizAlignTextMode
parameter has been provided..
-
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()
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
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!
-
-