org.apache.tools.ant.util

Class GlobPatternMapper

public class GlobPatternMapper extends Object implements FileNameMapper

Implementation of FileNameMapper that does simple wildcard pattern replacements.

This does simple translations like *.foo -> *.bar where the prefix to .foo will be left unchanged. It only handles a single * character, use regular expressions for more complicated situations.

This is one of the more useful Mappers, it is used by javac for example.

Field Summary
protected StringfromPostfix
Part of "from" pattern after the *.
protected StringfromPrefix
Part of "from" pattern before the *.
protected intpostfixLength
Length of the postfix ("from" pattern).
protected intprefixLength
Length of the prefix ("from" pattern).
protected StringtoPostfix
Part of "to" pattern after the *.
protected StringtoPrefix
Part of "to" pattern before the *.
Method Summary
protected StringextractVariablePart(String name)
Returns the part of the given string that matches the * in the "from" pattern.
booleangetHandleDirSep()
Attribute specifying whether to ignore the difference between / and \ (the two common directory characters).
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.
voidsetCaseSensitive(boolean caseSensitive)
Attribute specifying whether to ignore the case difference in the names.
voidsetFrom(String from)
Sets the "from" pattern.
voidsetHandleDirSep(boolean handleDirSep)
Attribute specifying whether to ignore the difference between / and \ (the two common directory characters).
voidsetTo(String to)
Sets the "to" pattern.

Field Detail

fromPostfix

protected String fromPostfix
Part of "from" pattern after the *.

fromPrefix

protected String fromPrefix
Part of "from" pattern before the *.

postfixLength

protected int postfixLength
Length of the postfix ("from" pattern).

prefixLength

protected int prefixLength
Length of the prefix ("from" pattern).

toPostfix

protected String toPostfix
Part of "to" pattern after the *.

toPrefix

protected String toPrefix
Part of "to" pattern before the *.

Method Detail

extractVariablePart

protected String extractVariablePart(String name)
Returns the part of the given string that matches the * in the "from" pattern.

Parameters: name the source file name

Returns: the variable part of the name

getHandleDirSep

public boolean getHandleDirSep()
Attribute specifying whether to ignore the difference between / and \ (the two common directory characters).

Since: Ant 1.8.3

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 filename to map

Returns: a list of converted filenames

setCaseSensitive

public void setCaseSensitive(boolean caseSensitive)
Attribute specifying 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 a string

setHandleDirSep

public void setHandleDirSep(boolean handleDirSep)
Attribute specifying 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 a string