Package org.refcodes.textual
Class TextBlockBuilderImpl
- java.lang.Object
-
- org.refcodes.textual.TextBlockBuilderImpl
-
- All Implemented Interfaces:
org.refcodes.mixin.ColumnWidthAccessor
,org.refcodes.mixin.ColumnWidthAccessor.ColumnWidthBuilder<TextBlockBuilder>
,org.refcodes.mixin.ColumnWidthAccessor.ColumnWidthMutator
,org.refcodes.mixin.ColumnWidthAccessor.ColumnWidthProperty
,HorizAlignTextModeAccessor
,HorizAlignTextModeAccessor.HorizAlignTextModeBuilder<TextBlockBuilder>
,HorizAlignTextModeAccessor.HorizAlignTextModeMutator
,HorizAlignTextModeAccessor.HorizAlignTextModeProperty
,Text<TextBlockBuilder>
,TextAccessor
,TextAccessor.TextBuilder<Text<TextBlockBuilder>>
,TextAccessor.TextMutator
,TextAccessor.TextProperty
,TextAccessor.TextProvider
,TextBlockBuilder
public class TextBlockBuilderImpl extends java.lang.Object implements TextBlockBuilder
The Class TextBlockBuilderImpl.- 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
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.String
NO_SINGLE_LINE_CHARS
-
Constructor Summary
Constructors Constructor Description TextBlockBuilderImpl()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getColumnWidth()
HorizAlignTextMode
getHorizAlignTextMode()
Retrieves the horizontal align text mode from the horizontal align text mode property.SplitTextMode
getSplitTextMode()
Retrieves the split text mode from the split text mode property.java.lang.String[]
getText()
Retrieves the text from the text property.void
setColumnWidth(int aColumnWidth)
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
setText(java.lang.String... aText)
Sets the text for the text property.protected static java.lang.String
toNonBreakingLine(java.lang.String aText)
Creates a single line by replacing all new lines, line feeds and tabulators from the givenString
by full stops or spaces (heuristic) so that it is displayed in one single line.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()
.protected static java.lang.String[]
toTextBlock(java.lang.String aText, int aLength)
Cuts theString
into subString
instances with the maximum given length.protected static java.lang.String[]
toTextBlock(java.lang.String aText, int aLength, HorizAlignTextMode aHorizAlignTextMode)
Cuts theString
into subString
instances with the maximum given length.protected static java.lang.String[]
toTextBlock(java.lang.String aText, int aLength, HorizAlignTextMode aHorizAlignTextMode, SplitTextMode aLineSplitMode)
Cuts theString
into subString
instances with the maximum given length.protected static java.lang.String[]
toTextBlock(java.lang.String aText, int aLength, SplitTextMode aLineSplitMode)
Cuts theString
into subString
instances with the maximum given length.TextBlockBuilder
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 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
-
Methods inherited from interface org.refcodes.textual.TextBlockBuilder
withHorizAlignTextMode, withSplitTextMode
-
-
-
-
Method Detail
-
withColumnWidth
public TextBlockBuilder withColumnWidth(int aColumnWidth)
- 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
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.
-
getSplitTextMode
public SplitTextMode getSplitTextMode()
Retrieves the split text mode from the split text mode property.- Specified by:
getSplitTextMode
in interfaceTextBlockBuilder
- 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.- Specified by:
setSplitTextMode
in interfaceTextBlockBuilder
- Parameters:
aSplitTextMode
- The split text mode 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<TextBlockBuilder>
- Parameters:
aText
- The text to be processed.- Returns:
- The according resulting
String
array
-
toTextBlock
protected static java.lang.String[] toTextBlock(java.lang.String aText, int aLength)
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).aLength
- The maximum length of a line returned in theString
array.- Returns:
- A
String
array with the subString
instances.
-
toTextBlock
protected static java.lang.String[] toTextBlock(java.lang.String aText, int aLength, SplitTextMode aLineSplitMode)
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).aLength
- The maximum length of a line returned in theString
array.aLineSplitMode
- 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.
-
toTextBlock
protected static java.lang.String[] toTextBlock(java.lang.String aText, int aLength, HorizAlignTextMode aHorizAlignTextMode)
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).aLength
- 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.
-
toTextBlock
protected static java.lang.String[] toTextBlock(java.lang.String aText, int aLength, HorizAlignTextMode aHorizAlignTextMode, SplitTextMode aLineSplitMode)
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).aLength
- The maximum length of a line returned in theString
array.aHorizAlignTextMode
- TheHorizAlignTextMode
specifies on how a line is to be aligned in the result.aLineSplitMode
- 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.
-
toNonBreakingLine
protected static java.lang.String toNonBreakingLine(java.lang.String aText)
Creates a single line by replacing all new lines, line feeds and tabulators from the givenString
by full stops or spaces (heuristic) so that it is displayed in one single line.- Parameters:
aText
- TheString
from which to replace all characters responsible for line wrapping and stuff.- Returns:
- A
String
which will render in a single line.
-
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!
-
-