1 18 19 package org.apache.tools.ant.util; 20 21 import java.util.List ; 22 import java.util.Arrays ; 23 import java.util.Iterator ; 24 import java.util.ArrayList ; 25 26 32 public class ChainedMapper extends ContainerMapper { 33 34 35 public String [] mapFileName(String sourceFileName) { 36 List inputs = new ArrayList (); 37 List results = new ArrayList (); 38 results.add(sourceFileName); 39 FileNameMapper mapper = null; 40 41 for (Iterator mIter = getMappers().iterator(); mIter.hasNext();) { 42 mapper = (FileNameMapper) (mIter.next()); 43 if (mapper != null) { 44 inputs.clear(); 45 inputs.addAll(results); 46 results.clear(); 47 48 for (Iterator it = inputs.iterator(); it.hasNext();) { 49 String [] mapped = mapper.mapFileName((String ) (it.next())); 50 if (mapped != null) { 51 results.addAll(Arrays.asList(mapped)); 52 } 53 } 54 } 55 } 56 return (results.size() == 0) ? null 57 : (String []) results.toArray(new String [results.size()]); 58 } 59 } 60 61 | Popular Tags |