Class IndexedContainer
- All Implemented Interfaces:
Container,Container.Filterable,Container.Indexed,Container.ItemSetChangeNotifier,Container.Ordered,Container.PropertySetChangeNotifier,Container.SimpleFilterable,Container.Sortable,Property.ValueChangeNotifier,Serializable,Cloneable
Container.Indexed interface
with all important features.
Features:
Container.IndexedContainer.OrderedContainer.SortableContainer.FilterableCloneable(deprecated, might be removed in the future)- Sends all needed events on content changes.
- Since:
- 3.0
- Author:
- Vaadin Ltd.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classAneventobject specifying the list whose Item set has changed.Nested classes/interfaces inherited from class com.vaadin.featurepack.data.util.AbstractInMemoryContainer
AbstractInMemoryContainer.BaseItemAddEvent, AbstractInMemoryContainer.BaseItemRemoveEventNested classes/interfaces inherited from class com.vaadin.featurepack.data.util.AbstractContainer
AbstractContainer.BaseItemSetChangeEvent, AbstractContainer.BasePropertySetChangeEventNested classes/interfaces inherited from interface com.vaadin.featurepack.data.Container
Container.Editor, Container.Filter, Container.Filterable, Container.Hierarchical, Container.Indexed, Container.ItemSetChangeListener, Container.ItemSetChangeNotifier, Container.Ordered, Container.PropertySetChangeEvent, Container.PropertySetChangeListener, Container.PropertySetChangeNotifier, Container.SimpleFilterable, Container.Sortable, Container.ViewerNested classes/interfaces inherited from interface com.vaadin.featurepack.data.Container.Indexed
Container.Indexed.ItemAddEvent, Container.Indexed.ItemRemoveEvent -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddContainerFilter(Container.Filter filter) Adds a filter for the container.voidaddContainerFilter(Object propertyId, String filterString, boolean ignoreCase, boolean onlyMatchPrefix) Add a filter for given property.booleanaddContainerProperty(Object propertyId, Class<?> type, Object defaultValue) Adds a new Property to all Items in the Container.addItem()Creates a new Item into the Container, and assign it an automatic ID.Creates a new Item with the given ID in the Container.addItemAfter(Object previousItemId) Adds a new item after the given item.addItemAfter(Object previousItemId, Object newItemId) Adds a new item after the given item.addItemAt(int index) Adds a new item at given index (in the filtered view).Adds a new item at given index (in the filtered view).voidDeprecated.voidImplementation of the corresponding method inContainer.PropertySetChangeNotifier, override with the corresponding public method and implement the interface to use this.voidRegisters a new value change listener for this Property.clone()Deprecated.As of 6.6.protected voidfireItemAdded(int position, Object itemId, Item item) Notify item set change listeners that an item has been added to the container.protected voidSends a simple Item set change event to all interested listeners, indicating that anything in the contents may have changed (items added, removed etc.).Returns the filters which have been applied to the containergetContainerProperty(Object itemId, Object propertyId) Gets the Property identified by the given itemId and propertyId from the Container.Collection<?> Gets the ID's of all Properties stored in the Container.Returns the ItemSorter used for comparing items in a sort.Collection<?> getListeners(Class<?> eventType) Collection<?> Gets the container property IDs which can be used to sort the items.Class<?> Gets the type of a Property stored in the list.protected ItemgetUnfilteredItem(Object itemId) Get an item even if filtered out.booleanReturns true if any filters have been applied to the container.protected voidregisterNewItem(int index, Object newItemId, Item item) Registers a new item as having been added to the container.voidRemove all active filters from the container.booleanRemoves all Items from the Container.voidRemoves a filter from the container.voidremoveContainerFilters(Object propertyId) Remove all filters from the given property.booleanremoveContainerProperty(Object propertyId) Removes a Property specified by the given Property ID from the Container.booleanremoveItem(Object itemId) Removes the Item identified byItemIdfrom the Container.voidDeprecated.As of 7.0, replaced byremovePropertySetChangeListener(Container.PropertySetChangeListener)voidImplementation of the corresponding method inContainer.PropertySetChangeNotifier, override with the corresponding public method and implement the interface to use this.voidRemoves a previously registered value change listener.voidsetItemSorter(ItemSorter itemSorter) Sets the ItemSorter used for comparing items in a sort.voidSorts the container items.Methods inherited from class com.vaadin.featurepack.data.util.AbstractInMemoryContainer
addFilter, addItemSetChangeListener, addListener, containsId, doFilterContainer, doSort, filterAll, fireItemRemoved, fireItemsAdded, fireItemsRemoved, firstItemId, getAllItemIds, getFilteredItemIds, getFilters, getFirstVisibleItem, getIdByIndex, getItem, getItemIds, getItemIds, getSortablePropertyIds, getVisibleItemIds, indexOfId, internalAddItemAfter, internalAddItemAt, internalAddItemAtEnd, internalRemoveAllItems, internalRemoveItem, isFiltered, isFirstId, isLastId, isPropertyFiltered, lastItemId, nextItemId, passesFilters, prevItemId, removeAllFilters, removeFilter, removeFilters, removeItemSetChangeListener, removeListener, setAllItemIds, setFilteredItemIds, setFilters, size, sortContainerMethods inherited from class com.vaadin.featurepack.data.util.AbstractContainer
fireContainerPropertySetChange, fireContainerPropertySetChange, fireItemSetChange, getItemSetChangeListeners, getPropertySetChangeListeners, setItemSetChangeListeners, setPropertySetChangeListenersMethods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.featurepack.data.Container
containsId, getItem, getItemIds, sizeMethods inherited from interface com.vaadin.featurepack.data.Container.Ordered
firstItemId, isFirstId, isLastId, lastItemId, nextItemId, prevItemId
-
Constructor Details
-
IndexedContainer
public IndexedContainer() -
IndexedContainer
-
-
Method Details
-
getUnfilteredItem
Description copied from class:AbstractInMemoryContainerGet an item even if filtered out. For internal use only.- Specified by:
getUnfilteredItemin classAbstractInMemoryContainer<Object,Object, Item> - Parameters:
itemId-- Returns:
-
getContainerPropertyIds
Description copied from interface:ContainerGets the ID's of all Properties stored in the Container. The ID's cannot be modified through the returned collection.- Specified by:
getContainerPropertyIdsin interfaceContainer- Returns:
- unmodifiable collection of Property IDs
-
getType
Gets the type of a Property stored in the list. -
getContainerProperty
Description copied from interface:ContainerGets the Property identified by the given itemId and propertyId from the Container. If the Container does not contain the item or it is filtered out, or the Container does not have the Property,nullis returned.- Specified by:
getContainerPropertyin interfaceContainer- Parameters:
itemId- ID of the visible Item which contains the PropertypropertyId- ID of the Property to retrieve- Returns:
- Property with the given ID or
null
-
addContainerProperty
Description copied from interface:ContainerAdds a new Property to all Items in the Container. The Property ID, data type and default value of the new Property are given as parameters.This functionality is optional.
- Specified by:
addContainerPropertyin interfaceContainer- Overrides:
addContainerPropertyin classAbstractInMemoryContainer<Object,Object, Item> - Parameters:
propertyId- ID of the Propertytype- Data type of the new PropertydefaultValue- The value all created Properties are initialized to- Returns:
trueif the operation succeeded,falseif not
-
removeAllItems
public boolean removeAllItems()Description copied from interface:ContainerRemoves all Items from the Container.Note that Property ID and type information is preserved. This functionality is optional.
- Specified by:
removeAllItemsin interfaceContainer- Overrides:
removeAllItemsin classAbstractInMemoryContainer<Object,Object, Item> - Returns:
trueif the operation succeeded,falseif not
-
addItem
Creates a new Item into the Container, and assign it an automatic ID.The new ID is returned, or
nullif the operation fails. After a successful call you can use themethod to fetch the Item.getItemThis functionality is optional.
The item ID is generated from a sequence of Integers. The id of the first added item is 1.
-
addItem
Description copied from interface:ContainerCreates a new Item with the given ID in the Container.The new Item is returned, and it is ready to have its Properties modified. Returns
nullif the operation fails or the Container already contains a Item with the given ID.This functionality is optional.
-
removeItem
Description copied from interface:ContainerRemoves the Item identified byItemIdfrom the Container.Containers that support filtering should also allow removing an item that is currently filtered out.
This functionality is optional.
- Specified by:
removeItemin interfaceContainer- Overrides:
removeItemin classAbstractInMemoryContainer<Object,Object, Item> - Parameters:
itemId- ID of the Item to remove- Returns:
trueif the operation succeeded,falseif not
-
removeContainerProperty
Description copied from interface:ContainerRemoves a Property specified by the given Property ID from the Container. Note that the Property will be removed from all Items in the Container.This functionality is optional.
- Specified by:
removeContainerPropertyin interfaceContainer- Overrides:
removeContainerPropertyin classAbstractInMemoryContainer<Object,Object, Item> - Parameters:
propertyId- ID of the Property to remove- Returns:
trueif the operation succeeded,falseif not
-
addItemAfter
Description copied from interface:Container.OrderedAdds a new item after the given item.Adding an item after null item adds the item as first item of the ordered container.
- Specified by:
addItemAfterin interfaceContainer.Ordered- Overrides:
addItemAfterin classAbstractInMemoryContainer<Object,Object, Item> - Parameters:
previousItemId- Id of the visible item in ordered container after which to insert the new item.newItemId- Id of the new item to be added.- Returns:
- new item or null if the operation fails.
- See Also:
-
addItemAfter
Adds a new item after the given item.Adding an item after null item adds the item as first item of the ordered container.
The item ID is generated from a sequence of Integers. The id of the first added item is 1.
- Specified by:
addItemAfterin interfaceContainer.Ordered- Overrides:
addItemAfterin classAbstractInMemoryContainer<Object,Object, Item> - Parameters:
previousItemId- Id of the visible item in ordered container after which to insert the new item.- Returns:
- item id the the created new item or null if the operation fails.
- See Also:
-
addItemAt
Description copied from interface:Container.IndexedAdds a new item at given index (in the filtered view).The indexes of the item currently in the given position and all the following items are incremented.
This method should apply filters to the added item after inserting it, possibly hiding it immediately. If the container is being sorted, the item may be added at the correct sorted position instead of the given position. See
Container.Indexed,Container.FilterableandContainer.Sortablefor more information.- Specified by:
addItemAtin interfaceContainer.Indexed- Overrides:
addItemAtin classAbstractInMemoryContainer<Object,Object, Item> - Parameters:
index- Index (in the filtered and sorted view) at which to add the new item.newItemId- Id of the new item to be added.- Returns:
- new
Itemor null if the operation fails.
-
addItemAt
Adds a new item at given index (in the filtered view).The indices of the item currently in the given position and all the following items are incremented.
This method should apply filters to the added item after inserting it, possibly hiding it immediately. If the container is being sorted, the item may be added at the correct sorted position instead of the given position. See
Container.Indexed,Container.Ordered,Container.FilterableandContainer.Sortablefor more information.The item ID is generated from a sequence of Integers. The id of the first added item is 1.
- Specified by:
addItemAtin interfaceContainer.Indexed- Overrides:
addItemAtin classAbstractInMemoryContainer<Object,Object, Item> - Parameters:
index- Index (in the filtered and sorted view) to add the new item.- Returns:
- item id of the created item or null if the operation fails.
-
registerNewItem
Description copied from class:AbstractInMemoryContainerRegisters a new item as having been added to the container. This can involve storing the item or any relevant information about it in internal container-specific collections if necessary, as well as registering listeners etc. The full identifier list inAbstractInMemoryContainerhas already been updated to reflect the new item when this method is called.- Overrides:
registerNewItemin classAbstractInMemoryContainer<Object,Object, Item> - Parameters:
index-newItemId-item-
-
addPropertySetChangeListener
Description copied from class:AbstractContainerImplementation of the corresponding method inContainer.PropertySetChangeNotifier, override with the corresponding public method and implement the interface to use this.- Specified by:
addPropertySetChangeListenerin interfaceContainer.PropertySetChangeNotifier- Overrides:
addPropertySetChangeListenerin classAbstractContainer- Parameters:
listener- The new Listener to be registered- See Also:
-
addListener
Deprecated.As of 7.0, replaced byaddPropertySetChangeListener(Container.PropertySetChangeListener)- Overrides:
addListenerin classAbstractContainer
-
removePropertySetChangeListener
Description copied from class:AbstractContainerImplementation of the corresponding method inContainer.PropertySetChangeNotifier, override with the corresponding public method and implement the interface to use this.- Specified by:
removePropertySetChangeListenerin interfaceContainer.PropertySetChangeNotifier- Overrides:
removePropertySetChangeListenerin classAbstractContainer- Parameters:
listener- Listener to be removed- See Also:
-
removeListener
Deprecated.As of 7.0, replaced byremovePropertySetChangeListener(Container.PropertySetChangeListener)- Overrides:
removeListenerin classAbstractContainer
-
addValueChangeListener
Description copied from interface:Property.ValueChangeNotifierRegisters a new value change listener for this Property.- Specified by:
addValueChangeListenerin interfaceProperty.ValueChangeNotifier- Parameters:
listener- the new Listener to be registered
-
removeValueChangeListener
Description copied from interface:Property.ValueChangeNotifierRemoves a previously registered value change listener.- Specified by:
removeValueChangeListenerin interfaceProperty.ValueChangeNotifier- Parameters:
listener- listener to be removed
-
getListeners
- Overrides:
getListenersin classAbstractContainer
-
fireItemAdded
Description copied from class:AbstractInMemoryContainerNotify item set change listeners that an item has been added to the container.- Overrides:
fireItemAddedin classAbstractInMemoryContainer<Object,Object, Item> - Parameters:
position- position of the added item in the viewitemId- id of the added itemitem- the added item
-
fireItemSetChange
protected void fireItemSetChange()Description copied from class:AbstractContainerSends a simple Item set change event to all interested listeners, indicating that anything in the contents may have changed (items added, removed etc.).- Overrides:
fireItemSetChangein classAbstractContainer
-
sort
Description copied from interface:Container.SortableSorts the container items.Sorting a container can irreversibly change the order of its items or only change the order temporarily, depending on the container.
- Specified by:
sortin interfaceContainer.Sortable- Parameters:
propertyId- Array of container property IDs, whose values are used to sort the items in container as primary, secondary, ... sorting criterion. All of the item IDs must be in the collection returned byContainer.Sortable.getSortableContainerPropertyIds()ascending- Array of sorting order flags corresponding to each property ID used in sorting. If this array is shorter than propertyId array, ascending order is assumed for items where the order is not specified. Usetrueto sort in ascending order,falseto use descending order.
-
getSortableContainerPropertyIds
Description copied from interface:Container.SortableGets the container property IDs which can be used to sort the items.- Specified by:
getSortableContainerPropertyIdsin interfaceContainer.Sortable- Returns:
- the IDs of the properties that can be used for sorting the container
-
getItemSorter
Description copied from class:AbstractInMemoryContainerReturns the ItemSorter used for comparing items in a sort. SeeAbstractInMemoryContainer.setItemSorter(ItemSorter)for more information.- Overrides:
getItemSorterin classAbstractInMemoryContainer<Object,Object, Item> - Returns:
- The ItemSorter used for comparing two items in a sort.
-
setItemSorter
Description copied from class:AbstractInMemoryContainerSets the ItemSorter used for comparing items in a sort. TheItemSorter.compare(Object, Object)method is called with item ids to perform the sorting. A default ItemSorter is used if this is not explicitly set.- Overrides:
setItemSorterin classAbstractInMemoryContainer<Object,Object, Item> - Parameters:
itemSorter- The ItemSorter used for comparing two items in a sort (not null).
-
clone
Deprecated.As of 6.6. Cloning support might be removed from IndexedContainer in the futureSupports cloning of the IndexedContainer cleanly.- Overrides:
clonein classObject- Throws:
CloneNotSupportedException- if an object cannot be cloned. .
-
addContainerFilter
public void addContainerFilter(Object propertyId, String filterString, boolean ignoreCase, boolean onlyMatchPrefix) Description copied from interface:Container.SimpleFilterableAdd a filter for given property.The API
Container.Filterable.addContainerFilter(Filter)is recommended instead of this method. ASimpleStringFiltercan be used with the new API to implement the old string filtering functionality.The filter accepts items for which toString() of the value of the given property contains or starts with given filterString. Other items are not visible in the container when filtered.
If a container has multiple filters, only items accepted by all filters are visible.
- Specified by:
addContainerFilterin interfaceContainer.SimpleFilterable- Parameters:
propertyId- Property for which the filter is applied to.filterString- String that must match the value of the propertyignoreCase- Determine if the casing can be ignored when comparing strings.onlyMatchPrefix- Only match prefixes; no other matches are included.
-
removeAllContainerFilters
public void removeAllContainerFilters()Description copied from interface:Container.FilterableRemove all active filters from the container.- Specified by:
removeAllContainerFiltersin interfaceContainer.Filterable- Specified by:
removeAllContainerFiltersin interfaceContainer.SimpleFilterable
-
removeContainerFilters
Description copied from interface:Container.SimpleFilterableRemove all filters from the given property.- Specified by:
removeContainerFiltersin interfaceContainer.SimpleFilterable- Parameters:
propertyId- for which to remove filters
-
addContainerFilter
Description copied from interface:Container.FilterableAdds a filter for the container.If a container has multiple filters, only items accepted by all filters are visible.
- Specified by:
addContainerFilterin interfaceContainer.Filterable- Throws:
UnsupportedFilterException- if the filter is not supported by the container
-
removeContainerFilter
Description copied from interface:Container.FilterableRemoves a filter from the container.This requires that the equals() method considers the filters as equivalent (same instance or properly implemented equals() method).
- Specified by:
removeContainerFilterin interfaceContainer.Filterable
-
hasContainerFilters
public boolean hasContainerFilters()Description copied from class:AbstractInMemoryContainerReturns true if any filters have been applied to the container.- Overrides:
hasContainerFiltersin classAbstractInMemoryContainer<Object,Object, Item> - Returns:
- true if the container has filters applied, false otherwise
-
getContainerFilters
Description copied from interface:Container.FilterableReturns the filters which have been applied to the container- Specified by:
getContainerFiltersin interfaceContainer.Filterable- Overrides:
getContainerFiltersin classAbstractInMemoryContainer<Object,Object, Item> - Returns:
- A collection of filters which have been applied to the container. An empty collection if no filters have been applied.
-
addPropertySetChangeListener(Container.PropertySetChangeListener)