Package com.vaadin.data.provider
Class DataCommunicator.ActiveDataHandler
- java.lang.Object
-
- com.vaadin.data.provider.DataCommunicator.ActiveDataHandler
-
- All Implemented Interfaces:
DataGenerator<T>,Serializable
- Enclosing class:
- DataCommunicator<T>
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 byDataKeyMapper.When the
DataCommunicatoris 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:
- Serialized Form
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedActiveDataHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddActiveData(Stream<T> dataObjects)Adds given objects as currently active objects.voidcleanUp(Stream<T> dataObjects)Executes the data destruction for dropped data that is not sent to the client.voiddestroyAllData()Informs theDataGeneratorthat all data has been dropped.voiddestroyData(T data)Informs theDataGeneratorthat the given data item has been dropped and is no longer needed.voiddropActiveData(String key)Marks a data object identified by given key string to be dropped.voiddropAllActiveData()Marks all currently active data objects to be dropped.voidgenerateData(T data, elemental.json.JsonObject jsonObject)Adds custom data for the given item to its serializedJsonObjectrepresentation.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 theDataCommunicator.ActiveDataHandlerfrom 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:DataGeneratorAdds custom data for the given item to its serializedJsonObjectrepresentation. This JSON object will be sent to client-side DataProvider.- Specified by:
generateDatain 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:DataGeneratorInforms theDataGeneratorthat 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:
destroyDatain interfaceDataGenerator<T>- Parameters:
data- the dropped data item
-
destroyAllData
public void destroyAllData()
Description copied from interface:DataGeneratorInforms theDataGeneratorthat all data has been dropped. This method should clean up any unneeded information stored for items.- Specified by:
destroyAllDatain interfaceDataGenerator<T>
-
-