|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.javagen.agile.core.util.RegexRenamer
public class RegexRenamer
Itererates through a list of regular expressions and applies a replacement string when a match is found.
Currently only applies the first match found, ingnoring any remaining regex's in the list.
Regex and replacePatterns can be set as a single property string or added individually by calling
addReplacementPattern.
For example to add a regex to remove 'Fk' & 'Pk' suffixes from a name such as 'PersonPk',
you can call either:
addReplacementPattern("^([a-zA-Z]+)(Fk|Pk)$", "$1")
or
setRegexReplacePairs("^([a-zA-Z]+)(Fk|Pk)$>$1")
As a single string property the general form of the list is: regex1>replace1,regex2>replace2,...
The replacePattern can be any text interspersed with regex group replacement holders of the form $n, for example: text$1text$3text
| Constructor Summary | |
|---|---|
RegexRenamer()
|
|
| Method Summary | |
|---|---|
void |
addReplacementPattern(String regex,
String replacementPattern)
|
List<org.javagen.agile.core.util.RegexRenamer.PatternHolder> |
getPatternHolders()
|
boolean |
isEmpty()
|
String |
rename(String name)
|
void |
setRegexReplacePairs(String replacePatterns)
Property file friendly means of adding regex-replacePattern pairs as comma-delineated list. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public RegexRenamer()
| Method Detail |
|---|
public String rename(String name)
public void setRegexReplacePairs(String replacePatterns)
general form of the list: regex1>replace1,regex2>replace2,...
regex can be any regular expression excluding the > symbol.
The replacePattern can be any text interspersed with regex group replacement holders of the form $n, for example: text$1text$3text
For example to remove 'Fk' & 'Pk' suffixes use: ^([a-zA-Z]+)(Fk|Pk)$>$1
public void addReplacementPattern(String regex,
String replacementPattern)
public List<org.javagen.agile.core.util.RegexRenamer.PatternHolder> getPatternHolders()
public boolean isEmpty()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||