Package org.refcodes.textual
Class MoreTextBuilderImpl
- java.lang.Object
-
- org.refcodes.textual.MoreTextBuilderImpl
-
- All Implemented Interfaces:
org.refcodes.mixin.ColumnWidthAccessor
,org.refcodes.mixin.ColumnWidthAccessor.ColumnWidthBuilder<MoreTextBuilder>
,org.refcodes.mixin.ColumnWidthAccessor.ColumnWidthMutator
,org.refcodes.mixin.ColumnWidthAccessor.ColumnWidthProperty
,MoreTextBuilder
,Text<MoreTextBuilder>
,TextAccessor
,TextAccessor.TextBuilder<MoreTextBuilder>
,TextAccessor.TextMutator
,TextAccessor.TextProperty
,TextAccessor.TextProvider
public class MoreTextBuilderImpl extends java.lang.Object implements MoreTextBuilder
Implementation of theMoreTextBuilder
;.
-
-
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 MoreTextBuilderImpl()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getColumnWidth()
java.lang.String
getMoreText()
Retrieves the more text from the more text property.MoreTextMode
getMoreTextMode()
Retrieves the more text mode from the more text mode property.java.lang.String[]
getText()
Retrieves the text from the text property.void
setColumnWidth(int aColumnWidth)
void
setMoreText(java.lang.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(java.lang.String... aText)
Sets the text for the text property.protected static java.lang.String[]
toMore(java.lang.String[] aText, int aLength, java.lang.String aMore, MoreTextMode aMoreTextMode)
To more.protected static java.lang.String
toMore(java.lang.String aText, int aLength, java.lang.String aMore, MoreTextMode aMoreTextMode)
the text is "mored" depending on the providedMoreTextMode
.protected static java.lang.String
toMoreCenter(java.lang.String aText, int aLength, java.lang.String aMore)
Truncates a text by cutting the text from left to the right and from right to left one by one to reach the given length.protected static java.lang.String
toMoreLeft(java.lang.String aText, int aLength, java.lang.String aMore)
Truncates a text by cutting the text from left to the right to reach the given length.protected static java.lang.String
toMoreRight(java.lang.String aText, int aLength, java.lang.String aMore)
Truncates a text by cutting the text from left to the right to reach the given length.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()
.MoreTextBuilder
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.MoreTextBuilder
toString, withMoreText, withMoreTextMode
-
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
-
-
-
-
Method Detail
-
getMoreText
public java.lang.String getMoreText()
Retrieves the more text from the more text property.- Specified by:
getMoreText
in interfaceMoreTextBuilder
- Returns:
- The more text stored by the more text property.
-
setMoreText
public void setMoreText(java.lang.String aMoreText)
Sets the more text for the more text property.- Specified by:
setMoreText
in interfaceMoreTextBuilder
- 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>
- Specified by:
withColumnWidth
in interfaceMoreTextBuilder
-
getMoreTextMode
public MoreTextMode getMoreTextMode()
Retrieves the more text mode from the more text mode property.- Specified by:
getMoreTextMode
in interfaceMoreTextBuilder
- 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.- Specified by:
setMoreTextMode
in interfaceMoreTextBuilder
- Parameters:
aMoreTextMode
- The more text mode to be stored by the more 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 interfaceMoreTextBuilder
- 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<MoreTextBuilder>
- Parameters:
aText
- The text to be processed.- Returns:
- The according resulting
String
array
-
toMore
protected static java.lang.String[] toMore(java.lang.String[] aText, int aLength, java.lang.String aMore, MoreTextMode aMoreTextMode)
To more.- Parameters:
aText
- the textaLength
- the lengthaMore
- the moreaMoreTextMode
- the more text mode- Returns:
- the string[]
-
toMore
protected static java.lang.String toMore(java.lang.String aText, int aLength, java.lang.String aMore, MoreTextMode aMoreTextMode)
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" by thetoMoreLeft(String, int, String)
method. In case it isMoreTextMode.RIGHT
, then the text is "mored" by thetoMoreRight(String, int, String)
method.- 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.- Returns:
- The accordingly "mored" text.
-
toMoreLeft
protected static java.lang.String toMoreLeft(java.lang.String aText, int aLength, java.lang.String aMore)
Truncates a text by cutting the text from left to the right to reach the given length. If the text is shorter, then the text is returned. In case the text is longer than the required length, then the more text (e.g. "...") is prepended to indicate that text has been cut off, altogether being of the required length.- 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.- Returns:
- A
String
, when being longer than the provided length, which is being truncated and prepended with the given more (e.g. "...") text, altogether being of the required length.
-
toMoreRight
protected static java.lang.String toMoreRight(java.lang.String aText, int aLength, java.lang.String aMore)
Truncates a text by cutting the text from left to the right to reach the given length. If the text is shorter, then the text is returned. In case the text is longer than the required length, then the more text (e.g. "...") is prepended to indicate that text has been cut off, altogether being of the required length.- 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.- Returns:
- A
String
, when being longer than the provided length, which is being truncated and prepended with the given more (e.g. "...") text, altogether being of the required length.
-
toMoreCenter
protected static java.lang.String toMoreCenter(java.lang.String aText, int aLength, java.lang.String aMore)
Truncates a text by cutting the text from left to the right and from right to left one by one to reach the given length. If the text is shorter, then the text is returned. In case the text is longer than the required length, then the more text (e.g. "...") is prepended to indicate that text has been cut off, altogether being of the required length.- 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.- Returns:
- A
String
, when being longer than the provided length, which is being truncated and prepended with the given more (e.g. "...") text, altogether being of the required length.
-
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!
-
-