Package org.refcodes.textual
Class ReplaceTextBuilderImpl
- java.lang.Object
-
- org.refcodes.textual.ReplaceTextBuilderImpl
-
- All Implemented Interfaces:
ReplaceTextBuilder
,Text<ReplaceTextBuilder>
,TextAccessor
,TextAccessor.TextBuilder<ReplaceTextBuilder>
,TextAccessor.TextMutator
,TextAccessor.TextProperty
,TextAccessor.TextProvider
public class ReplaceTextBuilderImpl extends java.lang.Object implements ReplaceTextBuilder
The Class ReplaceTextBuilderImpl.- 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 ReplaceTextBuilderImpl()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getFindText()
Retrieves the find text from the find text property.java.lang.String
getReplaceText()
Retrieves the replace text from the replace text property.java.lang.String[]
getText()
Retrieves the text from the text property.void
setFindText(java.lang.String aFindText)
Sets the find text for the find text property.void
setReplaceText(java.lang.String aReplaceText)
Sets the replace text for the replace text property.void
setText(java.lang.String... aText)
Sets the text for the text property.protected static java.lang.String[]
toReplaced(java.lang.String[] aText, java.lang.String aFindText, java.lang.String aReplaceText)
To replaced.protected static int
toReplaced(java.lang.StringBuffer aTextBuffer, java.lang.String aFindText, java.lang.String aReplaceText)
Replaces a text by an other text in a StringBuffer.protected static java.lang.String
toReplaced(java.lang.String aText, java.lang.String aFindText, java.lang.String aReplaceText)
Replaces all occurrences of a find-String
with a replace-String
in a text and returns the find-and-replaceString
.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()
.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.ReplaceTextBuilder
withFindText, withReplaceText
-
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
-
-
-
-
Method Detail
-
getReplaceText
public java.lang.String getReplaceText()
Retrieves the replace text from the replace text property.- Specified by:
getReplaceText
in interfaceReplaceTextBuilder
- Returns:
- The replace text stored by the replace text property.
-
setReplaceText
public void setReplaceText(java.lang.String aReplaceText)
Sets the replace text for the replace text property.- Specified by:
setReplaceText
in interfaceReplaceTextBuilder
- Parameters:
aReplaceText
- The replace text to be stored by the text align mode property.
-
getFindText
public java.lang.String getFindText()
Retrieves the find text from the find text property.- Specified by:
getFindText
in interfaceReplaceTextBuilder
- Returns:
- The find text stored by the find text property.
-
setFindText
public void setFindText(java.lang.String aFindText)
Sets the find text for the find text property.- Specified by:
setFindText
in interfaceReplaceTextBuilder
- Parameters:
aFindText
- The find text to be stored by the text align mode property.
-
toStrings
public java.lang.String[] toStrings() throws java.lang.IllegalStateException
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 - Throws:
java.lang.IllegalStateException
-
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<ReplaceTextBuilder>
- Parameters:
aText
- The text to be processed.- Returns:
- The according resulting
String
array
-
toReplaced
protected static java.lang.String[] toReplaced(java.lang.String[] aText, java.lang.String aFindText, java.lang.String aReplaceText)
To replaced.- Parameters:
aText
- the textaFindText
- the find textaReplaceText
- the replace text- Returns:
- the string[]
-
toReplaced
protected static java.lang.String toReplaced(java.lang.String aText, java.lang.String aFindText, java.lang.String aReplaceText)
Replaces all occurrences of a find-String
with a replace-String
in a text and returns the find-and-replaceString
.- Parameters:
aText
- The text to be processed ('find-and-replace').aFindText
- TheString
to be searched and replaced.aReplaceText
- TheString
which will replace the searchedString
.- Returns:
- Description is currently not available!
-
toReplaced
protected static int toReplaced(java.lang.StringBuffer aTextBuffer, java.lang.String aFindText, java.lang.String aReplaceText)
Replaces a text by an other text in a StringBuffer.- Parameters:
aTextBuffer
- The buffer containing text with keywords.aFindText
- The text which has to be replaced.aReplaceText
- The text that should be places over the original.- Returns:
- The number of replacements done.
-
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!
-
-