Methods Summary |
---|
public java.lang.String[] | mapFileName(java.lang.String sourceFileName)Returns null if the source file name doesn't match the
"from" pattern, an one-element array containing the
translated file otherwise.
if (handleDirSep) {
if (sourceFileName.indexOf("\\") != -1) {
sourceFileName = sourceFileName.replace('\\", '/");
}
}
if (reg == null || to == null
|| !reg.matches(sourceFileName, regexpOptions)) {
return null;
}
return new String[] {replaceReferences(sourceFileName)};
|
protected java.lang.String | replaceReferences(java.lang.String source)Replace all backreferences in the to pattern with the matched
groups of the source.
Vector v = reg.getGroups(source, regexpOptions);
result.setLength(0);
for (int i = 0; i < to.length; i++) {
if (to[i] == '\\") {
if (++i < to.length) {
int value = Character.digit(to[i], 10);
if (value > -1) {
result.append((String) v.elementAt(value));
} else {
result.append(to[i]);
}
} else {
// XXX - should throw an exception instead?
result.append('\\");
}
} else {
result.append(to[i]);
}
}
return result.substring(0);
|
public void | setCaseSensitive(boolean caseSensitive)Attribute specifing whether to ignore the case difference
in the names.
if (!caseSensitive) {
regexpOptions = RegexpMatcher.MATCH_CASE_INSENSITIVE;
} else {
regexpOptions = 0;
}
|
public void | setFrom(java.lang.String from)Sets the "from" pattern. Required.
try {
reg.setPattern(from);
} catch (NoClassDefFoundError e) {
// depending on the implementation the actual RE won't
// get instantiated in the constructor.
throw new BuildException("Cannot load regular expression matcher",
e);
}
|
public void | setHandleDirSep(boolean handleDirSep)Attribute specifing whether to ignore the difference
between / and \ (the two common directory characters).
this.handleDirSep = handleDirSep;
|
public void | setTo(java.lang.String to)Sets the "to" pattern. Required.
this.to = to.toCharArray();
|