net.sf.jeters.util
Class StringProtector

java.lang.Object
  extended by net.sf.jeters.util.StringProtector

public class StringProtector
extends java.lang.Object

tool that will "protect" parts of a String identified by regular expressions by replacing them with an ID (positive integer) and some strings specified in the constructor. This functionality is useful if certain parts of a text (comments, for example) should not be exposed to regular expressions applied to the text. The number of protections is limited to the number of possible non-negative values in a Long.


Constructor Summary
StringProtector(java.lang.String startMarker, java.lang.String endMarker)
          creates a new string protector
 
Method Summary
 java.lang.String protect(java.lang.String s, java.lang.String... expressions)
          replaces all occurrences of given regular expressions in the String s with "protection strings"
 java.lang.String unprotect(java.lang.String s)
          replaces the protection marks with the original text; protected text will no longer be known to this StringProtector
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringProtector

public StringProtector(java.lang.String startMarker,
                       java.lang.String endMarker)
creates a new string protector

Parameters:
startMarker - String that will mark the beginning of a protected part
endMarker - String that will mark the end of a protected part
Method Detail

protect

public java.lang.String protect(java.lang.String s,
                                java.lang.String... expressions)
replaces all occurrences of given regular expressions in the String s with "protection strings"

Parameters:
s - string to create a protected version from
expressions - regular expr.s to protect
Returns:
s with protections applied

unprotect

public java.lang.String unprotect(java.lang.String s)
replaces the protection marks with the original text; protected text will no longer be known to this StringProtector

Parameters:
s - String to remove protection marks from
Returns:
s with original Strings instead of protections