Class EscapeTextBuilder

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

public class EscapeTextBuilder extends Object
The EscapeTextBuilder provides means to "escape" and "unescape" text, e.g. simple marshaling and unmarshaling.
  • Constructor Details

    • EscapeTextBuilder

      public EscapeTextBuilder()
  • Method Details

    • getEscapeTextMode

      public EscapeTextMode getEscapeTextMode()
      Retrieves the escape text mode from the escape text mode property.
      Returns:
      The escape text mode stored by the escape text mode property.
    • setEscapeTextMode

      public void setEscapeTextMode(EscapeTextMode aEscapeTextMode)
      Sets the escape text mode for the escape text mode property.
      Parameters:
      aEscapeTextMode - The escape text mode to be stored by the align text mode property.
    • getEscapeProperties

      public org.refcodes.struct.Property[] getEscapeProperties()
      Gets the escape properties.
      Returns:
      the escape properties
    • setEscapeProperties

      public void setEscapeProperties(org.refcodes.struct.Property... aProperties)
      Sets the escape properties.
      Parameters:
      aProperties - the new escape properties
    • addEscapeProperty

      public EscapeTextBuilder addEscapeProperty(org.refcodes.struct.Property aProperty)
      Adds the escape property.
      Parameters:
      aProperty - the property
      Returns:
      the escape text builder
    • addEscapeProperty

      public EscapeTextBuilder addEscapeProperty(String aKey, String aValue)
      Adds the escape property.
      Parameters:
      aKey - the key
      aValue - the value
      Returns:
      the escape text builder
    • toStrings

      public String[] toStrings() throws IllegalStateException
      The Strings being build by the builder upon the settings of the attributes.
      Returns:
      The according resulting String array
      Throws:
      IllegalStateException
    • 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
    • withEscapeTextMode

      public EscapeTextBuilder withEscapeTextMode(EscapeTextMode aEscapeTextMode)
      Sets the escape text mode for the escape text mode property.
      Parameters:
      aEscapeTextMode - The escape text mode to be stored by the align text mode property.
      Returns:
      The builder for applying multiple build operations.
    • withEscapeProperties

      public EscapeTextBuilder withEscapeProperties(org.refcodes.struct.Property... aProperties)
      With escape properties.
      Parameters:
      aProperties - the properties
      Returns:
      the escape text builder
    • toEscaped

      protected String[] toEscaped(String[] aText, List<org.refcodes.struct.Property> aProperties, EscapeTextMode aEscapeTextMode)
      To escaped.
      Parameters:
      aText - the text
      aProperties - the properties
      aEscapeTextMode - the escape text mode
      Returns:
      the string[]
    • toEscaped

      protected String toEscaped(String aText, List<org.refcodes.struct.Property> aProperties, EscapeTextMode aEscapeTextMode)
      To escaped.
      Parameters:
      aText - the text
      aProperties - the properties
      aEscapeTextMode - the escape text mode
      Returns:
      the string
    • toEscaped

      public static String toEscaped(String aUnEscaped, String[][] aEscapeMatrix)
      Escapes a text using the provided escape matrix which must be a two dimensional array with two elements per line and where the element at position 0 (of a line) represents the character and the element at position 1 (of a line) the escaped character.
      Parameters:
      aUnEscaped - The text to be escaped.
      aEscapeMatrix - The matrix to be used for escaping.
      Returns:
      The escape text as of the escape matrix.
    • toUnEscaped

      public static String toUnEscaped(String aEscaped, String[][] aEscapeMatrix)
      Unescapes a text using the provided escape matrix which must be a two dimensional array with two elements per line and where the element at position 0 (of a line) represents the character and the element at position 1 (of a line) the escaped character.
      Parameters:
      aEscaped - The text to be unescaped.
      aEscapeMatrix - The matrix to be used for unescaping.
      Returns:
      The unescape text as of the escape matrix.
    • asEscaped

      public static String asEscaped(String aUnEscapedText)
      Default text escape implementation used by the EscapeTextBuilder in case no escape Property matrix has been supplied.
      Parameters:
      aUnEscapedText - The text to be escaped.
      Returns:
      The escaped text.
    • asUnEscaped

      public static String asUnEscaped(String aEscapedText)
      Default text un-escape implementation used by the EscapeTextBuilder in case no escape Property matrix has been supplied.
      Parameters:
      aEscapedText - The text to be un-escaped.
      Returns:
      The un-escaped text.
    • toEscapedRegexp

      protected static String toEscapedRegexp(char aDelimiter)
      To escaped regexp.
      Parameters:
      aDelimiter - the delimiter
      Returns:
      the string
    • toRegExEscaped

      protected static String toRegExEscaped(String aText)
      To reg ex escaped.
      Parameters:
      aText - the text
      Returns:
      the string
    • 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 EscapeTextBuilder 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 EscapeTextBuilder 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