java.lang.Object
org.refcodes.textual.TruncateTextBuilder
- All Implemented Interfaces:
org.refcodes.mixin.TruncateModeAccessor
,org.refcodes.mixin.TruncateModeAccessor.TruncateModeBuilder<TruncateTextBuilder>
,org.refcodes.mixin.TruncateModeAccessor.TruncateModeMutator
,org.refcodes.mixin.TruncateModeAccessor.TruncateModeProperty
,Text<TruncateTextBuilder>
,TextAccessor
,TextAccessor.TextBuilder<Text<TruncateTextBuilder>>
,TextAccessor.TextMutator
,TextAccessor.TextProperty
,TextAccessor.TextProvider
public class TruncateTextBuilder extends Object implements Text<TruncateTextBuilder>, org.refcodes.mixin.TruncateModeAccessor.TruncateModeProperty, org.refcodes.mixin.TruncateModeAccessor.TruncateModeBuilder<TruncateTextBuilder>
Strips given characters from text's left hand side or right hand side or
both.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.refcodes.textual.TextAccessor
TextAccessor.TextBuilder<B extends TextAccessor.TextBuilder<B>>, TextAccessor.TextMutator, TextAccessor.TextProperty, TextAccessor.TextProvider
Nested classes/interfaces inherited from interface org.refcodes.mixin.TruncateModeAccessor
org.refcodes.mixin.TruncateModeAccessor.TruncateModeBuilder<B extends org.refcodes.mixin.TruncateModeAccessor.TruncateModeBuilder<B>>, org.refcodes.mixin.TruncateModeAccessor.TruncateModeMutator, org.refcodes.mixin.TruncateModeAccessor.TruncateModeProperty
-
Constructor Summary
Constructors Constructor Description TruncateTextBuilder()
-
Method Summary
Modifier and Type Method Description static String
asTruncated(String aText, org.refcodes.mixin.TruncateMode aTruncateTextMode)
Returns a newString
without the according leading and/or trailing whitespaces as ofCharSet.WHITE_SPACES
.static String
asTruncated(String aText, org.refcodes.mixin.TruncateMode aTruncateTextMode, char... aChars)
Returns a newString
without the according leading and/or trailing chars.static String
asTruncatedLeft(String aText)
Returns a newString
without the according leading whitespaces as ofCharSet.WHITE_SPACES
.static String
asTruncatedLeft(String aText, char... aChars)
Returns a newString
without the according leading chars.static String
asTruncatedRight(String aText)
Returns a newString
without the according trailing whitespaces as ofCharSet.WHITE_SPACES
.static String
asTruncatedRight(String aText, char... aChars)
Returns a newString
without the according trailing chars.protected static void
doStrip(StringBuffer aStringBuffer, char aChar)
Removes all leading and trailing chars identical with specified char ch.protected static void
doStripLeft(StringBuffer aStringBuffer, char aChar)
Removes all leading chars identical with specified char.protected static void
doStripRight(StringBuffer aStringBuffer, char aChar)
Removes all rear chars identical with specified char ch.String[]
getText()
Retrieves the text from the text property.char[]
getTruncateChars()
Retrieves the truncate chars from the truncate chars property.org.refcodes.mixin.TruncateMode
getTruncateMode()
Retrieves the truncate text mode from the truncate text mode property.void
setText(String... aText)
Sets the text for the text property.void
setTruncateChars(char... aTruncateChars)
Sets the truncate chars for the truncate chars property.void
setTruncateMode(org.refcodes.mixin.TruncateMode aTruncateTextMode)
Sets the truncate text mode for the truncate text mode 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()
.protected static String
toStrip(String aText, char[] aChars)
Returns a new String without leading nor trailing chars.TruncateTextBuilder
withStripChars(char... aStripChars)
Sets the truncate chars for the truncate chars property.TruncateTextBuilder
withText(String... aTextLines)
Sets theString
array for the text property.TruncateTextBuilder
withText(Collection<String> aText)
With text.TruncateTextBuilder
withTruncateMode(org.refcodes.mixin.TruncateMode aTruncateTextMode)
Sets the truncate text mode for the truncate text mode property.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.TextProperty
letText, letText
Methods inherited from interface org.refcodes.mixin.TruncateModeAccessor.TruncateModeProperty
letTruncateMode
-
Constructor Details
-
TruncateTextBuilder
public TruncateTextBuilder()
-
-
Method Details
-
getTruncateMode
public org.refcodes.mixin.TruncateMode getTruncateMode()Retrieves the truncate text mode from the truncate text mode property.- Specified by:
getTruncateMode
in interfaceorg.refcodes.mixin.TruncateModeAccessor
- Returns:
- The truncate text mode stored by the truncate text mode property.
-
setTruncateMode
public void setTruncateMode(org.refcodes.mixin.TruncateMode aTruncateTextMode)Sets the truncate text mode for the truncate text mode property.- Specified by:
setTruncateMode
in interfaceorg.refcodes.mixin.TruncateModeAccessor.TruncateModeMutator
- Parameters:
aTruncateTextMode
- The truncate text mode to be stored by the truncate text mode property.
-
getTruncateChars
public char[] getTruncateChars()Retrieves the truncate chars from the truncate chars property.- Returns:
- The truncate chars stored by the truncate chars property.
-
setTruncateChars
public void setTruncateChars(char... aTruncateChars)Sets the truncate chars for the truncate chars property.- Parameters:
aTruncateChars
- The truncate chars to be stored by the text align mode property.
-
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
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<TruncateTextBuilder>
- Parameters:
aText
- The text to be processed.- Returns:
- The according resulting
String
array
-
withTruncateMode
Sets the truncate text mode for the truncate text mode property.- Specified by:
withTruncateMode
in interfaceorg.refcodes.mixin.TruncateModeAccessor.TruncateModeBuilder<TruncateTextBuilder>
- Parameters:
aTruncateTextMode
- The truncate text mode to be stored by the truncate text mode property.- Returns:
- The builder for applying multiple build operations.
-
withText
Sets theString
array for the text property.- Specified by:
withText
in interfaceText<TruncateTextBuilder>
- Specified by:
withText
in interfaceTextAccessor.TextBuilder<Text<TruncateTextBuilder>>
- Parameters:
aTextLines
- TheString
array be stored by the text property.- Returns:
- The builder for applying multiple build operations.
-
withStripChars
Sets the truncate chars for the truncate chars property.- Parameters:
aStripChars
- The truncate chars to be stored by the text align mode property.- Returns:
- The builder for applying multiple build operations.
-
toString
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 thewithText(String...)
orTextAccessor.TextMutator.setText(String...)
methods.
-
asTruncated
Returns a newString
without the according leading and/or trailing whitespaces as ofCharSet.WHITE_SPACES
.- Parameters:
aText
- The text to truncate.aTruncateTextMode
- TheTruncateMode
describes how to truncate (left, right or both).- Returns:
- The accordingly truncated
String
.
-
asTruncated
public static String asTruncated(String aText, org.refcodes.mixin.TruncateMode aTruncateTextMode, char... aChars)Returns a newString
without the according leading and/or trailing chars.- Parameters:
aText
- The text to truncate.aTruncateTextMode
- TheTruncateMode
describes how to truncate (left, right or both).aChars
- the chars to detect when truncating.- Returns:
- The accordingly truncated
String
.
-
asTruncatedLeft
Returns a newString
without the according leading whitespaces as ofCharSet.WHITE_SPACES
.- Parameters:
aText
- The text to truncate.- Returns:
- The accordingly truncated
String
.
-
asTruncatedLeft
Returns a newString
without the according leading chars.- Parameters:
aText
- The text to be stripped.aChars
- the chars- Returns:
- The stripped text.
-
asTruncatedRight
Returns a newString
without the according trailing whitespaces as ofCharSet.WHITE_SPACES
.- Parameters:
aText
- The text to truncate.- Returns:
- The accordingly truncated
String
.
-
asTruncatedRight
Returns a newString
without the according trailing chars.- Parameters:
aText
- The text to truncate.aChars
- the chars to detect when truncating.- Returns:
- The accordingly truncated
String
.
-
doStripLeft
Removes all leading chars identical with specified char. E.g. if str=AAABBBAAABBB and ch=A the returnedString
will be BBBAAABBB.- Parameters:
aStringBuffer
- StringBuffer to modify.aChar
- Char to remove.
-
doStripRight
Removes all rear chars identical with specified char ch. E.g. if str=AAABBBAAABBB and ch=B str will become AAABBBAAA.- Parameters:
aStringBuffer
- StringBuffer to modify.aChar
- Char to remove.
-
doStrip
Removes all leading and trailing chars identical with specified char ch. E.g. if str=BAABBBAAABBB and ch=B str will become AABBBAAA.- Parameters:
aStringBuffer
- StringBuffer to modify.aChar
- Char to remove.
-
toStrip
Returns a new String without leading nor trailing chars.- Parameters:
aText
- The text to be stripped.aChars
- the chars- Returns:
- The stripped text.
-
getText
Retrieves the text from the text property.- Specified by:
getText
in interfaceTextAccessor
- Returns:
- The text stored by the text property.
-
setText
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
With text.- Specified by:
withText
in interfaceTextAccessor.TextBuilder<B extends Text<B>>
- Parameters:
aText
- the text- Returns:
- the b
-
toString
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!
-