|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.javasimon.utils.Replacer
public final class Replacer
Replacer stores from regex as pattern and its process(java.lang.String) method than returns
string with all from replaced with to. Using the replacer should be faster
because the regex is compiled only once. Pattern.matcher(CharSequence)
and Matcher.replaceAll(String) is used internally, hence to
parameter is regex as well and can reference matched group from the from String.
Replacer.Modificators.
| Nested Class Summary | |
|---|---|
static class |
Replacer.Modificator
Flags for modifying the default replacer behavior. |
| Field Summary | |
|---|---|
private Pattern |
from
|
private boolean |
ignoreCase
|
private Replacer.Modificator[] |
modificators
|
private boolean |
repeatUntilUnchanged
|
private String |
to
|
| Constructor Summary | |
|---|---|
Replacer(String from,
String to,
Replacer.Modificator... modificators)
Creates the replacer with from->to regex specification. |
|
| Method Summary | |
|---|---|
String |
getTo()
Returns replacement string. |
String |
process(String in)
Processes input, replaces all as expected and returns the result. |
private void |
processModificators(Replacer.Modificator... modificators)
|
void |
setTo(String to)
Sets replacement string - this can be changed anytime with any subsequent process(String) calls
reflecting this change immediatelly. |
String |
toString()
Returns from, to and untilUnchanged fields as a human readable string. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private final Pattern from
private String to
private boolean repeatUntilUnchanged
private boolean ignoreCase
private Replacer.Modificator[] modificators
| Constructor Detail |
|---|
public Replacer(String from,
String to,
Replacer.Modificator... modificators)
from - replaced regexto - replacement stringmodificators - list of modificators of the behavior or pattern treatment| Method Detail |
|---|
private void processModificators(Replacer.Modificator... modificators)
public String getTo()
public void setTo(String to)
process(String) calls
reflecting this change immediatelly.
to - new replacement stringpublic String process(String in)
in - input string
public String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||