Most notably, <mapper> had to changed to not
automatically reject nested elements when other
attributes (other than refid) are set.  The use-case
for this is:

<mapper
classname="org.apache.tools.ant.util.ChainedMapper">
  <mapper type="whatever" />
  <mapper type="etc" />
  <mapper type="etc" />
</mapper>

However unlikely, it can be done, and is supported
with the current code, which is an interesting hybrid
of mine and Peter's patches.

-Matt

--- [EMAIL PROTECTED] wrote:
> mbenson     2004/04/22 13:27:21
> 
>   Modified:    src/main/org/apache/tools/ant/util
> ContainerMapper.java
>                docs/manual/CoreTypes mapper.html
>                src/main/org/apache/tools/ant/types
> Mapper.java
>                         defaults.properties
>               
> src/testcases/org/apache/tools/ant/types
> MapperTest.java
>   Added:       src/main/org/apache/tools/ant/util
> ChainedMapper.java
>                         CompositeMapper.java
>   Log:
>   Make ContainerMapper abstract; move
> chained/composite behaviors to
>   subclasses ChainedMapper and CompositeMapper,
> respectively.
>   
>   Revision  Changes    Path
>   1.3       +49 -77   
>
ant/src/main/org/apache/tools/ant/util/ContainerMapper.java
>   
>   Index: ContainerMapper.java
>  
>
===================================================================
>   RCS file:
>
/home/cvs/ant/src/main/org/apache/tools/ant/util/ContainerMapper.java,v
>   retrieving revision 1.2
>   retrieving revision 1.3
>   diff -u -r1.2 -r1.3
>   --- ContainerMapper.java    15 Mar 2004 17:26:34
> -0000 1.2
>   +++ ContainerMapper.java    22 Apr 2004 20:27:21
> -0000 1.3
>   @@ -17,112 +17,84 @@
>    
>    package org.apache.tools.ant.util;
>    
>   -import java.util.ArrayList;
>   -import java.util.Iterator;
>    import java.util.List;
>   +import java.util.Iterator;
>   +import java.util.ArrayList;
>   +import java.util.Collections;
>    import org.apache.tools.ant.types.Mapper;
>    
>    /**
>   - * A filenamemapper that contains other filename
> mappers.
>   - * The mappers proceeded in a chain or
> separately.
>   + * A <code>FileNameMapper</code> that contains
>   + * other <CODE>FileNameMapper</CODE>s.
>     * @see FileNameMapper
>     */
>   +public abstract class ContainerMapper implements
> FileNameMapper {
>    
>   -public class ContainerMapper implements
> FileNameMapper {
>   -
>   -    private boolean chained = false;
>        private List mappers = new ArrayList();
>    
>        /**
>   -     * Add a file name mapper.
>   -     *
>   -     * @param fileNameMapper a file name mapper.
>   +     * Add a <code>Mapper</code>.
>   +     * @param mapper the <code>Mapper</code> to
> add.
>         */
>   -    public void add(FileNameMapper
> fileNameMapper) {
>   -        mappers.add(fileNameMapper);
>   +    public void addConfiguredMapper(Mapper
> mapper) {
>   +        add(mapper.getImplementation());
>        }
>    
>        /**
>   -     * Add a Mapper
>   -     * @param mapper the mapper to add
>   -     */
>   -    public void addConfiguredMapper(Mapper
> mapper) {
>   -        mappers.add(mapper.getImplementation());
>   +     * Add a <code>FileNameMapper</code>.
>   +     * @param fileNameMapper a
> <CODE>FileNameMapper</CODE>.
>   +     * @throws
> <CODE>IllegalArgumentException</CODE> if attempting
> to add this
>   +     *         <CODE>ContainerMapper</CODE> to
> itself, or if the specified
>   +     *         <CODE>FileNameMapper</CODE> is
> itself a <CODE>ContainerMapper</CODE>
>   +     *         that contains this
> <CODE>ContainerMapper</CODE>.
>   +     */
>   +    public synchronized void add(FileNameMapper
> fileNameMapper) {
>   +        if (this == fileNameMapper
>   +            || (fileNameMapper instanceof
> ContainerMapper
>   +            &&
> ((ContainerMapper)fileNameMapper).contains(this))) {
>   +            throw new IllegalArgumentException(
>   +                "Circular mapper containment
> condition detected");
>   +        } else {
>   +            mappers.add(fileNameMapper);
>   +        }
>   +    }
>   +
>   +    /**
>   +     * Return <CODE>true</CODE> if this
> <CODE>ContainerMapper</CODE> or any of
>   +     * its sub-elements contains the specified
> <CODE>FileNameMapper</CODE>.
>   +     * @param fileNameMapper   the
> <CODE>FileNameMapper</CODE> to search for.
>   +     * @return <CODE>boolean</CODE>.
>   +     */
>   +    protected synchronized boolean
> contains(FileNameMapper fileNameMapper) {
>   +        boolean foundit = false;
>   +        for (Iterator iter = mappers.iterator();
> iter.hasNext() && !foundit;) {
>   +            FileNameMapper next =
> (FileNameMapper)(iter.next());
>   +            foundit|= (next == fileNameMapper
>   +                || (next instanceof
> ContainerMapper
>   +                &&
> ((ContainerMapper)next).contains(fileNameMapper)));
>   +        }
>   +        return foundit;
>        }
>    
>        /**
>   -     * Set the chained attribute.
>   -     *
>   -     * @param chained if true the mappers are
> processed in
>   -     *                   a chained fashion. The
> outputs of
>   -     *                a mapper are the inputs for
> the next mapper.
>   -     *                if false the mappers are
> processed indepentanly, the
>   -     *                outputs are combined.
>   +     * Get the <CODE>List</CODE> of
> <CODE>FileNameMapper</CODE>s.
>   +     * @return <CODE>List</CODE>.
>         */
>   -    public void setChained(boolean chained) {
>   -        this.chained = chained;
>   +    public synchronized List getMappers() {
>   +        return
> Collections.unmodifiableList(mappers);
>        }
>    
>        /**
>   -     * This method is ignored, present to
> fullfill the FileNameMapper
>   -     * interface.
>   -     * @param ignore this parameter is ignored.
>   +     * Empty implementation.
>         */
>        public void setFrom(String ignore) {
>        }
>    
>        /**
>   -     * This method is ignored, present to
> fullfill the FileNameMapper
>   -     * interface.
>   -     * @param ignore this parameter is ignored.
>   +     * Empty implementation.
>         */
>        public void setTo(String ignore) {
>        }
>    
>   -    /**
>   -     * Map a filename using the list of mappers.
>   -     *
>   -     * @param sourceFileName The filename to map.
>   -     * @return a <code>String[]</code> value or
> null if there
>   -     *         are no mappings.
>   -     */
>   -    public String[] mapFileName(String
> sourceFileName) {
>   -        List ret = new ArrayList();
>   -        if (chained) {
>   -            List inputs = new ArrayList();
>   -            ret.add(sourceFileName);
>   -            for (int i = 0; i < mappers.size();
> ++i) {
> 
=== message truncated ===



        
                
__________________________________
Do you Yahoo!?
Yahoo! Photos: High-quality 4x6 digital prints for 25¢
http://photos.yahoo.com/ph/print_splash

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

Reply via email to