com.vaadin.data.util.
Class AbstractInMemoryContainer<ITEMIDTYPE,PROPERTYIDCLASS,ITEMCLASS extends Item>
java.lang.Object
com.vaadin.data.util.AbstractContainer
com.vaadin.data.util.AbstractInMemoryContainer<ITEMIDTYPE,PROPERTYIDCLASS,ITEMCLASS>
Type Parameters:
ITEMIDTYPE
- the class of item identifiers in the container, use Object if can
be any class
PROPERTYIDCLASS
- the class of property identifiers for the items in the container,
use Object if can be any class
ITEMCLASS
- the (base) class of the Item instances in the container, use
Item
if unknown
All Implemented Interfaces:
Container, Container.Indexed, Container.ItemSetChangeNotifier, Container.Ordered, Serializable
Direct Known Subclasses:
- extends AbstractContainer
- implements Container.ItemSetChangeNotifier, Container.Indexed
public abstract class AbstractInMemoryContainer<ITEMIDTYPE,PROPERTYIDCLASS,ITEMCLASS extends Item>
Abstract Container
class that handles common functionality for
in-memory containers. Concrete in-memory container classes can either inherit
this class, inherit AbstractContainer
, or implement the
Container
interface directly.
Adding and removing items (if desired) must be implemented in subclasses by
overriding the appropriate add*Item() and remove*Item() and removeAllItems()
methods, calling the corresponding
#internalAddItemAfter(Object, Object, Item)
,
#internalAddItemAt(int, Object, Item)
,
internalAddItemAtEnd(Object, Item, boolean)
,
internalRemoveItem(Object)
and internalRemoveAllItems()
methods.
By default, adding and removing container properties is not supported, and
subclasses need to implement Container.getContainerPropertyIds()
. Optionally,
subclasses can override addContainerProperty(Object, Class, Object)
and removeContainerProperty(Object)
to implement them.
Features:
-
Container.Ordered
-
Container.Indexed
-
Filterable
andSimpleFilterable
(internal implementation, does not implement the interface directly) -
Sortable
(internal implementation, does not implement the interface directly)
Sortable
, subclasses need to implement
getSortablePropertyIds()
and call the superclass method
sortContainer(Object[], boolean[])
in the method
sort(Object[], boolean[])
.
To implement Filterable
, subclasses need to implement the methods
Filterable#addContainerFilter(com.vaadin.data.Container.Filter)
(calling #addFilter(Filter)
),
Filterable#removeAllContainerFilters()
(calling
removeAllFilters()
) and
Filterable#removeContainerFilter(com.vaadin.data.Container.Filter)
(calling removeFilter(com.vaadin.data.Container.Filter)
).
To implement SimpleFilterable
, subclasses also need to implement the
methods
SimpleFilterable#addContainerFilter(Object, String, boolean, boolean)
and SimpleFilterable#removeContainerFilters(Object)
calling
addFilter(com.vaadin.data.Container.Filter)
and
removeFilters(Object)
respectively.
Since:
6.6
See Also:
Nested Class Summary |
---|
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.ItemSetChangeEvent, Container.ItemSetChangeListener, Container.ItemSetChangeNotifier, Container.Ordered, Container.PropertySetChangeEvent, Container.PropertySetChangeListener, Container.PropertySetChangeNotifier, Container.SimpleFilterable, Container.Sortable, Container.Viewer |
Constructor Summary | |
---|---|
protected |
AbstractInMemoryContainer()
Constructor for an abstract in-memory container. |
Method Summary | |
---|---|
boolean |
addContainerProperty(Object propertyId,
Class<?> type,
Object defaultValue)
Adds a new Property to all Items in the Container. |
protected void |
addFilter(Container.Filter filter)
Adds a container filter and re-filter the view. |
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.ItemSetChangeListener listener)
Implementation of the corresponding method in ItemSetChangeNotifier , override with the corresponding public
method and implement the interface to use this. |
boolean |
containsId(Object itemId)
Tests if the Container contains the specified Item. |
protected boolean |
doFilterContainer(boolean hasFilters)
Filters the data in the container and updates internal data structures. |
protected void |
doSort()
Perform the sorting of the data structures in the container. |
protected void |
filterAll()
Filter the view to recreate the visible item list from the unfiltered items, and send a notification if the set of visible items changed in any way. |
protected void |
fireItemAdded(int position,
ITEMIDTYPE itemId,
ITEMCLASS item)
Notify item set change listeners that an item has been added to the container. |
protected void |
fireItemRemoved(int position,
Object itemId)
Notify item set change listeners that an item has been removed from the container. |
ITEMIDTYPE |
firstItemId()
Gets the ID of the first Item in the Container. |
protected List<ITEMIDTYPE> |
getAllItemIds()
Internal helper method to get the internal list of all item identifiers. |
protected List<ITEMIDTYPE> |
getFilteredItemIds()
Internal helper method to get the internal list of filtered item identifiers. |
protected Set<Container.Filter> |
getFilters()
Returns the internal collection of filters. |
ITEMIDTYPE |
getIdByIndex(int index)
Gets the ID of an Item by an index number. |
ITEMCLASS |
getItem(Object itemId)
Gets the Item with the given Item ID from the Container. |
Collection<?> |
getItemIds()
Gets the ID's of all visible (after filtering and sorting) Items stored in the Container. |
protected ItemSorter |
getItemSorter()
Returns the ItemSorter used for comparing items in a sort. |
protected Collection<?> |
getSortablePropertyIds()
Returns the sortable property identifiers for the container. |
protected abstract ITEMCLASS |
getUnfilteredItem(Object itemId)
Get an item even if filtered out. |
protected List<ITEMIDTYPE> |
getVisibleItemIds()
Returns the internal list of visible item identifiers after filtering. |
int |
indexOfId(Object itemId)
Gets the index of the Item corresponding to the itemId. |
protected ITEMCLASS |
internalAddItemAfter(ITEMIDTYPE previousItemId,
ITEMIDTYPE newItemId,
ITEMCLASS item,
boolean filter)
Add an item after a given (visible) item, and perform filtering. |
protected ITEMCLASS |
internalAddItemAt(int index,
ITEMIDTYPE newItemId,
ITEMCLASS item,
boolean filter)
Add an item at a given (visible after filtering) item index, and perform filtering. |
protected ITEMCLASS |
internalAddItemAtEnd(ITEMIDTYPE newItemId,
ITEMCLASS item,
boolean filter)
Add an item at the end of the container, and perform filtering if necessary. |
protected void |
internalRemoveAllItems()
Removes all items from the internal data structures of this class. |
protected boolean |
internalRemoveItem(Object itemId)
Removes a single item from the internal data structures of this class. |
protected boolean |
isFiltered()
Returns true is the container has active filters. |
boolean |
isFirstId(Object itemId)
Tests if the Item corresponding to the given Item ID is the first Item in the Container. |
boolean |
isLastId(Object itemId)
Tests if the Item corresponding to the given Item ID is the last Item in the Container. |
protected boolean |
isPropertyFiltered(Object propertyId)
Checks if there is a filter that applies to a given property. |
ITEMIDTYPE |
lastItemId()
Gets the ID of the last Item in the Container.. |
ITEMIDTYPE |
nextItemId(Object itemId)
Gets the ID of the Item following the Item that corresponds to itemId . |
protected boolean |
passesFilters(Object itemId)
Checks if the given itemId passes the filters set for the container. |
ITEMIDTYPE |
prevItemId(Object itemId)
Gets the ID of the Item preceding the Item that corresponds to itemId . |
protected void |
registerNewItem(int position,
ITEMIDTYPE itemId,
ITEMCLASS item)
Registers a new item as having been added to the container. |
protected void |
removeAllFilters()
Remove all container filters for all properties and re-filter the view. |
boolean |
removeAllItems()
Removes all Items from the Container. |
boolean |
removeContainerProperty(Object propertyId)
Removes a Property specified by the given Property ID from the Container. |
protected void |
removeFilter(Container.Filter filter)
Remove a specific container filter and re-filter the view (if necessary). |
protected Collection<Container.Filter> |
removeFilters(Object propertyId)
Remove all container filters for a given property identifier and re-filter the view. |
boolean |
removeItem(Object itemId)
Removes the Item identified by ItemId from the Container. |
void |
removeListener(Container.ItemSetChangeListener listener)
Implementation of the corresponding method in ItemSetChangeNotifier , override with the corresponding public
method and implement the interface to use this. |
protected void |
setAllItemIds(List<ITEMIDTYPE> allItemIds)
Deprecated. |
protected void |
setFilteredItemIds(List<ITEMIDTYPE> filteredItemIds)
Deprecated. |
protected void |
setFilters(Set<Container.Filter> filters)
Set the internal collection of filters without performing filtering. |
protected void |
setItemSorter(ItemSorter itemSorter)
Sets the ItemSorter used for comparing items in a sort. |
int |
size()
Gets the number of visible Items in the Container. |
protected void |
sortContainer(Object[] propertyId,
boolean[] ascending)
Sort base implementation to be used to implement Sortable . |
Methods inherited from class com.vaadin.data.util.AbstractContainer |
---|
addListener, fireContainerPropertySetChange, fireContainerPropertySetChange, fireItemSetChange, fireItemSetChange, getItemSetChangeListeners, getListeners, getPropertySetChangeListeners, removeListener, setItemSetChangeListeners, setPropertySetChangeListeners |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.vaadin.data.Container |
---|
getContainerProperty, getContainerPropertyIds, getType |
Constructor Detail |
---|
AbstractInMemoryContainer
protected AbstractInMemoryContainer()
Constructor for an abstract in-memory container.
Method Detail |
---|
getItem
public ITEMCLASS getItem(Object itemId)
Description copied from interface: Container
Gets the Item
with the given Item ID from the Container. If the
Container does not contain the requested Item, null
is
returned.
Containers should not return Items that are filtered out.
getUnfilteredItem
protected abstract ITEMCLASS getUnfilteredItem(Object itemId)
- Parameters:
itemId
-- Returns:
Get an item even if filtered out. For internal use only.
size
public int size()
- Returns:
- number of Items in the Container
Description copied from interface: Container
Gets the number of visible Items in the Container. Filtering can hide items so that they will not be visible through the container API.
containsId
public boolean containsId(Object itemId)
- Specified by:
containsId
in interfaceContainer
- Parameters:
itemId
- ID the of Item to be tested- Returns:
- boolean indicating if the Container holds the specified Item
Description copied from interface: Container
Tests if the Container contains the specified Item. Filtering can hide items so that they will not be visible through the container API, and this method should respect visibility of items (i.e. only indicate visible items as being in the container) if feasible for the container.
getItemIds
public Collection<?> getItemIds()
- Specified by:
getItemIds
in interfaceContainer
- Returns:
- unmodifiable collection of Item IDs
Description copied from interface: Container
Gets the ID's of all visible (after filtering and sorting) Items stored
in the Container. The ID's cannot be modified through the returned
collection.
If the container is Container.Ordered
, the collection returned by this
method should follow that order. If the container is Container.Sortable
,
the items should be in the sorted order.
Calling this method for large lazy containers can be an expensive
operation and should be avoided when practical.
nextItemId
public ITEMIDTYPE nextItemId(Object itemId)
- Specified by:
nextItemId
in interfaceContainer.Ordered
- Parameters:
itemId
- ID of a visible Item in the Container- Returns:
- ID of the next visible Item or
null
Description copied from interface: Container.Ordered
Gets the ID of the Item following the Item that corresponds to
itemId
. If the given Item is the last or not found in
the Container, null
is returned.
prevItemId
public ITEMIDTYPE prevItemId(Object itemId)
- Specified by:
prevItemId
in interfaceContainer.Ordered
- Parameters:
itemId
- ID of a visible Item in the Container- Returns:
- ID of the previous visible Item or
null
Description copied from interface: Container.Ordered
Gets the ID of the Item preceding the Item that corresponds to
itemId
. If the given Item is the first or not found in
the Container, null
is returned.
firstItemId
public ITEMIDTYPE firstItemId()
- Specified by:
firstItemId
in interfaceContainer.Ordered
- Returns:
- ID of the first visible Item in the Container
Description copied from interface: Container.Ordered
Gets the ID of the first Item in the Container.
lastItemId
public ITEMIDTYPE lastItemId()
- Specified by:
lastItemId
in interfaceContainer.Ordered
- Returns:
- ID of the last visible Item in the Container
Description copied from interface: Container.Ordered
Gets the ID of the last Item in the Container..
isFirstId
public boolean isFirstId(Object itemId)
- Specified by:
isFirstId
in interfaceContainer.Ordered
- Parameters:
itemId
- ID of an Item in the Container- Returns:
true
if the Item is first visible item in the Container,false
if not
Description copied from interface: Container.Ordered
Tests if the Item corresponding to the given Item ID is the first Item in the Container.
isLastId
public boolean isLastId(Object itemId)
- Specified by:
isLastId
in interfaceContainer.Ordered
- Returns:
true
if the Item is last visible item in the Container,false
if not
Description copied from interface: Container.Ordered
Tests if the Item corresponding to the given Item ID is the last Item in the Container.
getIdByIndex
public ITEMIDTYPE getIdByIndex(int index)
- Specified by:
getIdByIndex
in interfaceContainer.Indexed
- Parameters:
index
- Index of the requested id in (the filtered and sorted view of) the Container- Returns:
- ID of the Item in the given index
Description copied from interface: Container.Indexed
Gets the ID of an Item by an index number.
indexOfId
public int indexOfId(Object itemId)
- Specified by:
indexOfId
in interfaceContainer.Indexed
- 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
Description copied from interface: Container.Indexed
Gets the index of the Item corresponding to the itemId. The following
is true
for the returned index: 0 <= index < size(), or
index = -1 if there is no visible item with that id in the container.
addItemAt
public Object addItemAt(int index)
throws UnsupportedOperationException
- Specified by:
addItemAt
in interfaceContainer.Indexed
- 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
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.
addItemAt
public Item addItemAt(int index,
Object newItemId)
throws UnsupportedOperationException
- Specified by:
addItemAt
in interfaceContainer.Indexed
- 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. - Throws:
UnsupportedOperationException
- if the operation is not supported by the container
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.
addItemAfter
public Object addItemAfter(Object previousItemId)
throws UnsupportedOperationException
- Specified by:
addItemAfter
in interfaceContainer.Ordered
- 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.
- Throws:
UnsupportedOperationException
- if the operation is not supported by the container- 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 Item addItemAfter(Object previousItemId,
Object newItemId)
throws UnsupportedOperationException
- Specified by:
addItemAfter
in interfaceContainer.Ordered
- 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.
- Throws:
UnsupportedOperationException
- if the operation is not supported by the container- 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.
addItem
public Item addItem(Object itemId)
throws UnsupportedOperationException
- Parameters:
itemId
- ID of the Item to be created- Returns:
- Created new Item, or
null
in case of a failure - Throws:
UnsupportedOperationException
- if adding an item with an explicit item ID is not supported by the container
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.
addItem
public Object addItem()
throws UnsupportedOperationException
- Returns:
- ID of the newly created Item, or
null
in case of a failure - Throws:
UnsupportedOperationException
- if adding an item without an explicit item ID is not supported by the container
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.
removeItem
public boolean removeItem(Object itemId)
throws UnsupportedOperationException
- Specified by:
removeItem
in interfaceContainer
- Parameters:
itemId
- ID of the Item to remove- Returns:
true
if the operation succeeded,false
if not- Throws:
UnsupportedOperationException
- if the container does not support removing individual items
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.
removeAllItems
public boolean removeAllItems()
throws UnsupportedOperationException
- Specified by:
removeAllItems
in interfaceContainer
- Returns:
true
if the operation succeeded,false
if not- Throws:
UnsupportedOperationException
- if the container does not support removing all items
Description copied from interface: Container
Removes all Items from the Container.
Note that Property ID and type information is preserved. This functionality is optional.
addContainerProperty
public boolean addContainerProperty(Object propertyId,
Class<?> type,
Object defaultValue)
throws UnsupportedOperationException
- Specified by:
addContainerProperty
in interfaceContainer
- 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- Throws:
UnsupportedOperationException
- if the container does not support explicitly adding container properties
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.
removeContainerProperty
public boolean removeContainerProperty(Object propertyId)
throws UnsupportedOperationException
- Specified by:
removeContainerProperty
in interfaceContainer
- Parameters:
propertyId
- ID of the Property to remove- Returns:
true
if the operation succeeded,false
if not- Throws:
UnsupportedOperationException
- if the container does not support removing container properties
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.
addListener
public void addListener(Container.ItemSetChangeListener listener)
- Specified by:
addListener
in interfaceContainer.ItemSetChangeNotifier
- Overrides:
addListener
in classAbstractContainer
- Parameters:
listener
- listener to be added- See Also:
ItemSetChangeNotifier#addListener(com.vaadin.data.Container.ItemSetChangeListener)
Description copied from class: AbstractContainer
Implementation of the corresponding method in
ItemSetChangeNotifier
, override with the corresponding public
method and implement the interface to use this.
removeListener
public void removeListener(Container.ItemSetChangeListener listener)
- Specified by:
removeListener
in interfaceContainer.ItemSetChangeNotifier
- Overrides:
removeListener
in classAbstractContainer
- Parameters:
listener
- listener to be removed- See Also:
ItemSetChangeNotifier#removeListener(com.vaadin.data.Container.ItemSetChangeListener)
Description copied from class: AbstractContainer
Implementation of the corresponding method in
ItemSetChangeNotifier
, override with the corresponding public
method and implement the interface to use this.
filterAll
protected void filterAll()
Filter the view to recreate the visible item list from the unfiltered items, and send a notification if the set of visible items changed in any way.
doFilterContainer
protected boolean doFilterContainer(boolean hasFilters)
- Parameters:
hasFilters
- true if filters has been set for the container, false otherwise- Returns:
- true if the item set has changed as a result of the filtering
Filters the data in the container and updates internal data structures.
This method should reset any internal data structures and then repopulate
them so getItemIds()
and other methods only return the filtered
items.
passesFilters
protected boolean passesFilters(Object itemId)
- Parameters:
itemId
- An itemId that exists in the container.- Returns:
- true if the itemId passes all filters or no filters are set, false otherwise.
Checks if the given itemId passes the filters set for the container. The caller should make sure the itemId exists in the container. For non-existing itemIds the behavior is undefined.
addFilter
protected void addFilter(Container.Filter filter)
throws UnsupportedFilterException
- Throws:
UnsupportedFilterException
- if the filter is detected as not supported by the container
Adds a container filter and re-filter the view.
The filter must implement Filter and its sub-filters (if any) must also
be in-memory filterable.
This can be used to implement
Filterable#addContainerFilter(com.vaadin.data.Container.Filter)
and optionally also
SimpleFilterable#addContainerFilter(Object, String, boolean, boolean)
(with SimpleStringFilter
).
Note that in some cases, incompatible filters cannot be detected when
added and an UnsupportedFilterException
may occur when performing
filtering.
removeFilter
protected void removeFilter(Container.Filter filter)
Remove a specific container filter and re-filter the view (if necessary).
This can be used to implement
Filterable#removeContainerFilter(com.vaadin.data.Container.Filter)
.
removeAllFilters
protected void removeAllFilters()
Remove all container filters for all properties and re-filter the view.
This can be used to implement
Filterable#removeAllContainerFilters()
.
isPropertyFiltered
protected boolean isPropertyFiltered(Object propertyId)
- Parameters:
propertyId
-- Returns:
- true if there is an active filter for the property
Checks if there is a filter that applies to a given property.
removeFilters
protected Collection<Container.Filter> removeFilters(Object propertyId)
- Parameters:
propertyId
-- Returns:
- Collection
removed filters
Remove all container filters for a given property identifier and
re-filter the view. This also removes filters applying to multiple
properties including the one identified by propertyId.
This can be used to implement
Filterable#removeContainerFilters(Object)
.
getItemSorter
protected ItemSorter getItemSorter()
- Returns:
- The ItemSorter used for comparing two items in a sort.
Returns the ItemSorter used for comparing items in a sort. See
setItemSorter(ItemSorter)
for more information.
setItemSorter
protected void setItemSorter(ItemSorter itemSorter)
- Parameters:
itemSorter
- The ItemSorter used for comparing two items in a sort (not null).
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.
sortContainer
protected void sortContainer(Object[] propertyId,
boolean[] ascending)
Sort base implementation to be used to implement Sortable
.
Subclasses should call this from a public
#sort(Object[], boolean[])
method when implementing Sortable.
doSort
protected void doSort()
Perform the sorting of the data structures in the container. This is
invoked when the itemSorter
has been prepared for the sort
operation. Typically this method calls
Collections.sort(aCollection, getItemSorter())
on all arrays
(containing item ids) that need to be sorted.
getSortablePropertyIds
protected Collection<?> getSortablePropertyIds()
Returns the sortable property identifiers for the container. Can be used
to implement Sortable#getSortableContainerPropertyIds()
.
internalRemoveAllItems
protected void internalRemoveAllItems()
Removes all items from the internal data structures of this class. This
can be used to implement removeAllItems()
in subclasses.
No notification is sent, the caller has to fire a suitable item set
change notification.
internalRemoveItem
protected boolean internalRemoveItem(Object itemId)
- Parameters:
itemId
- the identifier of the item to remove- Returns:
- true if an item was successfully removed, false if failed to remove or no such item
Removes a single item from the internal data structures of this class.
This can be used to implement removeItem(Object)
in subclasses.
No notification is sent, the caller has to fire a suitable item set
change notification.
internalAddItemAtEnd
protected ITEMCLASS internalAddItemAtEnd(ITEMIDTYPE newItemId,
ITEMCLASS item,
boolean filter)
- Parameters:
newItemId
-item
- new item to addfilter
- true to perform filtering and send event after adding the item, false to skip these operations for batch inserts - if false, caller needs to make sure these operations are performed at the end of the batch- Returns:
- item added or null if no item was added
Add an item at the end of the container, and perform filtering if necessary. An event is fired if the filtered view changes.
internalAddItemAfter
protected ITEMCLASS internalAddItemAfter(ITEMIDTYPE previousItemId,
ITEMIDTYPE newItemId,
ITEMCLASS item,
boolean filter)
- Parameters:
previousItemId
- item id of a visible item after which to add the new item, or null to add at the beginningnewItemId
-item
- new item to addfilter
- true to perform filtering and send event after adding the item, false to skip these operations for batch inserts - if false, caller needs to make sure these operations are performed at the end of the batch- Returns:
- item added or null if no item was added
Add an item after a given (visible) item, and perform filtering. An event is fired if the filtered view changes. The new item is added at the beginning if previousItemId is null.
internalAddItemAt
protected ITEMCLASS internalAddItemAt(int index,
ITEMIDTYPE newItemId,
ITEMCLASS item,
boolean filter)
- Parameters:
index
- position where to add the item (visible/view index)newItemId
-item
- new item to addfilter
- true to perform filtering and send event after adding the item, false to skip these operations for batch inserts - if false, caller needs to make sure these operations are performed at the end of the batch- Returns:
- item added or null if no item was added
Add an item at a given (visible after filtering) item index, and perform filtering. An event is fired if the filtered view changes.
registerNewItem
protected void registerNewItem(int position,
ITEMIDTYPE itemId,
ITEMCLASS item)
- Parameters:
position
-itemId
-item
-
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.
fireItemAdded
protected void fireItemAdded(int position,
ITEMIDTYPE itemId,
ITEMCLASS item)
- Parameters:
postion
- position of the added item in the view (if visible)itemId
- id of the added itemitem
- the added item
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.
fireItemRemoved
protected void fireItemRemoved(int position,
Object itemId)
- Parameters:
postion
- position of the removed item in the view prior to removal (if was visible)itemId
- id of the removed item, of typeObject
to satisfyContainer.removeItem(Object)
API
Notify item set change listeners that an item has been removed from the container. Unless subclasses specify otherwise, the default notification indicates a full refresh.
getVisibleItemIds
protected List<ITEMIDTYPE> getVisibleItemIds()
Returns the internal list of visible item identifiers after filtering. For internal use only.
isFiltered
protected boolean isFiltered()
- Returns:
- true if the container is currently filtered
Returns true is the container has active filters.
setFilteredItemIds
@Deprecated
protected void setFilteredItemIds(List<ITEMIDTYPE> filteredItemIds)
- Parameters:
filteredItemIds
-
Deprecated.
Internal helper method to set the internal list of filtered item identifiers. Should not be used outside this class except for implementing clone(), may disappear from future versions.
getFilteredItemIds
protected List<ITEMIDTYPE> getFilteredItemIds()
- Returns:
- List
Internal helper method to get the internal list of filtered item
identifiers. Should not be used outside this class except for
implementing clone(), may disappear from future versions - use
getVisibleItemIds()
in other contexts.
setAllItemIds
@Deprecated
protected void setAllItemIds(List<ITEMIDTYPE> allItemIds)
- Parameters:
allItemIds
-
Deprecated.
Internal helper method to set the internal list of all item identifiers. Should not be used outside this class except for implementing clone(), may disappear from future versions.
getAllItemIds
protected List<ITEMIDTYPE> getAllItemIds()
- Returns:
- List
Internal helper method to get the internal list of all item identifiers. Avoid using this method outside this class, may disappear in future versions.
setFilters
protected void setFilters(Set<Container.Filter> filters)
- Parameters:
filters
-
Set the internal collection of filters without performing filtering.
This method is mostly for internal use, use
addFilter(com.vaadin.data.Container.Filter)
and
remove*Filter*
(which also re-filter the container) instead
when possible.
getFilters
protected Set<Container.Filter> getFilters()
- Returns:
- Set
Returns the internal collection of filters. The returned collection should not be modified by callers outside this class.