mbenson     2004/02/27 15:23:06

  Modified:    docs/manual/CoreTasks pathconvert.html
               .        WHATSNEW
               src/main/org/apache/tools/ant/taskdefs PathConvert.java
  Log:
  Add nested <mapper>s to <pathconvert>.
  PR: 26364
  Submitted by: Peter Reilly
  
  Revision  Changes    Path
  1.14      +8 -0      ant/docs/manual/CoreTasks/pathconvert.html
  
  Index: pathconvert.html
  ===================================================================
  RCS file: /home/cvs/ant/docs/manual/CoreTasks/pathconvert.html,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- pathconvert.html  9 Feb 2004 21:50:05 -0000       1.13
  +++ pathconvert.html  27 Feb 2004 23:23:05 -0000      1.14
  @@ -19,6 +19,9 @@
   </p>
   <p>Nested <code>&lt;map&gt;</code> elements can be specified to map Windows
   drive letters to Unix paths, and vice-versa.</p>
  +<p>More complex transformations can be achieved using a nested
  +<a href="../CoreTypes/mapper.html"><code>&lt;mapper&gt;</code></a>.
  +</p>
   
   <h3>Parameters</h3>
   <table border="1" cellpadding="2" cellspacing="0">
  @@ -114,6 +117,11 @@
   <p>If the <code>refid</code> attribute is not specified, then a
      nested <code>&lt;path&gt;</code> element must be supplied.  See
      <a href="../using.html#path">Path-like Structures</a> for details.</p>
  +<h4>mapper</h4>
  +<p>A single nested <a href="../CoreTypes/mapper.html">
  +<code>&lt;mapper&gt;</code></a> element can be specified
  +to perform any of various filename transformations.
  +</p>
   
   <h3>Examples</h3>
   <p>In the examples below, assume that the <code>${wl.home}</code> property
  
  
  
  1.559     +2 -0      ant/WHATSNEW
  
  Index: WHATSNEW
  ===================================================================
  RCS file: /home/cvs/ant/WHATSNEW,v
  retrieving revision 1.558
  retrieving revision 1.559
  diff -u -r1.558 -r1.559
  --- WHATSNEW  27 Feb 2004 14:54:58 -0000      1.558
  +++ WHATSNEW  27 Feb 2004 23:23:05 -0000      1.559
  @@ -72,6 +72,8 @@
   
   * Docs fixes for xmlvalidate.html. Bugzilla Report 27092.
   
  +* <pathconvert> now accepts nested <mapper>s.  Bugzilla Report 26364.
  +
   Changes from Ant 1.6.0 to Ant 1.6.1
   =============================================
   
  
  
  
  1.31      +31 -0     
ant/src/main/org/apache/tools/ant/taskdefs/PathConvert.java
  
  Index: PathConvert.java
  ===================================================================
  RCS file: 
/home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/PathConvert.java,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- PathConvert.java  9 Feb 2004 21:05:20 -0000       1.30
  +++ PathConvert.java  27 Feb 2004 23:23:06 -0000      1.31
  @@ -19,6 +19,8 @@
   import java.io.File;
   import java.util.StringTokenizer;
   import java.util.Vector;
  +import java.util.List;
  +import java.util.ArrayList;
   import org.apache.tools.ant.BuildException;
   import org.apache.tools.ant.Project;
   import org.apache.tools.ant.Task;
  @@ -29,6 +31,8 @@
   import org.apache.tools.ant.types.FileSet;
   import org.apache.tools.ant.types.Path;
   import org.apache.tools.ant.types.Reference;
  +import org.apache.tools.ant.types.Mapper;
  +import org.apache.tools.ant.util.FileNameMapper;
   
   /**
    * Converts path and classpath information to a specific target OS
  @@ -83,6 +87,9 @@
        */
       private String dirSep = null;
   
  +    /** Filename mapper */
  +    private Mapper mapper = null;
  +
       /**
        * constructor
        */
  @@ -352,6 +359,18 @@
               // Get the list of path components in canonical form
               String[] elems = path.list();
   
  +            if (mapper != null) {
  +                FileNameMapper impl = mapper.getImplementation();
  +                List ret = new ArrayList();
  +                for (int i = 0; i < elems.length; ++i) {
  +                    String[] mapped = impl.mapFileName(elems[i]);
  +                    for (int m = 0; mapped != null && m < mapped.length; 
++m) {
  +                        ret.add(mapped[m]);
  +                    }
  +                }
  +                elems = (String[]) ret.toArray(new String[] {});
  +            }
  +
               for (int i = 0; i < elems.length; i++) {
                   String elem = elems[i];
   
  @@ -435,6 +454,18 @@
           return elem;
       }
   
  +    /**
  +     * Add a mapper to convert the file names.
  +     *
  +     * @param mapper a <code>Mapper</code> value
  +     */
  +    public void addMapper(Mapper mapper) {
  +        if (this.mapper != null) {
  +            throw new BuildException(
  +                "Cannot define more than one mapper");
  +        }
  +        this.mapper = mapper;
  +    }
   
       /**
        * Validate that all our parameters have been properly initialized.
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to