Class EncodingPatternPreservation


  • public class EncodingPatternPreservation
    extends java.lang.Object
    String mutation utility which can be used to replace all occurrences of a defined regular expression with a marker string, and also restore the original string content.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String captureAndReplaceMatches​(java.lang.String input)
      Replaces each matching instance of this instance's Pattern with an identifiable replacement marker.
      void reset()
      Clears any stored replacement values out of the instance.
      java.lang.String restoreOriginalContent​(java.lang.String input)
      Replaces each instance of the replacementMarker with the original content, as captured by captureAndReplaceMatches(String)
      void setReplacementMarker​(java.lang.String marker)
      Allows the marker used as a replacement to be altered.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • EncodingPatternPreservation

        public EncodingPatternPreservation​(java.util.regex.Pattern pattern)
        Constructor.
        Parameters:
        pattern - Pattern identifying content being replaced.
    • Method Detail

      • captureAndReplaceMatches

        public java.lang.String captureAndReplaceMatches​(java.lang.String input)
        Replaces each matching instance of this instance's Pattern with an identifiable replacement marker.

        After the encoding process is complete, use restoreOriginalContent(String) to re-insert the original data.
        Parameters:
        input - String to adjust
        Returns:
        The adjusted String
      • restoreOriginalContent

        public java.lang.String restoreOriginalContent​(java.lang.String input)
        Replaces each instance of the replacementMarker with the original content, as captured by captureAndReplaceMatches(String)
        Parameters:
        input - String to restore.
        Returns:
        String reference with all values replaced.
      • setReplacementMarker

        public void setReplacementMarker​(java.lang.String marker)
        Allows the marker used as a replacement to be altered.
        Parameters:
        marker - String replacment to use for regex matches.
      • reset

        public void reset()
        Clears any stored replacement values out of the instance.