org.schmant.support.text
Class ClosureReplacementTextStrategy
java.lang.Object
org.schmant.support.text.ClosureReplacementTextStrategy
- All Implemented Interfaces:
- ReplacementTextStrategy
public class ClosureReplacementTextStrategy
- extends Object
- implements ReplacementTextStrategy
This ReplacementTextStrategy
uses a closure to get the replacement
text. The closure must take one or two arguments. The first, mandatory,
argument is a string containing the text to replace. The second, optional,
argument is a Matcher
object containing the matcher that matched the
text to replace (read only). The closure should return a string.
- Since:
- 1.1
- Author:
- Karl Gustafsson
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ClosureReplacementTextStrategy
public ClosureReplacementTextStrategy(Object closure)
getReplace
public String getReplace(String text,
Matcher m)
- Description copied from interface:
ReplacementTextStrategy
- Get the replacement text for the supplied text.
- Specified by:
getReplace
in interface ReplacementTextStrategy
- Parameters:
text
- 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.