com.vaadin.data.provider.
Class DataCommunicator.ActiveDataHandler
- java.lang.Object
-
- com.vaadin.data.provider.DataCommunicator.ActiveDataHandler
-
All Implemented Interfaces:
Enclosing class:
protected class DataCommunicator.ActiveDataHandler extends Object implements DataGenerator<T>
A class for handling currently active data and dropping data that is no longer needed. Data tracking is based on key string provided by
DataKeyMapper
.When the
DataCommunicator
is pushing new data to the client-side viaDataCommunicator.pushData(int, List)
,addActiveData(Stream)
andcleanUp(Stream)
are called with the same parameter. In the clean up method any dropped data objects that are not in the given collection will be cleaned up andDataGenerator.destroyData(Object)
will be called for them.See Also:
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ActiveDataHandler()
-
Method Summary
All Methods Modifier and Type Method Description void
addActiveData(Stream<T> dataObjects)
Adds given objects as currently active objects.
void
cleanUp(Stream<T> dataObjects)
Executes the data destruction for dropped data that is not sent to the client.
void
destroyAllData()
Informs the
DataGenerator
that all data has been dropped.void
destroyData(T data)
Informs the
DataGenerator
that the given data item has been dropped and is no longer needed.void
dropActiveData(String key)
Marks a data object identified by given key string to be dropped.
void
dropAllActiveData()
Marks all currently active data objects to be dropped.
void
generateData(T data, elemental.json.JsonObject jsonObject)
Adds custom data for the given item to its serialized
JsonObject
representation.Map<Object,T>
getActiveData()
Returns all currently active data mapped by their id from DataProvider.
protected Map<Object,T>
getDroppedData()
Returns all dropped data mapped by their id from DataProvider.
-
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.provider.DataGenerator
refreshData
-
-
-
-
Method Detail
-
addActiveData
public void addActiveData(Stream<T> dataObjects)
Adds given objects as currently active objects.
Parameters:
dataObjects
- collection of new active data objects
-
cleanUp
public void cleanUp(Stream<T> dataObjects)
Executes the data destruction for dropped data that is not sent to the client. This method takes most recently sent data objects in a collection. Doing the clean up like this prevents the
DataCommunicator.ActiveDataHandler
from creating new keys for rows that were dropped but got re-requested by the client-side. In the case of having all data at the client, the collection should be all the data in the back end.Parameters:
dataObjects
- collection of most recently sent data to the client
-
dropAllActiveData
public void dropAllActiveData()
Marks all currently active data objects to be dropped.
Since:
8.6.0
-
dropActiveData
public void dropActiveData(String key)
Marks a data object identified by given key string to be dropped.
Parameters:
key
- key string
-
getDroppedData
protected Map<Object,T> getDroppedData()
Returns all dropped data mapped by their id from DataProvider.
Returns:
map of ids to dropped data objects
Since:
8.6.0
-
getActiveData
public Map<Object,T> getActiveData()
Returns all currently active data mapped by their id from DataProvider.
Returns:
map of ids to active data objects
-
generateData
public void generateData(T data, elemental.json.JsonObject jsonObject)
Description copied from interface:
DataGenerator
Adds custom data for the given item to its serialized
JsonObject
representation. This JSON object will be sent to client-side DataProvider.Specified by:
generateData
in interfaceDataGenerator<T>
Parameters:
data
- the data item being serializedjsonObject
- the JSON object being sent to the client
-
destroyData
public void destroyData(T data)
Description copied from interface:
DataGenerator
Informs the
DataGenerator
that the given data item has been dropped and is no longer needed. This method should clean up any unneeded information stored for this item.Specified by:
destroyData
in interfaceDataGenerator<T>
Parameters:
data
- the dropped data item
-
destroyAllData
public void destroyAllData()
Description copied from interface:
DataGenerator
Informs the
DataGenerator
that all data has been dropped. This method should clean up any unneeded information stored for items.Specified by:
destroyAllData
in interfaceDataGenerator<T>
-
-