Class ReplaceTextBuilder

java.lang.Object
org.refcodes.textual.ReplaceTextBuilder
All Implemented Interfaces:
Text<ReplaceTextBuilder>, TextAccessor, TextAccessor.TextBuilder<Text<ReplaceTextBuilder>>, TextAccessor.TextMutator, TextAccessor.TextProperty, TextAccessor.TextProvider

public class ReplaceTextBuilder extends Object
Plain find/replace utility not(!) using regular expressions.
  • Constructor Details

    • ReplaceTextBuilder

      public ReplaceTextBuilder()
  • Method Details

    • getReplaceText

      public String getReplaceText()
      Retrieves the replace text from the replace text property.
      Returns:
      The replace text stored by the replace text property.
    • setReplaceText

      public void setReplaceText(String aReplaceText)
      Sets the replace text for the replace text property.
      Parameters:
      aReplaceText - The replace text to be stored by the text align mode property.
    • getFindText

      public String getFindText()
      Retrieves the find text from the find text property.
      Returns:
      The find text stored by the find text property.
    • setFindText

      public void setFindText(String aFindText)
      Sets the find text for the find text property.
      Parameters:
      aFindText - The find text to be stored by the text align mode property.
    • toStrings

      public String[] toStrings()
      The Strings being build by the builder upon the settings of the attributes.
      Returns:
      The according resulting String array
    • toStrings

      public String[] toStrings(String... aText)
      Race condition safe shortcut for using Text.withText(String...) followed by TextAccessor.TextProvider.toStrings(). Implementation requirements: This method must not(!) be implemented by calling Text.withText(String...) followed by TextAccessor.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

      public ReplaceTextBuilder withReplaceText(String aReplaceText)
      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

      public ReplaceTextBuilder withFindText(String aFindText)
      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

      public static String[] asReplaced(String[] aText, String aFindText, String aReplaceText)
      Replaces a text by an other text in a String 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

      public static String asReplaced(String aText, String aFindText, String aReplaceText)
      Replaces all occurrences of a find-String with a replace- String in a text and returns the find-and-replace String.
      Parameters:
      aText - The text to be processed ('find-and-replace').
      aFindText - The String to be searched and replaced.
      aReplaceText - The String which will replace the searched String.
      Returns:
      Description is currently not available!
    • getText

      public String[] getText()
      Retrieves the text from the text property.
      Specified by:
      getText in interface TextAccessor
      Returns:
      The text stored by the text property.
    • setText

      public void setText(String... aText)
      Sets the text for the text property.
      Specified by:
      setText in interface TextAccessor.TextMutator
      Parameters:
      aText - The text to be stored by the text property.
    • withText

      public ReplaceTextBuilder withText(String... aText)
      With text.
      Specified by:
      withText in interface Text<B extends Text<B>>
      Specified by:
      withText in interface TextAccessor.TextBuilder<B extends Text<B>>
      Parameters:
      aText - the text
      Returns:
      the b
    • withText

      public ReplaceTextBuilder withText(Collection<String> aText)
      With text.
      Specified by:
      withText in interface TextAccessor.TextBuilder<B extends Text<B>>
      Parameters:
      aText - the text
      Returns:
      the b
    • toString

      public String toString()
      The String 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 interface TextAccessor.TextProvider
      Overrides:
      toString in class Object
      Returns:
      The according resulting String
    • toString

      public String toString(String... aText)
      Race condition safe shortcut for using Text.withText(String...) followed by TextAccessor.TextProvider.toString(). Implementation requirements: This method must not(!) be implemented by calling Text.withText(String...) followed by TextAccessor.TextProvider.toString() (do not change the text property) as this would not be thread safe!
      Specified by:
      toString in interface Text<B extends Text<B>>
      Parameters:
      aText - The text to be processed.
      Returns:
      The according resulting String