Interface Container.Indexed
- All Superinterfaces:
Container,Container.Ordered,Serializable
- All Known Implementing Classes:
AbstractBeanContainer,AbstractInMemoryContainer,BeanContainer,BeanItemContainer,IndexedContainer,JPAContainer
- Enclosing interface:
Container
Items can be accessed by
their position in the container.
If the container is filtered or sorted, all indices refer to the filtered
and sorted view. However, the addItemAt() methods may add
items that will be filtered out after addition or moved to another
position based on sorting.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceAnEventobject specifying information about the added items.static interfaceAnEventobject specifying information about the removed items.Nested classes/interfaces inherited from interface com.vaadin.featurepack.data.Container
Container.Editor, Container.Filter, Container.Filterable, Container.Hierarchical, Container.Indexed, Container.ItemSetChangeEvent, Container.ItemSetChangeListener, Container.ItemSetChangeNotifier, Container.Ordered, Container.PropertySetChangeEvent, Container.PropertySetChangeListener, Container.PropertySetChangeNotifier, Container.SimpleFilterable, Container.Sortable, Container.Viewer -
Method Summary
Modifier and TypeMethodDescriptionaddItemAt(int index) Adds a new item at given index (in the filtered view).Adds a new item at given index (in the filtered view).getIdByIndex(int index) Get the item id for the item at the position given byindex.List<?> getItemIds(int startIndex, int numberOfItems) GetnumberOfItemsconsecutive item ids from the container, starting with the item id atstartIndex.intGets the index of the Item corresponding to the itemId.Methods inherited from interface com.vaadin.featurepack.data.Container
addContainerProperty, addItem, addItem, containsId, getContainerProperty, getContainerPropertyIds, getItem, getItemIds, getType, removeAllItems, removeContainerProperty, removeItem, sizeMethods inherited from interface com.vaadin.featurepack.data.Container.Ordered
addItemAfter, addItemAfter, firstItemId, isFirstId, isLastId, lastItemId, nextItemId, prevItemId
-
Method Details
-
indexOfId
Gets the index of the Item corresponding to the itemId. The following istruefor the returned index: 0 invalid input: '<'= index invalid input: '<' size(), or index = -1 if there is no visible item with that id in the container.- Parameters:
itemId- ID of an Item in the Container- Returns:
- index of the Item, or -1 if (the filtered and sorted view of) the Container does not include the Item
-
getIdByIndex
Get the item id for the item at the position given byindex.- Parameters:
index- the index of the requested item id- Returns:
- the item id of the item at the given index
- Throws:
IndexOutOfBoundsException- ifindexis outside the range of the container. (i.e.index < 0 || container.size()-1 < index)
-
getItemIds
GetnumberOfItemsconsecutive item ids from the container, starting with the item id atstartIndex.Implementations should return at most
numberOfItemsitem ids, but can contain less if the container has less items than required to fulfill the request. The returned list must hence contain all of the item ids from the range:startIndextomax(startIndex + (numberOfItems-1), container.size()-1).For quick migration to new API see:
ContainerHelpers.getItemIdsUsingGetIdByIndex(int, int, Indexed)- Parameters:
startIndex- the index for the first item which id to includenumberOfItems- the number of consecutive item ids to get from the given start index, must be >= 0- Returns:
- List containing the requested item ids or empty list if
numberOfItems== 0; not null - Throws:
IllegalArgumentException- ifnumberOfItemsis invalid input: '<' 0IndexOutOfBoundsException- ifstartIndexis outside the range of the container. (i.e.startIndex < 0 || container.size()-1 < startIndex)- Since:
- 7.0
-
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.- 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.
- Throws:
UnsupportedOperationException- if the operation is not supported by the container
-
addItemAt
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.FilterableandContainer.Sortablefor more information.- 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. - Throws:
UnsupportedOperationException- if the operation is not supported by the container
-