]> source.dussan.org Git - vaadin-framework.git/commitdiff
#6527 Container refactoring: first version of AbstractInMemoryContainer with some...
authorHenri Sara <henri.sara@itmill.com>
Tue, 1 Mar 2011 10:45:53 +0000 (10:45 +0000)
committerHenri Sara <henri.sara@itmill.com>
Tue, 1 Mar 2011 10:45:53 +0000 (10:45 +0000)
svn changeset:17521/svn branch:6.6

src/com/vaadin/data/util/AbstractBeanContainer.java
src/com/vaadin/data/util/AbstractInMemoryContainer.java [new file with mode: 0644]
src/com/vaadin/data/util/IndexedContainer.java

index f8ea7ebdd1cf04bbcc18be8b53c71f8ec4479f08..1c65003c9bf4e103d59bf5e06f2496fbf77e06d7 100644 (file)
@@ -19,10 +19,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
-import com.vaadin.data.Container;
 import com.vaadin.data.Container.Filterable;
-import com.vaadin.data.Container.Indexed;
-import com.vaadin.data.Container.ItemSetChangeNotifier;
 import com.vaadin.data.Container.Sortable;
 import com.vaadin.data.Item;
 import com.vaadin.data.Property;
@@ -61,8 +58,8 @@ import com.vaadin.data.Property.ValueChangeNotifier;
  * @since 6.5
  */
 public abstract class AbstractBeanContainer<IDTYPE, BEANTYPE> extends
-        AbstractContainer implements Indexed, Filterable, Sortable,
-        ValueChangeListener, ItemSetChangeNotifier {
+        AbstractInMemoryContainer<IDTYPE, String, BeanItem<BEANTYPE>> implements
+        Filterable, Sortable, ValueChangeListener {
 
     /**
      * Resolver that maps beans to their (item) identifiers, removing the need
@@ -152,19 +149,6 @@ public abstract class AbstractBeanContainer<IDTYPE, BEANTYPE> extends
      */
     private Set<Filter> filters = new HashSet<Filter>();
 
-    /**
-     * The filteredItems variable contains the ids for items that are visible
-     * outside the container. If filters are enabled this contains a subset of
-     * allItems, if no filters are set this contains the same items as allItems.
-     */
-    private ListSet<IDTYPE> filteredItemIds = new ListSet<IDTYPE>();
-
-    /**
-     * The allItems variable always contains the ids for all the items in the
-     * container. Some or all of these are also in the filteredItems list.
-     */
-    private ListSet<IDTYPE> allItemIds = new ListSet<IDTYPE>();
-
     /**
      * Maps all item ids in the container (including filtered) to their
      * corresponding BeanItem.
@@ -191,6 +175,8 @@ public abstract class AbstractBeanContainer<IDTYPE, BEANTYPE> extends
      *             If {@code type} is null
      */
     protected AbstractBeanContainer(Class<? super BEANTYPE> type) {
+        super(new ListSet<IDTYPE>());
+        setFilteredItemIds(new ListSet<IDTYPE>());
         if (type == null) {
             throw new IllegalArgumentException(
                     "The bean type passed to AbstractBeanContainer must not be null");
@@ -268,25 +254,6 @@ public abstract class AbstractBeanContainer<IDTYPE, BEANTYPE> extends
         throw new UnsupportedOperationException();
     }
 
-    @Override
-    public void addListener(Container.ItemSetChangeListener listener) {
-        super.addListener(listener);
-    }
-
-    @Override
-    public void removeListener(Container.ItemSetChangeListener listener) {
-        super.removeListener(listener);
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see com.vaadin.data.Container#size()
-     */
-    public int size() {
-        return filteredItemIds.size();
-    }
-
     /*
      * (non-Javadoc)
      * 
@@ -294,7 +261,7 @@ public abstract class AbstractBeanContainer<IDTYPE, BEANTYPE> extends
      */
     public boolean removeAllItems() {
         allItemIds.clear();
-        filteredItemIds.clear();
+        getFilteredItemIds().clear();
         // detach listeners from all Items
         for (Item item : itemIdToItem.values()) {
             removeAllValueChangeListeners(item);
@@ -304,21 +271,12 @@ public abstract class AbstractBeanContainer<IDTYPE, BEANTYPE> extends
         return true;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see com.vaadin.data.Container#containsId(java.lang.Object)
-     */
-    public boolean containsId(Object itemId) {
-        // only look at visible items after filtering
-        return filteredItemIds.contains(itemId);
-    }
-
     /*
      * (non-Javadoc)
      * 
      * @see com.vaadin.data.Container#getItem(java.lang.Object)
      */
+    @Override
     public BeanItem<BEANTYPE> getItem(Object itemId) {
         return itemIdToItem.get(itemId);
     }
@@ -328,9 +286,10 @@ public abstract class AbstractBeanContainer<IDTYPE, BEANTYPE> extends
      * 
      * @see com.vaadin.data.Container#getItemIds()
      */
+    @Override
     @SuppressWarnings("unchecked")
     public Collection<IDTYPE> getItemIds() {
-        return (Collection<IDTYPE>) filteredItemIds.clone();
+        return (Collection<IDTYPE>) super.getItemIds();
     }
 
     /*
@@ -360,7 +319,7 @@ public abstract class AbstractBeanContainer<IDTYPE, BEANTYPE> extends
         removeAllValueChangeListeners(getItem(itemId));
         // remove item
         itemIdToItem.remove(itemId);
-        filteredItemIds.remove(itemId);
+        getFilteredItemIds().remove(itemId);
         fireItemSetChange();
         return true;
     }
@@ -381,16 +340,17 @@ public abstract class AbstractBeanContainer<IDTYPE, BEANTYPE> extends
     @SuppressWarnings("unchecked")
     protected void filterAll() {
         // avoid notification if the filtering had no effect
-        List<IDTYPE> originalItems = filteredItemIds;
+        List<IDTYPE> originalItems = getFilteredItemIds();
         // it is somewhat inefficient to do a (shallow) clone() every time
-        filteredItemIds = (ListSet<IDTYPE>) allItemIds.clone();
+        setFilteredItemIds((List<IDTYPE>) ((ListSet<IDTYPE>) allItemIds)
+                .clone());
         for (Filter f : filters) {
             filter(f);
         }
         // check if exactly the same items are there after filtering to avoid
         // unnecessary notifications
         // this may be slow in some cases as it uses BEANTYPE.equals()
-        if (!originalItems.equals(filteredItemIds)) {
+        if (!originalItems.equals(getFilteredItemIds())) {
             fireItemSetChange();
         }
     }
@@ -412,7 +372,7 @@ public abstract class AbstractBeanContainer<IDTYPE, BEANTYPE> extends
      *            The filter used to determine if items should be removed
      */
     protected void filter(Filter f) {
-        Iterator<IDTYPE> iterator = filteredItemIds.iterator();
+        Iterator<IDTYPE> iterator = getFilteredItemIds().iterator();
         while (iterator.hasNext()) {
             IDTYPE itemId = iterator.next();
             if (!f.passesFilter(getItem(itemId))) {
@@ -432,7 +392,8 @@ public abstract class AbstractBeanContainer<IDTYPE, BEANTYPE> extends
     public void addContainerFilter(Object propertyId, String filterString,
             boolean ignoreCase, boolean onlyMatchPrefix) {
         if (filters.isEmpty()) {
-            filteredItemIds = (ListSet<IDTYPE>) allItemIds.clone();
+            setFilteredItemIds((List<IDTYPE>) ((ListSet<IDTYPE>) allItemIds)
+                    .clone());
         }
         // listen to change events to be able to update filtering
         for (Item item : itemIdToItem.values()) {
@@ -537,98 +498,6 @@ public abstract class AbstractBeanContainer<IDTYPE, BEANTYPE> extends
         }
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see com.vaadin.data.Container.Ordered#nextItemId(java.lang.Object)
-     */
-    public IDTYPE nextItemId(Object itemId) {
-        int index = indexOfId(itemId);
-        if (index >= 0 && index < size() - 1) {
-            return getIdByIndex(index + 1);
-        } else {
-            // out of bounds
-            return null;
-        }
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see com.vaadin.data.Container.Ordered#prevItemId(java.lang.Object)
-     */
-    public IDTYPE prevItemId(Object itemId) {
-        int index = indexOfId(itemId);
-        if (index > 0) {
-            return getIdByIndex(index - 1);
-        } else {
-            // out of bounds
-            return null;
-        }
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see com.vaadin.data.Container.Ordered#firstItemId()
-     */
-    public IDTYPE firstItemId() {
-        if (size() > 0) {
-            return getIdByIndex(0);
-        } else {
-            return null;
-        }
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see com.vaadin.data.Container.Ordered#lastItemId()
-     */
-    public IDTYPE lastItemId() {
-        if (size() > 0) {
-            return getIdByIndex(size() - 1);
-        } else {
-            return null;
-        }
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see com.vaadin.data.Container.Ordered#isFirstId(java.lang.Object)
-     */
-    public boolean isFirstId(Object itemId) {
-        return firstItemId() == itemId;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see com.vaadin.data.Container.Ordered#isLastId(java.lang.Object)
-     */
-    public boolean isLastId(Object itemId) {
-        return lastItemId() == itemId;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see com.vaadin.data.Container.Indexed#getIdByIndex(int)
-     */
-    public IDTYPE getIdByIndex(int index) {
-        return filteredItemIds.get(index);
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see com.vaadin.data.Container.Indexed#indexOfId(java.lang.Object)
-     */
-    public int indexOfId(Object itemId) {
-        return filteredItemIds.indexOf(itemId);
-    }
-
     /**
      * Unsupported operation. Use other methods to add items.
      */
diff --git a/src/com/vaadin/data/util/AbstractInMemoryContainer.java b/src/com/vaadin/data/util/AbstractInMemoryContainer.java
new file mode 100644 (file)
index 0000000..4facd29
--- /dev/null
@@ -0,0 +1,212 @@
+package com.vaadin.data.util;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import com.vaadin.data.Container;
+import com.vaadin.data.Container.ItemSetChangeNotifier;
+import com.vaadin.data.Item;
+
+/**
+ * Abstract {@link Container} class that handles common functionality for
+ * in-memory containers. Concrete in-memory container classes can either inherit
+ * this class, inherit {@link AbstractContainer}, or implement the
+ * {@link Container} interface directly.
+ * 
+ * TODO this version does not implement {@link Container.Sortable}
+ * 
+ * TODO this version does not implement {@link Container.Filterable}
+ * 
+ * TODO this version does not implement container modification methods
+ * 
+ * Features:
+ * <ul>
+ * <li> {@link Container.Ordered}
+ * <li> {@link Container.Indexed}
+ * </ul>
+ * 
+ * @param <ITEMIDTYPE>
+ *            the class of item identifiers in the container, use Object if can
+ *            be any class
+ * @param <PROPERTYIDCLASS>
+ *            the class of property identifiers for the items in the container,
+ *            use Object if can be any class
+ * @param <ITEMCLASS>
+ *            the (base) class of the Item instances in the container, use
+ *            {@link Item} if unknown
+ * 
+ * @since 6.6
+ */
+public abstract class AbstractInMemoryContainer<ITEMIDTYPE, PROPERTYIDCLASS, ITEMCLASS extends Item>
+        extends AbstractContainer implements ItemSetChangeNotifier,
+        Container.Indexed {
+
+    /**
+     * An ordered {@link List} of all item identifiers in the container,
+     * including those that have been filtered out.
+     * 
+     * Must not be null.
+     */
+    protected List<ITEMIDTYPE> allItemIds;
+
+    /**
+     * An ordered {@link List} of item identifiers in the container after
+     * filtering, excluding those that have been filtered out.
+     * 
+     * This is what the external API of the {@link Container} interface and its
+     * subinterfaces shows (e.g. {@link #size()}, {@link #nextItemId(Object)}).
+     * 
+     * If null, the full item id list is used instead.
+     */
+    private List<ITEMIDTYPE> filteredItemIds;
+
+    // Constructors
+
+    /**
+     * Constructor for an abstract in-memory container.
+     * 
+     * @param allItemIds
+     *            the internal {@link List} of item identifiers which must not
+     *            be null; used and modified by various operations
+     */
+    protected AbstractInMemoryContainer(List<ITEMIDTYPE> allItemIds) {
+        this.allItemIds = allItemIds;
+    }
+
+    // Container interface methods with more specific return class
+
+    public abstract ITEMCLASS getItem(Object itemId);
+
+    // cannot override getContainerPropertyIds() and getItemIds(): if subclass
+    // uses Object as ITEMIDCLASS or PROPERTYIDCLASS, Collection<Object> cannot
+    // be cast to Collection<MyInterface>
+
+    // public abstract Collection<PROPERTYIDCLASS> getContainerPropertyIds();
+    // public abstract Collection<ITEMIDCLASS> getItemIds();
+
+    // Container interface method implementations
+
+    public int size() {
+        return getVisibleItemIds().size();
+    }
+
+    public boolean containsId(Object itemId) {
+        // only look at visible items after filtering
+        return getVisibleItemIds().contains(itemId);
+    }
+
+    public Collection<?> getItemIds() {
+        return Collections.unmodifiableCollection(getVisibleItemIds());
+    }
+
+    // Container.Ordered
+
+    public ITEMIDTYPE nextItemId(Object itemId) {
+        int index = indexOfId(itemId);
+        if (index >= 0 && index < size() - 1) {
+            return getIdByIndex(index + 1);
+        } else {
+            // out of bounds
+            return null;
+        }
+    }
+
+    public ITEMIDTYPE prevItemId(Object itemId) {
+        int index = indexOfId(itemId);
+        if (index > 0) {
+            return getIdByIndex(index - 1);
+        } else {
+            // out of bounds
+            return null;
+        }
+    }
+
+    public ITEMIDTYPE firstItemId() {
+        if (size() > 0) {
+            return getIdByIndex(0);
+        } else {
+            return null;
+        }
+    }
+
+    public ITEMIDTYPE lastItemId() {
+        if (size() > 0) {
+            return getIdByIndex(size() - 1);
+        } else {
+            return null;
+        }
+    }
+
+    public boolean isFirstId(Object itemId) {
+        if (itemId == null) {
+            return false;
+        }
+        return itemId.equals(firstItemId());
+    }
+
+    public boolean isLastId(Object itemId) {
+        if (itemId == null) {
+            return false;
+        }
+        return itemId.equals(lastItemId());
+    }
+
+    // Container.Indexed
+
+    public ITEMIDTYPE getIdByIndex(int index) {
+        return getVisibleItemIds().get(index);
+    }
+
+    public int indexOfId(Object itemId) {
+        return getVisibleItemIds().indexOf(itemId);
+    }
+
+    // ItemSetChangeNotifier
+
+    @Override
+    public void addListener(Container.ItemSetChangeListener listener) {
+        super.addListener(listener);
+    }
+
+    @Override
+    public void removeListener(Container.ItemSetChangeListener listener) {
+        super.removeListener(listener);
+    }
+
+    // internal methods
+
+    /**
+     * Returns the internal list of visible item identifiers after filtering.
+     * 
+     * For internal use only.
+     */
+    protected List<ITEMIDTYPE> getVisibleItemIds() {
+        if (getFilteredItemIds() != null) {
+            return getFilteredItemIds();
+        } else {
+            return allItemIds;
+        }
+    }
+
+    /**
+     * TODO Temporary internal helper method to set the internal list of
+     * filtered item identifiers.
+     * 
+     * @param filteredItemIds
+     */
+    protected void setFilteredItemIds(List<ITEMIDTYPE> filteredItemIds) {
+        this.filteredItemIds = filteredItemIds;
+    }
+
+    /**
+     * TODO Temporary internal helper method to get the internal list of
+     * filtered item identifiers.
+     * 
+     * @return List<ITEMIDTYPE>
+     */
+    protected List<ITEMIDTYPE> getFilteredItemIds() {
+        return filteredItemIds;
+    }
+
+}
index 98bdf43778ce6c20bdfe96f9865a785f9fd05612..74cb4f596453e4425e51b35df5eab825ea5fa238 100644 (file)
@@ -14,11 +14,9 @@ import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Hashtable;
 import java.util.Iterator;
-import java.util.LinkedHashSet;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
-import java.util.NoSuchElementException;
 
 import com.vaadin.data.Container;
 import com.vaadin.data.Item;
@@ -47,21 +45,15 @@ import com.vaadin.data.Property;
  */
 
 @SuppressWarnings("serial")
-public class IndexedContainer extends AbstractContainer implements
-        Container.Indexed, Container.ItemSetChangeNotifier,
+// item type is really IndexedContainerItem, but using Item not to show it in
+// public API
+public class IndexedContainer extends
+        AbstractInMemoryContainer<Object, Object, Item> implements
         Container.PropertySetChangeNotifier, Property.ValueChangeNotifier,
         Container.Sortable, Cloneable, Container.Filterable {
 
     /* Internal structure */
 
-    /**
-     * Linked list of ordered Item IDs.
-     */
-    private ArrayList<Object> allItemIds = new ArrayList<Object>();
-
-    /** List of item ids that passes the filtering */
-    private LinkedHashSet<Object> filteredItemIds = null;
-
     /**
      * Linked list of ordered Property IDs.
      */
@@ -115,9 +107,11 @@ public class IndexedContainer extends AbstractContainer implements
     /* Container constructors */
 
     public IndexedContainer() {
+        super(new ArrayList<Object>());
     }
 
     public IndexedContainer(Collection<?> itemIds) {
+        this();
         if (items != null) {
             for (final Iterator<?> i = itemIds.iterator(); i.hasNext();) {
                 this.addItem(i.next());
@@ -132,29 +126,16 @@ public class IndexedContainer extends AbstractContainer implements
      * 
      * @see com.vaadin.data.Container#getItem(java.lang.Object)
      */
+    @Override
     public Item getItem(Object itemId) {
 
-        if (itemId != null
-                && items.containsKey(itemId)
-                && (getFilteredItemIds() == null || getFilteredItemIds()
-                        .contains(itemId))) {
+        if (itemId != null && items.containsKey(itemId)
+                && (getVisibleItemIds().contains(itemId))) {
             return new IndexedContainerItem(itemId);
         }
         return null;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see com.vaadin.data.Container#getItemIds()
-     */
-    public Collection<?> getItemIds() {
-        if (getFilteredItemIds() != null) {
-            return Collections.unmodifiableCollection(getFilteredItemIds());
-        }
-        return Collections.unmodifiableCollection(allItemIds);
-    }
-
     /*
      * (non-Javadoc)
      * 
@@ -195,31 +176,18 @@ public class IndexedContainer extends AbstractContainer implements
         return new IndexedContainerProperty(itemId, propertyId);
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see com.vaadin.data.Container#size()
-     */
-    public int size() {
-        if (getFilteredItemIds() == null) {
-            return allItemIds.size();
-        }
-        return getFilteredItemIds().size();
-    }
-
     /*
      * (non-Javadoc)
      * 
      * @see com.vaadin.data.Container#containsId(java.lang.Object)
      */
+    @Override
     public boolean containsId(Object itemId) {
         if (itemId == null) {
             return false;
+        } else {
+            return super.containsId(itemId);
         }
-        if (getFilteredItemIds() != null) {
-            return getFilteredItemIds().contains(itemId);
-        }
-        return items.containsKey(itemId);
     }
 
     /*
@@ -403,143 +371,6 @@ public class IndexedContainer extends AbstractContainer implements
 
     /* Container.Ordered methods */
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see com.vaadin.data.Container.Ordered#firstItemId()
-     */
-    public Object firstItemId() {
-        try {
-            if (getFilteredItemIds() != null) {
-                return getFilteredItemIds().iterator().next();
-            }
-            return allItemIds.get(0);
-        } catch (final IndexOutOfBoundsException e) {
-        } catch (final NoSuchElementException e) {
-        }
-        return null;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see com.vaadin.data.Container.Ordered#lastItemId()
-     */
-    public Object lastItemId() {
-        try {
-            if (getFilteredItemIds() != null) {
-                final Iterator<?> i = getFilteredItemIds().iterator();
-                Object last = null;
-                while (i.hasNext()) {
-                    last = i.next();
-                }
-                return last;
-            }
-            return allItemIds.get(allItemIds.size() - 1);
-        } catch (final IndexOutOfBoundsException e) {
-        }
-        return null;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see com.vaadin.data.Container.Ordered#nextItemId(java.lang.Object)
-     */
-    public Object nextItemId(Object itemId) {
-        if (getFilteredItemIds() != null) {
-            if (itemId == null || !getFilteredItemIds().contains(itemId)) {
-                return null;
-            }
-            final Iterator<?> i = getFilteredItemIds().iterator();
-            while (i.hasNext() && !itemId.equals(i.next())) {
-                ;
-            }
-            if (i.hasNext()) {
-                return i.next();
-            }
-            return null;
-        }
-        try {
-            int idx = allItemIds.indexOf(itemId);
-            if (idx == -1) {
-                // If the given Item is not found in the Container,
-                // null is returned.
-                return null;
-            }
-            return allItemIds.get(idx + 1);
-        } catch (final IndexOutOfBoundsException e) {
-            return null;
-        }
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see com.vaadin.data.Container.Ordered#prevItemId(java.lang.Object)
-     */
-    public Object prevItemId(Object itemId) {
-        if (getFilteredItemIds() != null) {
-            if (!getFilteredItemIds().contains(itemId)) {
-                return null;
-            }
-            final Iterator<?> i = getFilteredItemIds().iterator();
-            if (itemId == null) {
-                return null;
-            }
-            Object prev = null;
-            Object current;
-            while (i.hasNext() && !itemId.equals(current = i.next())) {
-                prev = current;
-            }
-            return prev;
-        }
-        try {
-            return allItemIds.get(allItemIds.indexOf(itemId) - 1);
-        } catch (final IndexOutOfBoundsException e) {
-            return null;
-        }
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see com.vaadin.data.Container.Ordered#isFirstId(java.lang.Object)
-     */
-    public boolean isFirstId(Object itemId) {
-        if (getFilteredItemIds() != null) {
-            try {
-                final Object first = getFilteredItemIds().iterator().next();
-                return (itemId != null && itemId.equals(first));
-            } catch (final NoSuchElementException e) {
-                return false;
-            }
-        }
-        return (size() >= 1 && allItemIds.get(0).equals(itemId));
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see com.vaadin.data.Container.Ordered#isLastId(java.lang.Object)
-     */
-    public boolean isLastId(Object itemId) {
-        if (getFilteredItemIds() != null) {
-            try {
-                Object last = null;
-                for (final Iterator<?> i = getFilteredItemIds().iterator(); i
-                        .hasNext();) {
-                    last = i.next();
-                }
-                return (itemId != null && itemId.equals(last));
-            } catch (final NoSuchElementException e) {
-                return false;
-            }
-        }
-        final int s = size();
-        return (s >= 1 && allItemIds.get(s - 1).equals(itemId));
-    }
-
     /*
      * (non-Javadoc)
      * 
@@ -581,55 +412,6 @@ public class IndexedContainer extends AbstractContainer implements
         }
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see com.vaadin.data.Container.Indexed#getIdByIndex(int)
-     */
-    public Object getIdByIndex(int index) {
-
-        if (getFilteredItemIds() != null) {
-            if (index < 0) {
-                throw new IndexOutOfBoundsException();
-            }
-            try {
-                final Iterator<?> i = getFilteredItemIds().iterator();
-                while (index-- > 0) {
-                    i.next();
-                }
-                return i.next();
-            } catch (final NoSuchElementException e) {
-                throw new IndexOutOfBoundsException();
-            }
-        }
-
-        return allItemIds.get(index);
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see com.vaadin.data.Container.Indexed#indexOfId(java.lang.Object)
-     */
-    public int indexOfId(Object itemId) {
-        if (getFilteredItemIds() != null) {
-            int index = 0;
-            if (itemId == null) {
-                return -1;
-            }
-            final Iterator<?> i = getFilteredItemIds().iterator();
-            while (i.hasNext()) {
-                Object id = i.next();
-                if (itemId.equals(id)) {
-                    return index;
-                }
-                index++;
-            }
-            return -1;
-        }
-        return allItemIds.indexOf(itemId);
-    }
-
     /*
      * (non-Javadoc)
      * 
@@ -796,16 +578,6 @@ public class IndexedContainer extends AbstractContainer implements
         super.removeListener(listener);
     }
 
-    @Override
-    public void addListener(Container.ItemSetChangeListener listener) {
-        super.addListener(listener);
-    }
-
-    @Override
-    public void removeListener(Container.ItemSetChangeListener listener) {
-        super.removeListener(listener);
-    }
-
     /*
      * (non-Javadoc)
      * 
@@ -1380,7 +1152,7 @@ public class IndexedContainer extends AbstractContainer implements
         final IndexedContainer nc = new IndexedContainer();
 
         // Clone the shallow properties
-        nc.allItemIds = allItemIds != null ? (ArrayList<Object>) allItemIds
+        nc.allItemIds = allItemIds != null ? (ArrayList<Object>) ((ArrayList<Object>) allItemIds)
                 .clone() : null;
         nc.setItemSetChangeListeners(getItemSetChangeListeners() != null ? new LinkedList<Container.ItemSetChangeListener>(
                 getItemSetChangeListeners()) : null);
@@ -1401,7 +1173,8 @@ public class IndexedContainer extends AbstractContainer implements
         nc.filters = filters == null ? null : (HashSet<Filter>) filters.clone();
 
         nc.setFilteredItemIds(getFilteredItemIds() == null ? null
-                : (LinkedHashSet<Object>) getFilteredItemIds().clone());
+                : (ListSet<Object>) ((ListSet<Object>) getFilteredItemIds())
+                        .clone());
 
         // Clone property-values
         if (items == null) {
@@ -1505,7 +1278,7 @@ public class IndexedContainer extends AbstractContainer implements
         }
         // Reset filtered list
         if (getFilteredItemIds() == null) {
-            setFilteredItemIds(new LinkedHashSet<Object>());
+            setFilteredItemIds(new ListSet<Object>());
         } else {
             getFilteredItemIds().clear();
         }
@@ -1547,12 +1320,4 @@ public class IndexedContainer extends AbstractContainer implements
         return true;
     }
 
-    private void setFilteredItemIds(LinkedHashSet<Object> filteredItemIds) {
-        this.filteredItemIds = filteredItemIds;
-    }
-
-    private LinkedHashSet<Object> getFilteredItemIds() {
-        return filteredItemIds;
-    }
-
 }
\ No newline at end of file