Class GlobPatternMapper
- java.lang.Object
-
- org.apache.maven.shared.model.fileset.mappers.GlobPatternMapper
-
- All Implemented Interfaces:
FileNameMapper
- Direct Known Subclasses:
PackageNameMapper,UnPackageNameMapper
public class GlobPatternMapper extends java.lang.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
javacfor example.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.StringfromPostfixPart of "from" pattern after the *.protected java.lang.StringfromPrefixPart of "from" pattern before the *.protected intpostfixLengthLength of the postfix ("from" pattern).protected intprefixLengthLength of the prefix ("from" pattern).protected java.lang.StringtoPostfixPart of "to" pattern after the *.protected java.lang.StringtoPrefixPart of "to" pattern before the *.
-
Constructor Summary
Constructors Constructor Description GlobPatternMapper()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.StringextractVariablePart(java.lang.String name)Returns the part of the given string that matches the * in the "from" pattern.java.lang.StringmapFileName(java.lang.String sourceFileName)Returns the target filename for the given source file.voidsetCaseSensitive(boolean caseSensitive)Attribute specifing whether to ignore the case difference in the names.voidsetFrom(java.lang.String from)Sets the from part of the transformation rule.voidsetHandleDirSep(boolean handleDirSep)Attribute specifing whether to ignore the difference between / and \ (the two common directory characters).voidsetTo(java.lang.String to)Sets the to part of the transformation rule.
-
-
-
Field Detail
-
fromPrefix
protected java.lang.String fromPrefix
Part of "from" pattern before the *.
-
fromPostfix
protected java.lang.String fromPostfix
Part of "from" pattern after the *.
-
prefixLength
protected int prefixLength
Length of the prefix ("from" pattern).
-
postfixLength
protected int postfixLength
Length of the postfix ("from" pattern).
-
toPrefix
protected java.lang.String toPrefix
Part of "to" pattern before the *.
-
toPostfix
protected java.lang.String toPostfix
Part of "to" pattern after the *.
-
-
Method Detail
-
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.
-
setCaseSensitive
public void setCaseSensitive(boolean caseSensitive)
Attribute specifing whether to ignore the case difference in the names.- Parameters:
caseSensitive- a boolean, default is false.
-
setFrom
public void setFrom(java.lang.String from)
Description copied from interface:FileNameMapperSets the from part of the transformation rule.- Specified by:
setFromin interfaceFileNameMapper- Parameters:
from- the source
-
setTo
public void setTo(java.lang.String to)
Description copied from interface:FileNameMapperSets the to part of the transformation rule.- Specified by:
setToin interfaceFileNameMapper- Parameters:
to- the destination
-
mapFileName
public java.lang.String mapFileName(java.lang.String sourceFileName)
Description copied from interface:FileNameMapperReturns the target filename for the given source file.If the given rule doesn't apply to the source file, the implementation must return null. SourceFileScanner will then omit the source file in question.
- Specified by:
mapFileNamein interfaceFileNameMapper- Parameters:
sourceFileName- the name of the source file relative to some given base directory- Returns:
- the target filename for the given source file
-
extractVariablePart
protected java.lang.String extractVariablePart(java.lang.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
-
-