[jdom-interest] Comparators (was: Text class (Modified))

Noam Tamim noamt at yahoo.com
Sat Jun 2 17:05:11 PDT 2001

[class Text implements Comparable?]
> The main question is whether anybody needs this. If there isn't a
> real pressing use case for it, then I'd propose leaving it till at
> least 1.1. We can certainly add it later. There's no need to lock
> ourselves in now.

I don't think it should be added at all, because the "natural order" of xml
nodes is not very clear. What can be done, is writing (perhaps in
jdom.contrib) a class that has many Comparator objects. Something like:

class JDOMComparators {
    public final static Comparator ElementTextComparator=new Comparator() {
        public int compare(Object o1, Object o2) {
            Element e1=(Element)o1;
            Element e2=(Element)o2;
            return e1.getText().compareTo(e2.getText());
    public final static Comparator TextComparator ...
    // etc.

If anyone here thinks it's a good idea, I may do it.

 - Noam.

More information about the jdom-interest mailing list