|
@@ -31,8 +31,11 @@ import java.io.OutputStreamWriter; |
|
|
import java.io.Reader; |
|
|
import java.io.Reader; |
|
|
import java.io.Writer; |
|
|
import java.io.Writer; |
|
|
import java.util.ArrayList; |
|
|
import java.util.ArrayList; |
|
|
|
|
|
import java.util.Comparator; |
|
|
import java.util.Iterator; |
|
|
import java.util.Iterator; |
|
|
import java.util.Properties; |
|
|
import java.util.Properties; |
|
|
|
|
|
import java.util.Set; |
|
|
|
|
|
import java.util.TreeSet; |
|
|
|
|
|
|
|
|
import org.apache.tools.ant.BuildException; |
|
|
import org.apache.tools.ant.BuildException; |
|
|
import org.apache.tools.ant.DirectoryScanner; |
|
|
import org.apache.tools.ant.DirectoryScanner; |
|
@@ -508,7 +511,7 @@ public class Replace extends MatchingTask { |
|
|
try { |
|
|
try { |
|
|
if (replaceFilterResource != null) { |
|
|
if (replaceFilterResource != null) { |
|
|
Properties props = getProperties(replaceFilterResource); |
|
|
Properties props = getProperties(replaceFilterResource); |
|
|
Iterator e = props.keySet().iterator(); |
|
|
|
|
|
|
|
|
Iterator e = getOrderedIterator(props); |
|
|
while (e.hasNext()) { |
|
|
while (e.hasNext()) { |
|
|
String tok = e.next().toString(); |
|
|
String tok = e.next().toString(); |
|
|
Replacefilter replaceFilter = createReplacefilter(); |
|
|
Replacefilter replaceFilter = createReplacefilter(); |
|
@@ -952,4 +955,22 @@ public class Replace extends MatchingTask { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* Sort keys by size so that tokens that are substrings of other |
|
|
|
|
|
* strings are tried later. |
|
|
|
|
|
*/ |
|
|
|
|
|
private Iterator<Object> getOrderedIterator(Properties props) { |
|
|
|
|
|
Set<Object> keys = new TreeSet(new Comparator<Object>() { |
|
|
|
|
|
@Override |
|
|
|
|
|
public int compare(Object key1, Object key2) { |
|
|
|
|
|
return compare(key1.toString(), key2.toString()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private int compare(String key1, String key2) { |
|
|
|
|
|
return key2.length() - key1.length(); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
keys.addAll(props.keySet()); |
|
|
|
|
|
return keys.iterator(); |
|
|
|
|
|
} |
|
|
} |
|
|
} |