Package org.refcodes.textual
Class TruncateTextBuilderImpl
- java.lang.Object
-
- org.refcodes.textual.TruncateTextBuilderImpl
-
- All Implemented Interfaces:
Text<TruncateTextBuilder>
,TextAccessor
,TextAccessor.TextBuilder<TruncateTextBuilder>
,TextAccessor.TextMutator
,TextAccessor.TextProperty
,TextAccessor.TextProvider
,TruncateTextBuilder
public class TruncateTextBuilderImpl extends java.lang.Object implements TruncateTextBuilder
The Class TruncateTextBuilderImpl.- Author:
- steiner
-
-
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
-
-
Constructor Summary
Constructors Constructor Description TruncateTextBuilderImpl()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static void
doStrip(java.lang.StringBuffer aStringBuffer, char aChar)
Removes all leading and trailing chars identical with specified char ch.protected static void
doStripLeft(java.lang.StringBuffer aStringBuffer, char aChar)
Removes all leading chars identical with specified char.protected static void
doStripRight(java.lang.StringBuffer aStringBuffer, char aChar)
Removes all rear chars identical with specified char ch.java.lang.String[]
getText()
Retrieves the text from the text property.char[]
getTruncateChars()
Retrieves the truncate chars from the truncate chars property.TruncateTextMode
getTruncateTextMode()
Retrieves the truncate text mode from the truncate text mode property.void
setText(java.lang.String... aText)
Sets the text for the text property.void
setTruncateChars(char... aStripChars)
Sets the truncate chars for the truncate chars property.void
setTruncateTextMode(TruncateTextMode aTruncateTextMode)
Sets the truncate text mode for the truncate text mode property.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
toStrip(java.lang.String aText, char[] aChars)
Returns a new String without leading nor trailing chars.protected static java.lang.String
toStrip(java.lang.String aText, char[] aChars, TruncateTextMode aTruncateTextMode)
To strip.protected static java.lang.String
toStripLeft(java.lang.String aText, char[] aChars)
Returns a new String without leading chars.protected static java.lang.String
toStripRight(java.lang.String aText, char[] aChars)
Returns a new String without trailing chars.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.TruncateTextBuilder
toString, withStripChars, withText, withTruncateTextMode
-
-
-
-
Method Detail
-
getTruncateTextMode
public TruncateTextMode getTruncateTextMode()
Retrieves the truncate text mode from the truncate text mode property.- Specified by:
getTruncateTextMode
in interfaceTruncateTextBuilder
- Returns:
- The truncate text mode stored by the truncate text mode property.
-
setTruncateTextMode
public void setTruncateTextMode(TruncateTextMode aTruncateTextMode)
Sets the truncate text mode for the truncate text mode property.- Specified by:
setTruncateTextMode
in interfaceTruncateTextBuilder
- 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.- Specified by:
getTruncateChars
in interfaceTruncateTextBuilder
- Returns:
- The truncate chars stored by the truncate chars property.
-
setTruncateChars
public void setTruncateChars(char... aStripChars)
Sets the truncate chars for the truncate chars property.- Specified by:
setTruncateChars
in interfaceTruncateTextBuilder
- Parameters:
aStripChars
- The truncate chars to be stored by the text align 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
- Specified by:
toStrings
in interfaceTruncateTextBuilder
- 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<TruncateTextBuilder>
- Parameters:
aText
- The text to be processed.- Returns:
- The according resulting
String
array
-
toStrip
protected static java.lang.String toStrip(java.lang.String aText, char[] aChars, TruncateTextMode aTruncateTextMode)
To strip.- Parameters:
aText
- the textaChars
- the charsaTruncateTextMode
- the truncate text mode- Returns:
- the string
-
doStripLeft
protected static void doStripLeft(java.lang.StringBuffer aStringBuffer, char aChar)
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.
-
toStripLeft
protected static java.lang.String toStripLeft(java.lang.String aText, char[] aChars)
Returns a new String without leading chars.- Parameters:
aText
- The text to be stripped.aChars
- the chars- Returns:
- The stripped text.
-
doStripRight
protected static void doStripRight(java.lang.StringBuffer aStringBuffer, char aChar)
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
protected static void doStrip(java.lang.StringBuffer aStringBuffer, char aChar)
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.
-
toStripRight
protected static java.lang.String toStripRight(java.lang.String aText, char[] aChars)
Returns a new String without trailing chars.- Parameters:
aText
- Description is currently not available!aChars
- the chars- Returns:
- Description is currently not available!
-
toStrip
protected static java.lang.String toStrip(java.lang.String aText, char[] aChars)
Returns a new String without leading nor trailing chars.- Parameters:
aText
- The text to be stripped.aChars
- the chars- Returns:
- The stripped text.
-
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!
-
-