edu.northwestern.at.utils

## Class PatternReplacer

- java.lang.Object
- - edu.northwestern.at.utils.PatternReplacer

- All Implemented Interfaces:
    java.io.Serializable

      public class PatternReplacer
      extends java.lang.Object
      implements java.io.Serializable

  Defines a pattern replacer.

  Defines a source pattern (regular expresssion) and its replacement string, along with a method for performing the replacement.

  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected java.lang.String` | `replacementPattern` Replacement.
    `protected java.lang.String` | `sourcePattern` Source pattern string.
    `protected java.util.regex.Matcher` | `sourcePatternMatcher` Compiled source pattern matcher.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PatternReplacer(java.lang.String sourcePattern, java.lang.String replacementPattern)` Create a pattern replacer definition.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.util.regex.Matcher` | `getMatcher()` Get pattern matcher.
    `java.lang.String[]` | `matchGroups(java.lang.String s)` Return matched groups.
    `java.lang.String` | `replace(java.lang.String s)` Perform replacement.
    `java.lang.String` | `toString()` Display pattern replacer as string.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### sourcePattern

          protected java.lang.String sourcePattern

      Source pattern string.

    - #### sourcePatternMatcher

          protected java.util.regex.Matcher sourcePatternMatcher

      Compiled source pattern matcher.

    - #### replacementPattern

          protected java.lang.String replacementPattern

      Replacement.

  - ### Constructor Detail

    - #### PatternReplacer

          public PatternReplacer(java.lang.String sourcePattern,
                         java.lang.String replacementPattern)

      Create a pattern replacer definition.
      Parameters:
        `sourcePattern` - Source pattern string as a regular expression.
        `replacementPattern` - Replacement pattern string as a regular expression replacement expression.

  - ### Method Detail

    - #### matchGroups

          public java.lang.String[] matchGroups(java.lang.String s)

      Return matched groups.
      Parameters:
        `s` - String to match.
      Returns:
        String array of matched groups. Null if match fails.

    - #### replace

          public java.lang.String replace(java.lang.String s)

      Perform replacement.
      Parameters:
        `s` - String in which to perform replacement.
      Returns:
        String with source pattern replaced.

    - #### getMatcher

          public java.util.regex.Matcher getMatcher()

      Get pattern matcher.
      Returns:
        The pattern matcher.

    - #### toString

          public java.lang.String toString()

      Display pattern replacer as string.
      Overrides:
        `toString` in class `java.lang.Object`
      Returns:
        Pattern replacer as string.