Package org.refcodes.textual
Class HorizAlignTextBuilderImpl
- java.lang.Object
-
- org.refcodes.textual.HorizAlignTextBuilderImpl
-
- All Implemented Interfaces:
org.refcodes.mixin.ColumnWidthAccessor
,org.refcodes.mixin.ColumnWidthAccessor.ColumnWidthBuilder<HorizAlignTextBuilder>
,org.refcodes.mixin.ColumnWidthAccessor.ColumnWidthMutator
,org.refcodes.mixin.ColumnWidthAccessor.ColumnWidthProperty
,HorizAlignTextBuilder
,HorizAlignTextModeAccessor
,HorizAlignTextModeAccessor.HorizAlignTextModeBuilder<HorizAlignTextBuilder>
,HorizAlignTextModeAccessor.HorizAlignTextModeMutator
,HorizAlignTextModeAccessor.HorizAlignTextModeProperty
,Text<HorizAlignTextBuilder>
,TextAccessor
,TextAccessor.TextBuilder<Text<HorizAlignTextBuilder>>
,TextAccessor.TextMutator
,TextAccessor.TextProperty
,TextAccessor.TextProvider
public class HorizAlignTextBuilderImpl extends java.lang.Object implements HorizAlignTextBuilder
The Class HorizAlignTextBuilderImpl.- Author:
- steiner
-
-
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.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 HorizAlignTextBuilderImpl()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.java.lang.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(java.lang.String... aText)
Sets the text for the text property.protected static java.lang.String[]
toAlign(java.lang.String[] aText, int aLength, char aFillChar, HorizAlignTextMode aHorizAlignTextMode)
To align.protected static java.lang.String
toAlign(java.lang.String aText, int aLength, char aFillChar, HorizAlignTextMode aHorizAlignTextMode)
Fills a text up on by appending the given char to the left and the right till the given length is reached.protected static java.lang.String
toAlignBlock(java.lang.String aText, int aLength, char aFillChar)
Fills a text up on by adding the given char to occurrences of the given char round robin till given length is reached (block mode).protected static java.lang.String
toAlignCenter(java.lang.String aText, int aLength, char aFillChar)
Fills a text up on by appending the given char to the left and the right till the given length is reached (align center).protected static java.lang.String
toAlignLeft(java.lang.String aText, int aLength, char aFillChar)
Fills a text up on by appending the given char to the right till the given length is reached (align left).protected static java.lang.String
toAlignRight(java.lang.String aText, int aLength, char aFillChar)
Fills a text up by prepending the given char to the left till the given length is reached (align right).java.lang.String
toString()
TheString
being build by the builder upon the settings of the attributes.java.lang.String
toString(java.lang.String... aText)
Race condition safe shortcut for usingText.withText(String...)
followed byTextAccessor.TextProvider.toString()
.java.lang.String[]
toStrings()
TheString
s being build by the builder upon the settings of the attributes.java.lang.String[]
toStrings(java.lang.String... aText)
Race condition safe shortcut for usingText.withText(String...)
followed byTextAccessor.TextProvider.toStrings()
.HorizAlignTextBuilder
withColumnWidth(int aColumnWidth)
B
withText(java.lang.String... aText)
With text.B
withText(java.util.Collection<java.lang.String> aText)
With text.-
Methods inherited from interface org.refcodes.textual.HorizAlignTextBuilder
withFillChar, withHorizAlignTextMode
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
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.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 interfaceHorizAlignTextBuilder
- 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 interfaceHorizAlignTextBuilder
- Parameters:
aFillChar
- The fill char to be stored by the align text mode property.
-
toStrings
public java.lang.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 java.lang.String[] toStrings(java.lang.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
-
toAlign
protected static java.lang.String toAlign(java.lang.String aText, int aLength, char aFillChar, HorizAlignTextMode aHorizAlignTextMode)
Fills a text up on by appending the given char to the left and the right till the given length is reached.- Parameters:
aText
- The text to be filled up or aligned.aLength
- 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..
-
toAlignLeft
protected static java.lang.String toAlignLeft(java.lang.String aText, int aLength, char aFillChar)
Fills a text up on by appending the given char to the right till the given length is reached (align left).- Parameters:
aText
- The text to be filled up.aLength
- The length to be reached.aFillChar
- The char to be used for filling up- Returns:
- A
String
filled up on the right hand side with the given char.
-
toAlignRight
protected static java.lang.String toAlignRight(java.lang.String aText, int aLength, char aFillChar)
Fills a text up by prepending the given char to the left till the given length is reached (align right).- Parameters:
aText
- The text to be filled up.aLength
- The length to be reached.aFillChar
- The char to be used for filling up- Returns:
- A
String
filled up on the left hand side with the given char.
-
toAlignCenter
protected static java.lang.String toAlignCenter(java.lang.String aText, int aLength, char aFillChar)
Fills a text up on by appending the given char to the left and the right till the given length is reached (align center).- Parameters:
aText
- The text to be filled up.aLength
- The length to be reached.aFillChar
- The char to be used for filling up- Returns:
- A
String
filled up on the left and right hand side with the given char.
-
toAlignBlock
protected static java.lang.String toAlignBlock(java.lang.String aText, int aLength, char aFillChar)
Fills a text up on by adding the given char to occurrences of the given char round robin till given length is reached (block mode).- Parameters:
aText
- The text to be filled up.aLength
- The length to be reached.aFillChar
- The char to be used for filling up- Returns:
- A
String
filled up in block mode with the given char.
-
toAlign
protected static java.lang.String[] toAlign(java.lang.String[] aText, int aLength, char aFillChar, HorizAlignTextMode aHorizAlignTextMode)
To align.- Parameters:
aText
- the textaLength
- the lengthaFillChar
- the fill charaHorizAlignTextMode
- the horiz align text mode- Returns:
- the string[]
- See Also:
except applied to arrays.
-
getText
public java.lang.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(java.lang.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(java.lang.String... aText)
With text.
-
withText
public B withText(java.util.Collection<java.lang.String> aText)
With text.- Specified by:
withText
in interfaceTextAccessor.TextBuilder<B extends Text<B>>
- Parameters:
aText
- the text- Returns:
- the b
-
toString
public java.lang.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 classjava.lang.Object
- Returns:
- The according resulting
String
-
toString
public java.lang.String toString(java.lang.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!
-
-