public interface Buffered extends Serializable
Defines the interface to commit and discard changes to an object, supporting buffering.
In buffered mode the initial value is read from the data source and
then buffered. Any subsequential writes or reads will be done on the buffered
value. Calling commit()
will write the buffered value to the data
source while calling discard()
while discard the buffered value and
re-read the value from the data source.
In non-buffered mode the value is always read directly from the data
source. Any write is done directly to the data source with no buffering in
between. Reads are also done directly from the data source. Calling
commit()
or discard()
in this mode is efficiently a no-op.
Modifier and Type | Interface and Description |
---|---|
static class |
Buffered.SourceException
An exception that signals that one or more exceptions occurred while a
buffered object tried to access its data source or if there is a problem
in processing a data source.
|
Modifier and Type | Method and Description |
---|---|
void |
commit()
Updates all changes since the previous commit to the data source.
|
void |
discard()
Discards all changes since last commit.
|
boolean |
isBuffered()
Checks the buffered mode
|
boolean |
isModified()
Tests if the value stored in the object has been modified since it was
last updated from the data source.
|
void |
setBuffered(boolean buffered)
Sets the buffered mode to the specified status.
|
void commit() throws Buffered.SourceException, Validator.InvalidValueException
commit
is called.Buffered.SourceException
- if the operation fails because of an exception is thrown by
the data source. The cause is included in the exception.Validator.InvalidValueException
- if the operation fails because validation is enabled and the
values do not validatevoid discard() throws Buffered.SourceException
Buffered.SourceException
- if the operation fails because of an exception is thrown by
the data source. The cause is included in the exception.void setBuffered(boolean buffered)
When in buffered mode, an internal buffer will be used to store changes
until commit()
is called. Calling discard()
will revert
the internal buffer to the value of the data source.
When in non-buffered mode both read and write operations will be done
directly on the data source. In this mode the commit()
and
discard()
methods serve no purpose.
buffered
- true if buffered mode should be turned on, false otherwiseboolean isBuffered()
boolean isModified()
true
if the value in the object has been modified
since the last data source update, false
if not.Copyright © 2019 Vaadin Ltd. All rights reserved.