com.vaadin.data.util.
Class IndexedContainer
java.lang.Object
com.vaadin.data.util.AbstractContainer
com.vaadin.data.util.AbstractInMemoryContainer<Object,Object,Item>
com.vaadin.data.util.IndexedContainer
All Implemented Interfaces:
Container, Container.Filterable, Container.Indexed, Container.ItemSetChangeNotifier, Container.Ordered, Container.PropertySetChangeNotifier, Container.SimpleFilterable, Container.Sortable, Property.ValueChangeNotifier, Serializable, Cloneable
Direct Known Subclasses:
- extends AbstractInMemoryContainer<Object,Object,Item>
- implements Container.PropertySetChangeNotifier, Property.ValueChangeNotifier, Container.Sortable, Cloneable, Container.Filterable, Container.SimpleFilterable
public class IndexedContainer
An implementation of the
interface
with all important features.Container.Indexed
-
Container.Indexed
-
Container.Ordered
-
Container.Sortable
-
Container.Filterable
-
Cloneable
(deprecated, might be removed in the future) - Sends all needed events on content changes.
Since:
3.0
Version:
6.8.18
Author:
Vaadin Ltd.
See Also:
Nested Class Summary | |
---|---|
class |
IndexedContainer.ItemSetChangeEvent
An event object specifying the list whose Item set has
changed. |
Nested classes/interfaces inherited from class com.vaadin.data.util.AbstractContainer |
---|
AbstractContainer.BaseItemSetChangeEvent, AbstractContainer.BasePropertySetChangeEvent |
Nested classes/interfaces inherited from interface com.vaadin.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.Viewer |
Constructor Summary | |
---|---|
IndexedContainer()
|
|
IndexedContainer(Collection<?> itemIds)
|
Method Summary | |
---|---|
void |
addContainerFilter(Container.Filter filter)
Adds a filter for the container. |
void |
addContainerFilter(Object propertyId,
String filterString,
boolean ignoreCase,
boolean onlyMatchPrefix)
Add a filter for given property. |
boolean |
addContainerProperty(Object propertyId,
Class<?> type,
Object defaultValue)
Adds a new Property to all Items in the Container. |
Object |
addItem()
Creates a new Item into the Container, and assign it an automatic ID. |
Item |
addItem(Object itemId)
Creates a new Item with the given ID in the Container. |
Object |
addItemAfter(Object previousItemId)
Adds a new item after the given item. |
Item |
addItemAfter(Object previousItemId,
Object newItemId)
Adds a new item after the given item. |
Object |
addItemAt(int index)
Adds a new item at given index (in the filtered view). |
Item |
addItemAt(int index,
Object newItemId)
Adds a new item at given index (in the filtered view). |
void |
addListener(Container.PropertySetChangeListener listener)
Implementation of the corresponding method in PropertySetChangeNotifier , override with the corresponding public
method and implement the interface to use this. |
void |
addListener(Property.ValueChangeListener listener)
Registers a new value change listener for this Property. |
Object |
clone()
Deprecated. cloning support might be removed from IndexedContainer in the future |
protected void |
fireItemAdded(int position,
Object itemId,
Item item)
Notify item set change listeners that an item has been added to the container. |
protected void |
fireItemSetChange()
Sends a simple Item set change event to all interested listeners, indicating that anything in the contents may have changed (items added, removed etc.). |
Property |
getContainerProperty(Object itemId,
Object propertyId)
Gets the Property identified by the given itemId and propertyId from the Container. |
Collection<?> |
getContainerPropertyIds()
Gets the ID's of all Properties stored in the Container. |
ItemSorter |
getItemSorter()
Returns the ItemSorter used for comparing items in a sort. |
Collection<?> |
getListeners(Class<?> eventType)
|
Collection<?> |
getSortableContainerPropertyIds()
Gets the container property IDs which can be used to sort the items. |
Class<?> |
getType(Object propertyId)
Gets the type of a Property stored in the list. |
protected Item |
getUnfilteredItem(Object itemId)
Get an item even if filtered out. |
protected void |
registerNewItem(int index,
Object newItemId,
Item item)
Registers a new item as having been added to the container. |
void |
removeAllContainerFilters()
Remove all active filters from the container. |
boolean |
removeAllItems()
Removes all Items from the Container. |
void |
removeContainerFilter(Container.Filter filter)
Removes a filter from the container. |
void |
removeContainerFilters(Object propertyId)
Remove all filters from the given property. |
boolean |
removeContainerProperty(Object propertyId)
Removes a Property specified by the given Property ID from the Container. |
boolean |
removeItem(Object itemId)
Removes the Item identified by ItemId from the Container. |
void |
removeListener(Container.PropertySetChangeListener listener)
Implementation of the corresponding method in PropertySetChangeNotifier , override with the corresponding public
method and implement the interface to use this. |
void |
removeListener(Property.ValueChangeListener listener)
Removes a previously registered value change listener. |
void |
setItemSorter(ItemSorter itemSorter)
Sets the ItemSorter used for comparing items in a sort. |
void |
sort(Object[] propertyId,
boolean[] ascending)
Sort method. |
Methods inherited from class com.vaadin.data.util.AbstractContainer |
---|
fireContainerPropertySetChange, fireContainerPropertySetChange, fireItemSetChange, getItemSetChangeListeners, getPropertySetChangeListeners, setItemSetChangeListeners, setPropertySetChangeListeners |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.vaadin.data.Container.Ordered |
---|
firstItemId, isFirstId, isLastId, lastItemId, nextItemId, prevItemId |
Methods inherited from interface com.vaadin.data.Container |
---|
containsId, getItem, getItemIds, size |
Constructor Detail |
---|
IndexedContainer
public IndexedContainer()
IndexedContainer
public IndexedContainer(Collection<?> itemIds)
Method Detail |
---|
getUnfilteredItem
protected Item getUnfilteredItem(Object itemId)
- Specified by:
getUnfilteredItem
in classAbstractInMemoryContainer<Object,Object,Item>
- Returns:
Description copied from class: AbstractInMemoryContainer
Get an item even if filtered out. For internal use only.
getContainerPropertyIds
public Collection<?> getContainerPropertyIds()
- Specified by:
getContainerPropertyIds
in interfaceContainer
- Returns:
- unmodifiable collection of Property IDs
Description copied from interface: Container
Gets the ID's of all Properties stored in the Container. The ID's cannot be modified through the returned collection.
getType
public Class<?> getType(Object propertyId)
- Parameters:
id
- the ID of the Property.- Returns:
- Type of the requested Property
Gets the type of a Property stored in the list.
getContainerProperty
public Property getContainerProperty(Object itemId,
Object propertyId)
- Specified by:
getContainerProperty
in 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
Description copied from interface: Container
Gets 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, null
is
returned.
addContainerProperty
public boolean addContainerProperty(Object propertyId,
Class<?> type,
Object defaultValue)
- Specified by:
addContainerProperty
in interfaceContainer
- Overrides:
addContainerProperty
in 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:
true
if the operation succeeded,false
if not
Description copied from interface: Container
Adds 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.
removeAllItems
public boolean removeAllItems()
- Specified by:
removeAllItems
in interfaceContainer
- Overrides:
removeAllItems
in classAbstractInMemoryContainer<Object,Object,Item>
- Returns:
true
if the operation succeeded,false
if not
Description copied from interface: Container
Removes all Items from the Container.
Note that Property ID and type information is preserved. This functionality is optional.
addItem
public Object addItem()
- Specified by:
addItem
in interfaceContainer
- Overrides:
addItem
in classAbstractInMemoryContainer<Object,Object,Item>
- Returns:
- ID of the newly created Item, or
null
in case of a failure
Description copied from interface: Container
Creates a new Item into the Container, and assign it an automatic ID.
The new ID is returned, or null
if the operation fails.
After a successful call you can use the
method to fetch the Item.
getItem
This functionality is optional.
addItem
public Item addItem(Object itemId)
- Specified by:
addItem
in interfaceContainer
- Overrides:
addItem
in classAbstractInMemoryContainer<Object,Object,Item>
- Parameters:
itemId
- ID of the Item to be created- Returns:
- Created new Item, or
null
in case of a failure
Description copied from interface: Container
Creates 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 null
if the operation fails or the
Container already contains a Item with the given ID.
This functionality is optional.
removeItem
public boolean removeItem(Object itemId)
- Specified by:
removeItem
in interfaceContainer
- Overrides:
removeItem
in classAbstractInMemoryContainer<Object,Object,Item>
- Parameters:
itemId
- ID of the Item to remove- Returns:
true
if the operation succeeded,false
if not
Description copied from interface: Container
Removes the Item identified by ItemId
from the Container.
Containers that support filtering should also allow removing an item that is currently filtered out.
This functionality is optional.
removeContainerProperty
public boolean removeContainerProperty(Object propertyId)
- Specified by:
removeContainerProperty
in interfaceContainer
- Overrides:
removeContainerProperty
in classAbstractInMemoryContainer<Object,Object,Item>
- Parameters:
propertyId
- ID of the Property to remove- Returns:
true
if the operation succeeded,false
if not
Description copied from interface: Container
Removes 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.
addItemAfter
public Item addItemAfter(Object previousItemId,
Object newItemId)
- Specified by:
addItemAfter
in interfaceContainer.Ordered
- Overrides:
addItemAfter
in 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:
Ordered: adding items in filtered or sorted containers
Description copied from interface: Container.Ordered
Adds a new item after the given item.
Adding an item after null item adds the item as first item of the ordered container.
addItemAfter
public Object addItemAfter(Object previousItemId)
- Specified by:
addItemAfter
in interfaceContainer.Ordered
- Overrides:
addItemAfter
in 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:
Ordered: adding items in filtered or sorted containers
Description copied from interface: Container.Ordered
Adds a new item after the given item.
Adding an item after null item adds the item as first item of the ordered container.
addItemAt
public Item addItemAt(int index,
Object newItemId)
- Specified by:
addItemAt
in interfaceContainer.Indexed
- Overrides:
addItemAt
in 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
Item
or null if the operation fails.
Description copied from interface: Container.Indexed
Adds 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.SimpleFilterable
and
Container.Sortable
for more information.
addItemAt
public Object addItemAt(int index)
- Specified by:
addItemAt
in interfaceContainer.Indexed
- Overrides:
addItemAt
in 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.
Description copied from interface: Container.Indexed
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.SimpleFilterable
and Container.Sortable
for more information.
registerNewItem
protected void registerNewItem(int index,
Object newItemId,
Item item)
- Overrides:
registerNewItem
in classAbstractInMemoryContainer<Object,Object,Item>
Description copied from class: AbstractInMemoryContainer
Registers 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 in AbstractInMemoryContainer
has already
been updated to reflect the new item when this method is called.
addListener
public void addListener(Container.PropertySetChangeListener listener)
- Specified by:
addListener
in interfaceContainer.PropertySetChangeNotifier
- Overrides:
addListener
in classAbstractContainer
- Parameters:
listener
- The new Listener to be registered- See Also:
PropertySetChangeNotifier#addListener(com.vaadin.data.Container.PropertySetChangeListener)
Description copied from class: AbstractContainer
Implementation of the corresponding method in
PropertySetChangeNotifier
, override with the corresponding public
method and implement the interface to use this.
removeListener
public void removeListener(Container.PropertySetChangeListener listener)
- Specified by:
removeListener
in interfaceContainer.PropertySetChangeNotifier
- Overrides:
removeListener
in classAbstractContainer
- Parameters:
listener
- Listener to be removed- See Also:
PropertySetChangeNotifier#removeListener(com.vaadin.data.Container. PropertySetChangeListener)
Description copied from class: AbstractContainer
Implementation of the corresponding method in
PropertySetChangeNotifier
, override with the corresponding public
method and implement the interface to use this.
addListener
public void addListener(Property.ValueChangeListener listener)
- Specified by:
addListener
in interfaceProperty.ValueChangeNotifier
- Parameters:
listener
- the new Listener to be registered
Description copied from interface: Property.ValueChangeNotifier
Registers a new value change listener for this Property.
removeListener
public void removeListener(Property.ValueChangeListener listener)
- Specified by:
removeListener
in interfaceProperty.ValueChangeNotifier
- Parameters:
listener
- listener to be removed
Description copied from interface: Property.ValueChangeNotifier
Removes a previously registered value change listener.
getListeners
public Collection<?> getListeners(Class<?> eventType)
- Overrides:
getListeners
in classAbstractContainer
fireItemAdded
protected void fireItemAdded(int position,
Object itemId,
Item item)
- Overrides:
fireItemAdded
in classAbstractInMemoryContainer<Object,Object,Item>
itemId
- id of the added itemitem
- the added item
Description copied from class: AbstractInMemoryContainer
Notify item set change listeners that an item has been added to the container. Unless subclasses specify otherwise, the default notification indicates a full refresh.
fireItemSetChange
protected void fireItemSetChange()
- Overrides:
fireItemSetChange
in classAbstractContainer
Description copied from class: AbstractContainer
Sends a simple Item set change event to all interested listeners, indicating that anything in the contents may have changed (items added, removed etc.).
sort
public void sort(Object[] propertyId,
boolean[] ascending)
- Specified by:
sort
in 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. Usetrue
to sort in ascending order,false
to use descending order.
Description copied from interface: Container.Sortable
Sort method. Sorts the container items. Sorting a container can irreversibly change the order of its items or only change the order temporarily, depending on the container.
getSortableContainerPropertyIds
public Collection<?> getSortableContainerPropertyIds()
- Specified by:
getSortableContainerPropertyIds
in interfaceContainer.Sortable
- Returns:
- the IDs of the properties that can be used for sorting the container
Description copied from interface: Container.Sortable
Gets the container property IDs which can be used to sort the items.
getItemSorter
public ItemSorter getItemSorter()
- Overrides:
getItemSorter
in classAbstractInMemoryContainer<Object,Object,Item>
- Returns:
- The ItemSorter used for comparing two items in a sort.
Description copied from class: AbstractInMemoryContainer
Returns the ItemSorter used for comparing items in a sort. See
AbstractInMemoryContainer.setItemSorter(ItemSorter)
for more information.
setItemSorter
public void setItemSorter(ItemSorter itemSorter)
- Overrides:
setItemSorter
in classAbstractInMemoryContainer<Object,Object,Item>
- Parameters:
itemSorter
- The ItemSorter used for comparing two items in a sort (not null).
Description copied from class: AbstractInMemoryContainer
Sets the ItemSorter used for comparing items in a sort. The
ItemSorter.compare(Object, Object)
method is called with item ids
to perform the sorting. A default ItemSorter is used if this is not
explicitly set.
clone
@Deprecated
public Object clone()
throws CloneNotSupportedException
- Throws:
CloneNotSupportedException
- if an object cannot be cloned. .
Deprecated. cloning support might be removed from IndexedContainer in the future
Supports cloning of the IndexedContainer cleanly.
addContainerFilter
public void addContainerFilter(Object propertyId,
String filterString,
boolean ignoreCase,
boolean onlyMatchPrefix)
- Specified by:
addContainerFilter
in 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.
Description copied from interface: Container.SimpleFilterable
Add a filter for given property.
The API Filterable#addContainerFilter(Filter)
is recommended
instead of this method. A SimpleStringFilter
can 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.
removeAllContainerFilters
public void removeAllContainerFilters()
- Specified by:
removeAllContainerFilters
in interfaceContainer.Filterable
- Specified by:
removeAllContainerFilters
in interfaceContainer.SimpleFilterable
Description copied from interface: Container.Filterable
Remove all active filters from the container.
removeContainerFilters
public void removeContainerFilters(Object propertyId)
- Specified by:
removeContainerFilters
in interfaceContainer.SimpleFilterable
- Parameters:
propertyId
- for which to remove filters
Description copied from interface: Container.SimpleFilterable
Remove all filters from the given property.
addContainerFilter
public void addContainerFilter(Container.Filter filter)
throws UnsupportedFilterException
- Specified by:
addContainerFilter
in interfaceContainer.Filterable
- Throws:
UnsupportedFilterException
- if the filter is not supported by the container
Description copied from interface: Container.Filterable
Adds a filter for the container. If a container has multiple filters, only items accepted by all filters are visible.
removeContainerFilter
public void removeContainerFilter(Container.Filter filter)
- Specified by:
removeContainerFilter
in interfaceContainer.Filterable
Description copied from interface: Container.Filterable
Removes a filter from the container. This requires that the equals() method considers the filters as equivalent (same instance or properly implemented equals() method).