FileDocCategorySizeDatePackage
ChainedMapper.javaAPI DocApache Ant 1.702246Wed Dec 13 06:16:22 GMT 2006org.apache.tools.ant.util

ChainedMapper

public class ChainedMapper extends ContainerMapper
A ContainerMapper that chains the results of the first nested FileNameMappers into sourcefiles for the second, the second to the third, and so on, returning the resulting mapped filenames from the last nested FileNameMapper.

Fields Summary
Constructors Summary
Methods Summary
public java.lang.String[]mapFileName(java.lang.String sourceFileName)
{@inheritDoc}.

        List inputs = new ArrayList();
        List results = new ArrayList();
        results.add(sourceFileName);
        FileNameMapper mapper = null;

        for (Iterator mIter = getMappers().iterator(); mIter.hasNext();) {
            mapper = (FileNameMapper) (mIter.next());
            if (mapper != null) {
                inputs.clear();
                inputs.addAll(results);
                results.clear();

                for (Iterator it = inputs.iterator(); it.hasNext();) {
                    String[] mapped = mapper.mapFileName((String) (it.next()));
                    if (mapped != null) {
                        results.addAll(Arrays.asList(mapped));
                    }
                }
            }
        }
        return (results.size() == 0) ? null
            : (String[]) results.toArray(new String[results.size()]);