CutDirsMapper (Apache Ant API)
Date: 2016-08-23

org.apache.tools.ant.types.mappers

## Class CutDirsMapper

- java.lang.Object
- - org.apache.tools.ant.types.mappers.CutDirsMapper

- All Implemented Interfaces:
    FileNameMapper

      public class CutDirsMapper
      extends java.lang.Object
      implements FileNameMapper

  A mapper that strips of the a configurable number of leading directories from a file name.

  This mapper was inspired by a user-list thread that mentioned wget's --cut-dirs option.

  See Also:
    simplify copy with regexpmapper

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `CutDirsMapper()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.String[]` | `mapFileName(java.lang.String sourceFileName)` Returns an array containing the target filename(s) for the given source file.
    `void` | `setDirs(int dirs)` The number of leading directories to cut.
    `void` | `setFrom(java.lang.String ignore)` Empty implementation.
    `void` | `setTo(java.lang.String ignore)` Empty implementation.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### CutDirsMapper

          public CutDirsMapper()

  - ### Method Detail

    - #### setDirs

          public void setDirs(int dirs)

      The number of leading directories to cut.

    - #### setFrom

          public void setFrom(java.lang.String ignore)

      Empty implementation.
      Specified by:
        `setFrom` in interface `FileNameMapper`
      Parameters:
        `ignore` - ignored.

    - #### setTo

          public void setTo(java.lang.String ignore)

      Empty implementation.
      Specified by:
        `setTo` in interface `FileNameMapper`
      Parameters:
        `ignore` - ignored.

    - #### mapFileName

          public java.lang.String[] mapFileName(java.lang.String sourceFileName)

      Returns an array containing the target filename(s) for the given source file.

      if the given rule doesn't apply to the source file, implementation must return null. SourceFileScanner will then omit the source file in question.

      .
      Specified by:
        `mapFileName` in interface `FileNameMapper`
      Parameters:
        `sourceFileName` - the name of the source file relative to some given basedirectory.
      Returns:
        an array of strings if the rule applies to the source file, or null if it does not.