1 18 19 package org.apache.tools.ant.util; 20 21 import java.util.List ; 22 import java.util.Iterator ; 23 import java.util.ArrayList ; 24 import java.util.Collections ; 25 import org.apache.tools.ant.types.Mapper; 26 27 32 public abstract class ContainerMapper implements FileNameMapper { 33 34 private List mappers = new ArrayList (); 35 36 40 public void addConfiguredMapper(Mapper mapper) { 41 add(mapper.getImplementation()); 42 } 43 44 53 public void addConfigured(FileNameMapper fileNameMapper) { 54 add(fileNameMapper); 55 } 56 57 65 public synchronized void add(FileNameMapper fileNameMapper) { 66 if (this == fileNameMapper 67 || (fileNameMapper instanceof ContainerMapper 68 && ((ContainerMapper) fileNameMapper).contains(this))) { 69 throw new IllegalArgumentException ( 70 "Circular mapper containment condition detected"); 71 } else { 72 mappers.add(fileNameMapper); 73 } 74 } 75 76 82 protected synchronized boolean contains(FileNameMapper fileNameMapper) { 83 boolean foundit = false; 84 for (Iterator iter = mappers.iterator(); iter.hasNext() && !foundit;) { 85 FileNameMapper next = (FileNameMapper) (iter.next()); 86 foundit |= (next == fileNameMapper 87 || (next instanceof ContainerMapper 88 && ((ContainerMapper) next).contains(fileNameMapper))); 89 } 90 return foundit; 91 } 92 93 97 public synchronized List getMappers() { 98 return Collections.unmodifiableList(mappers); 99 } 100 101 105 public void setFrom(String ignore) { 106 } 108 109 113 public void setTo(String ignore) { 114 } 116 117 } 118 119 | Popular Tags |