org.schmant.support.text
Class CapturingGroupAwareStringTextStrategy

java.lang.Object
  extended by org.schmant.support.text.CapturingGroupAwareStringTextStrategy
All Implemented Interfaces:
ReplacementTextStrategy

public final class CapturingGroupAwareStringTextStrategy
extends Object
implements ReplacementTextStrategy

Replacer that use a constant string for replacement.

It is aware of capturing groups in the matched text. Any string \\n where n is a number in the replacement string will be replaced by the value of that capturing group.

Since:
0.5
Author:
Karl Gustafsson
See Also:
StringTextStrategy

Constructor Summary
CapturingGroupAwareStringTextStrategy(String s)
           
 
Method Summary
 String getReplace(String s, Matcher m)
          Get the replacement text for the supplied text.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CapturingGroupAwareStringTextStrategy

public CapturingGroupAwareStringTextStrategy(String s)
Method Detail

getReplace

public String getReplace(String s,
                         Matcher m)
Description copied from interface: ReplacementTextStrategy
Get the replacement text for the supplied text.

Specified by:
getReplace in interface ReplacementTextStrategy
Parameters:
s - The text.
m - The Matcher that matches the current text. This object can only be read from. Its state must not be updated.
Returns:
The replacement text.