org.apache.tools.ant.util

Class RegexpPatternMapper

public class RegexpPatternMapper extends Object implements FileNameMapper

Implementation of FileNameMapper that does regular expression replacements.
Field Summary
protected RegexpMatcherreg
protected StringBufferresult
protected char[]to
Constructor Summary
RegexpPatternMapper()
Constructor for RegexpPatternMapper.
Method Summary
String[]mapFileName(String sourceFileName)
Returns null if the source file name doesn't match the "from" pattern, an one-element array containing the translated file otherwise.
protected StringreplaceReferences(String source)
Replace all backreferences in the to pattern with the matched groups of the source.
voidsetCaseSensitive(boolean caseSensitive)
Attribute specifing whether to ignore the case difference in the names.
voidsetFrom(String from)
Sets the "from" pattern.
voidsetHandleDirSep(boolean handleDirSep)
Attribute specifing whether to ignore the difference between / and \ (the two common directory characters).
voidsetTo(String to)
Sets the "to" pattern.

Field Detail

reg

protected RegexpMatcher reg

result

protected StringBuffer result

to

protected char[] to

Constructor Detail

RegexpPatternMapper

public RegexpPatternMapper()
Constructor for RegexpPatternMapper.

Throws: BuildException on error.

Method Detail

mapFileName

public String[] mapFileName(String sourceFileName)
Returns null if the source file name doesn't match the "from" pattern, an one-element array containing the translated file otherwise.

Parameters: sourceFileName the source file name

Returns: a one-element array containing the translated file or null if the to pattern did not match

replaceReferences

protected String replaceReferences(String source)
Replace all backreferences in the to pattern with the matched groups of the source.

Parameters: source the source file name.

Returns: the translated file name.

setCaseSensitive

public void setCaseSensitive(boolean caseSensitive)
Attribute specifing whether to ignore the case difference in the names.

Parameters: caseSensitive a boolean, default is false.

Since: Ant 1.6.3

setFrom

public void setFrom(String from)
Sets the "from" pattern. Required.

Parameters: from the from pattern.

Throws: BuildException on error.

setHandleDirSep

public void setHandleDirSep(boolean handleDirSep)
Attribute specifing whether to ignore the difference between / and \ (the two common directory characters).

Parameters: handleDirSep a boolean, default is false.

Since: Ant 1.6.3

setTo

public void setTo(String to)
Sets the "to" pattern. Required.

Parameters: to the to pattern.

Throws: BuildException on error.

Copyright B) 2000-2007 Apache Software Foundation. All Rights Reserved.