java.lang.Object
org.refcodes.textual.ReplaceTextBuilder
- All Implemented Interfaces:
Text<ReplaceTextBuilder>
,TextAccessor
,TextAccessor.TextBuilder<Text<ReplaceTextBuilder>>
,TextAccessor.TextMutator
,TextAccessor.TextProperty
,TextAccessor.TextProvider
Plain find/replace utility not(!) using regular expressions.
-
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
-
Method Summary
Modifier and TypeMethodDescriptionstatic String[]
asReplaced
(String[] aText, String aFindText, String aReplaceText) Replaces a text by an other text in aString
array.static String
asReplaced
(String aText, String aFindText, String aReplaceText) Retrieves the find text from the find text property.Retrieves the replace text from the replace text property.String[]
getText()
Retrieves the text from the text property.void
setFindText
(String aFindText) Sets the find text for the find text property.void
setReplaceText
(String aReplaceText) Sets the replace text for the replace text property.void
Sets the text for the text property.toString()
TheString
being build by the builder upon the settings of the attributes.Race condition safe shortcut for usingText.withText(String...)
followed byTextAccessor.TextProvider.toString()
.String[]
TheString
s being build by the builder upon the settings of the attributes.String[]
Race condition safe shortcut for usingText.withText(String...)
followed byTextAccessor.TextProvider.toStrings()
.withFindText
(String aFindText) Sets the find text for the find text property.withReplaceText
(String aReplaceText) Sets the replace text for the replace text property.With text.withText
(Collection<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.TextMutator
setText
Methods inherited from interface org.refcodes.textual.TextAccessor.TextProperty
letText, letText
-
Constructor Details
-
ReplaceTextBuilder
public ReplaceTextBuilder()
-
-
Method Details
-
getReplaceText
Retrieves the replace text from the replace text property.- Returns:
- The replace text stored by the replace text property.
-
setReplaceText
Sets the replace text for the replace text property.- Parameters:
aReplaceText
- The replace text to be stored by the text align mode property.
-
getFindText
Retrieves the find text from the find text property.- Returns:
- The find text stored by the find text property.
-
setFindText
Sets the find text for the find text property.- Parameters:
aFindText
- The find text to be stored by the text align mode property.
-
toStrings
TheString
s being build by the builder upon the settings of the attributes.- 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!- Parameters:
aText
- The text to be processed.- Returns:
- The according resulting
String
array
-
withReplaceText
Sets the replace text for the replace text property.- Parameters:
aReplaceText
- The replace text to be stored by the text align mode property.- Returns:
- The builder for applying multiple build operations.
-
withFindText
Sets the find text for the find text property.- Parameters:
aFindText
- The find text to be stored by the text align mode property.- Returns:
- The builder for applying multiple build operations.
-
asReplaced
Replaces a text by an other text in aString
array.- Parameters:
aText
- The text to be processed ('find-and-replace').aFindText
- The text which has to be replaced.aReplaceText
- The text that replaces the original.- Returns:
- The number of replacements done.
-
asReplaced
-
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. -
withText
With text.- Specified by:
withText
in interfaceTextAccessor.TextBuilder<B extends Text<B>>
- Parameters:
aText
- the text- Returns:
- the b
-
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 classObject
- Returns:
- The according resulting
String
-
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!
-