Top Description Fields Constructors Methods
org.apache.tools.ant.util

public Class GlobPatternMapper

extends Object
implements FileNameMapper
Class Inheritance
All Implemented Interfaces
org.apache.tools.ant.util.FileNameMapper
Known Direct Subclasses
org.apache.tools.ant.util.PackageNameMapper, org.apache.tools.ant.util.UnPackageNameMapper
Imports
org.apache.tools.ant.BuildException

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

Modifier and TypeField and Description
private boolean
private boolean
protected String
fromPostfix

Part of "from" pattern after the *.

protected String
fromPrefix

Part of "from" pattern before the *.

private boolean
protected int
postfixLength

Length of the postfix ("from" pattern).

protected int
prefixLength

Length of the prefix ("from" pattern).

private boolean
protected String
toPostfix

Part of "to" pattern after the *.

protected String
toPrefix

Part of "to" pattern before the *.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected String

Returns:

the variable part of the name
extractVariablePart
(String
the source file name
name
)

Returns the part of the given string that matches the * in the "from" pattern.

public boolean

Returns:

boolean
getHandleDirSep
()

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

public String[]

Returns:

a list of converted filenames
mapFileName
(String
the filename to map
sourceFileName
)

Implements org.apache.tools.ant.util.FileNameMapper.mapFileName.

Returns null if the source file name doesn't match the "from" pattern, an one-element array containing the translated file otherwise.
private String

Returns:

the converted name
modifyName
(String
the name to convert
name
)

modify string based on dir char mapping and case sensitivity

public void
setCaseSensitive(boolean
a boolean, default is false.
caseSensitive
)

Attribute specifying whether to ignore the case difference in the names.

public void
setFrom(String
a string
from
)

Implements org.apache.tools.ant.util.FileNameMapper.setFrom.

Sets the "from" pattern.
public void
setHandleDirSep(boolean
a boolean, default is false.
handleDirSep
)

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

public void
setTo(String
a string
to
)

Implements org.apache.tools.ant.util.FileNameMapper.setTo.

Sets the "to" pattern.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

caseSensitiveback to summary
private boolean caseSensitive
fromContainsStarback to summary
private boolean fromContainsStar
fromPostfixback to summary
protected String fromPostfix

Part of "from" pattern after the *.

fromPrefixback to summary
protected String fromPrefix

Part of "from" pattern before the *.

handleDirSepback to summary
private boolean handleDirSep
postfixLengthback to summary
protected int postfixLength

Length of the postfix ("from" pattern).

prefixLengthback to summary
protected int prefixLength

Length of the prefix ("from" pattern).

toContainsStarback to summary
private boolean toContainsStar
toPostfixback to summary
protected String toPostfix

Part of "to" pattern after the *.

toPrefixback to summary
protected String toPrefix

Part of "to" pattern before the *.

Constructor Detail

GlobPatternMapperback to summary
public GlobPatternMapper()

Method Detail

extractVariablePartback to summary
protected String extractVariablePart(String name)

Returns the part of the given string that matches the * in the "from" pattern.

Parameters
name:String

the source file name

Returns:String

the variable part of the name

getHandleDirSepback to summary
public boolean getHandleDirSep()

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

Returns:boolean

boolean

Since
Ant 1.8.3
mapFileNameback to summary
public String[] mapFileName(String sourceFileName)

Implements org.apache.tools.ant.util.FileNameMapper.mapFileName.

Returns null if the source file name doesn't match the "from" pattern, an one-element array containing the translated file otherwise.

Parameters
sourceFileName:String

the filename to map

Returns:String[]

a list of converted filenames

Annotations
@Override
modifyNameback to summary
private String modifyName(String name)

modify string based on dir char mapping and case sensitivity

Parameters
name:String

the name to convert

Returns:String

the converted name

setCaseSensitiveback to summary
public void setCaseSensitive(boolean caseSensitive)

Attribute specifying whether to ignore the case difference in the names.

Parameters
caseSensitive:boolean

a boolean, default is false.

Since
Ant 1.6.3
setFromback to summary
public void setFrom(String from)

Implements org.apache.tools.ant.util.FileNameMapper.setFrom.

Sets the "from" pattern. Required.

Parameters
from:String

a string

Annotations
@Override
setHandleDirSepback to summary
public void setHandleDirSep(boolean handleDirSep)

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

Parameters
handleDirSep:boolean

a boolean, default is false.

Since
Ant 1.6.3
setToback to summary
public void setTo(String to)

Implements org.apache.tools.ant.util.FileNameMapper.setTo.

Sets the "to" pattern. Required.

Parameters
to:String

a string

Annotations
@Override