Index: FeatureQueryOrder.java
===================================================================
--- FeatureQueryOrder.java	(revision 44643)
+++ FeatureQueryOrder.java	(revision 44644)
@@ -23,6 +23,7 @@
 package org.gvsig.fmap.dal.feature;
 
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.Comparator;
 import java.util.Iterator;
 import java.util.List;
@@ -97,13 +98,42 @@
             return (FeatureQueryOrderMember) super.clone();
         }
 
+        public void setAscending(boolean ascending) {
+            this.ascending = ascending;
+        }
+
     }
 
-    private List members = new ArrayList();
+    private List<FeatureQueryOrderMember> members = new ArrayList();
 
     public FeatureQueryOrder() {
     }
         
+    @Override
+    public String toString() {
+        StringBuilder builder = new StringBuilder();
+        boolean needComma = false;
+        for (FeatureQueryOrderMember member : members) {
+            if( member!=null && !StringUtils.isBlank(member.getAttributeName()) ) {
+                if( needComma ) {
+                    builder.append(",");
+                }
+                if( member.ascending ) {
+                    builder.append("+");
+                } else {
+                    builder.append("-");
+                }
+                builder.append(member.getAttributeName());
+                needComma = true;
+            }
+        }
+        String s = builder.toString();
+        if( StringUtils.isBlank(s) ) {
+            return null;
+        }
+        return s;
+    }
+    
     public Object add(String order) {
         if( StringUtils.isEmpty(order) ) {
             return null;
@@ -198,18 +228,68 @@
     public int size() {
         return this.members.size();
     }
+    
+    public int getIndex(String attributeName) {
+        int n = 0;
+        for (FeatureQueryOrderMember member : members) {
+            if( member!=null && StringUtils.equalsIgnoreCase(attributeName, member.getAttributeName()) ) {
+                return n;
+            }
+            n++;
+        }
+        return -1;
+    }
+    
+    public void movePrevious(String name) {
+        int n = this.getIndex(name);
+        if( n<1 ) {
+            return;
+        }
+        Collections.swap(members, n, n-1);
+    }
 
-    public Comparator getFeatureComparator() {
+    public void moveNext(String name) {
+        int n = this.getIndex(name);
+        if( n>=this.members.size()-1 ) {
+            return;
+        }
+        Collections.swap(members, n, n+1);
+    }
+
+    public boolean isEmpty() {
+        return this.members==null || this.members.isEmpty();
+    }
+    
+    public FeatureQueryOrderMember get(String attributeName) {
+        for (FeatureQueryOrderMember member : members) {
+            if( member!=null && StringUtils.equalsIgnoreCase(attributeName, member.getAttributeName()) ) {
+                return member;
+            }
+        }
+        return null;
+    }
+    
+    public boolean contains(String attributeName) {
+        for (FeatureQueryOrderMember member : members) {
+            if( member!=null && StringUtils.equalsIgnoreCase(attributeName, member.getAttributeName()) ) {
+                return true;
+            }
+        }
+        return false;
+    }
+    
+    public Comparator<Feature> getFeatureComparator() {
         return new DefaultFeatureComparator(this);
     }
 
-    public Object clone() throws CloneNotSupportedException {
+    @Override
+    public FeatureQueryOrder clone() throws CloneNotSupportedException {
         FeatureQueryOrder clone = (FeatureQueryOrder) super.clone();
 
         if (members != null) {
             clone.members = new ArrayList(members.size());
             for (int i = 0; i < members.size(); i++) {
-                clone.members.add(((Cloneable) members.get(i)).clone());
+                clone.members.add((members.get(i)).clone());
             }
         }
 
@@ -231,18 +311,20 @@
         return aCopy;
     }
 
+    @Override
     public void loadFromState(PersistentState state)
             throws PersistenceException {
         this.members = (List) state.get("menbers");
     }
 
+    @Override
     public void saveToState(PersistentState state) throws PersistenceException {
         state.set("menbers", members);
     }
 
-    private class DefaultFeatureComparator implements Comparator {
+    private class DefaultFeatureComparator implements Comparator<Feature> {
 
-        private FeatureQueryOrder order;
+        private final FeatureQueryOrder order;
 
         public DefaultFeatureComparator(FeatureQueryOrder order) {
             this.order = order;
@@ -278,11 +360,12 @@
 
         }
 
-        public int compare(Object arg0, Object arg1) {
+        @Override
+        public int compare(Feature f0, Feature f1) {
             Iterator iter = this.order.iterator();
             int returnValue = 0;
-            Feature f0 = (Feature) arg0;
-            Feature f1 = (Feature) arg1;
+//            Feature f0 = (Feature) arg0;
+//            Feature f1 = (Feature) arg1;
             Object item;
             String attrName;
             Evaluator evaluator;
