Browse Source

I get these epiphanies lying in bed Saturday mornings... such as

"Properties won't sort under an alternate implementation of
Properties.store()," such as might be encountered on Kaffe...


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@277987 13f79535-47bb-0310-9956-ffa450edef68
master
Matthew Jason Benson 20 years ago
parent
commit
cd02e2101c
1 changed files with 23 additions and 0 deletions
  1. +23
    -0
      src/main/org/apache/tools/ant/taskdefs/optional/EchoProperties.java

+ 23
- 0
src/main/org/apache/tools/ant/taskdefs/optional/EchoProperties.java View File

@@ -31,6 +31,10 @@ import java.util.Properties;
import java.util.Vector; import java.util.Vector;
import java.util.List; import java.util.List;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Comparator;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import java.util.Collections; import java.util.Collections;
import java.util.Iterator; import java.util.Iterator;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
@@ -43,6 +47,7 @@ import org.apache.tools.ant.types.PropertySet;
import org.apache.tools.ant.util.CollectionUtils; import org.apache.tools.ant.util.CollectionUtils;
import org.apache.tools.ant.util.DOMElementWriter; import org.apache.tools.ant.util.DOMElementWriter;
import org.apache.tools.ant.util.FileUtils; import org.apache.tools.ant.util.FileUtils;
import org.apache.tools.ant.util.JavaEnvUtils;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Element; import org.w3c.dom.Element;


@@ -344,6 +349,24 @@ public class EchoProperties extends Task {
public Enumeration keys() { public Enumeration keys() {
return CollectionUtils.asEnumeration(keyList.iterator()); return CollectionUtils.asEnumeration(keyList.iterator());
} }
public Set entrySet() {
Set result = super.entrySet();
if (JavaEnvUtils.isKaffe()) {
TreeSet t = new TreeSet(new Comparator() {
public boolean equals(Object o) {
return false;
}
public int compare(Object o1, Object o2) {
String key1 = (String) ((Map.Entry) o1).getKey();
String key2 = (String) ((Map.Entry) o2).getKey();
return key1.compareTo(key2);
}
});
t.addAll(result);
result = t;
}
return result;
}
}; };
for (int i = 0; i < keyList.size(); i++) { for (int i = 0; i < keyList.size(); i++) {
String name = keyList.get(i).toString(); String name = keyList.get(i).toString();


Loading…
Cancel
Save