public class IlvBufferFlatListModel extends IlvDefaultFlatListModel
IlvFlatListModel
that
buffers (caches) the data of a given IlvFlatListModel
.
It is meant to be used when the access to the original
IlvFlatListModel
is slow.
Changes in the underlying model are propagated to this model
if the isNotifying
method returns true
.
Note: this model supports adding and removing objects
if the underlying IlvFlatListModel
is an instance of
IlvDefaultFlatListModel
. It supports adding and removing
columns if the underlying IlvFlatListModel
is an instance of IlvBasicFlatListModel
.
BEFORE_COLUMN_REMOVED_MASK, BEFORE_DATA_CHANGE_MASK, BEFORE_OBJECTS_REMOVED_MASK
Constructor and Description |
---|
IlvBufferFlatListModel(IlvFlatListModel model)
Creates a model that is fed by and caches the data of a given
IlvFlatListModel . |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Removes all the objects from the model.
|
Object |
clone()
Returns a copy of this object.
|
void |
disconnect()
Drops references to objects to help garbage collection.
|
void |
dispose()
Cleans up this model and drops references to objects to
help garbage collection.
|
int |
getSupportedEventsMask()
Returns a bit mask denoting the optional kinds of events that are guaranteed
to be sent by this model to the registered listeners.
|
void |
insertColumn(int columnIndex,
IlvDataColumnInfo column)
Adds a column to the model at a given index.
|
void |
insertColumn(int columnIndex,
IlvDataColumnInfo column,
double[] data)
Adds a column with given data to the model at a given index.
|
void |
insertColumn(int columnIndex,
IlvDataColumnInfo column,
Object[] data)
Adds a column with given data to the model at a given index.
|
void |
insertObject(Object object,
int index)
Adds an object to the model at a given index.
|
void |
insertObject(Object object,
Object[] data,
int index)
Adds an object to the model at a given index.
|
void |
insertObjects(Object[] objects,
int index)
Adds some objects to the model at a given index.
|
protected boolean |
isColumnComputed(int columnIndex)
Returns
true if setValueAtInternal and setDoubleAtInternal on a given
column have no effect. |
boolean |
isNotifying()
Returns
true when this model is a dynamically updated cache
of the underlying model. |
void |
removeColumn(int columnIndex)
Removes a column from the model.
|
void |
removeObject(Object object)
Removes an object from the model.
|
void |
removeObjects(Object[] objects,
int firstIndex)
Removes some consecutive objects from the model.
|
void |
setColumnCount(int columnCount)
Sets the number of columns in the model.
|
protected boolean |
setDoubleAtInternal(double value,
Object object,
int columnIndex,
boolean forReal)
Does the equivalent of a
setDoubleAt() . |
void |
setNotifying(boolean dynamic)
Determines whether this model is a dynamically updated cache of the
underlying event (and therefore also sends events when the underlying
model changes).
|
void |
setObjects(Collection objects)
Replaces the set of objects in the model.
|
protected boolean |
setValueAtInternal(Object value,
Object object,
int columnIndex,
boolean forReal)
Does the equivalent of a
setValueAt() . |
addObject, addObject, createColumnStorage, getDoubleAt, getIndexOf, getObjectAt, getObjects, getValueAt, internalObjectsAdd, internalObjectsRemove, internalObjectsSet, setDoubleAt, setValueAt
addColumn, addColumn, addColumn, fireModelEvent, getColumn, getColumnCount, getColumns, setColumn, setColumns
addFlatListModelListener, convertToDouble, endBatch, removeFlatListModelListener, startBatch
public IlvBufferFlatListModel(IlvFlatListModel model)
IlvFlatListModel
.protected boolean setValueAtInternal(Object value, Object object, int columnIndex, boolean forReal)
setValueAt()
. Instead of notifying, it simply returns
a boolean
indicating whether notification should be done.
If forReal is false
, the value is not actually set, but the
method still returns the same Boolean, specifying whether the given value is
different from the previous one.
setValueAtInternal
in class IlvDefaultFlatListModel
protected boolean setDoubleAtInternal(double value, Object object, int columnIndex, boolean forReal)
setDoubleAt()
. Instead of notifying, it simply returns
a boolean
indicating whether notification should be done.
If forReal is false
, the value is not actually set, but the
method still returns the same Boolean, specifying whether the given value is
different from the previous one.
setDoubleAtInternal
in class IlvDefaultFlatListModel
protected boolean isColumnComputed(int columnIndex)
true
if setValueAtInternal
and setDoubleAtInternal
on a given
column have no effect.isColumnComputed
in class IlvDefaultFlatListModel
public int getSupportedEventsMask()
This implementation returns
BEFORE_DATA_CHANGE_MASK | BEFORE_OBJECTS_REMOVED_MASK | BEFORE_COLUMN_REMOVED_MASK
.
It may need to be overridden in subclasses.
getSupportedEventsMask
in interface IlvFlatListModel
getSupportedEventsMask
in class IlvDefaultFlatListModel
IlvFlatListModel.BEFORE_DATA_CHANGE_MASK
,
IlvFlatListModel.BEFORE_OBJECTS_REMOVED_MASK
,
IlvFlatListModel.BEFORE_COLUMN_REMOVED_MASK
public void setObjects(Collection objects)
setObjects
in class IlvDefaultFlatListModel
public void insertObject(Object object, int index)
insertObject
in class IlvDefaultFlatListModel
index
- The object desired index. It must be >= 0 and
<= getObjects().size()
.public void insertObjects(Object[] objects, int index)
insertObjects
in class IlvDefaultFlatListModel
index
- The first index of the new object. It must be >= 0 and
<= getObjects().size()
.public void insertObject(Object object, Object[] data, int index)
insertObject
in class IlvDefaultFlatListModel
data
- The initial data of this object. It must be an array of
getColumnCount()
elements.index
- The index of the new object. It must be >= 0 and
<= getObjects().size()
.public void removeObject(Object object)
removeObject
in class IlvDefaultFlatListModel
public void removeObjects(Object[] objects, int firstIndex)
removeObjects
in class IlvDefaultFlatListModel
objects
- The objects that were at indices firstIndex, ...,
firstIndex+objects.length-1 of
getObjects().iterator()
.public void clear()
clear
in class IlvDefaultFlatListModel
public void setColumnCount(int columnCount)
columnCount
and greater are discarded.setColumnCount
in class IlvBasicFlatListModel
columnCount
- The new number of columns.public void insertColumn(int columnIndex, IlvDataColumnInfo column)
insertColumn
in class IlvBasicFlatListModel
columnIndex
- The new column desired index, must be >= 0 and
<= getColumnCount()
column
- The metainformation of this column.public void insertColumn(int columnIndex, IlvDataColumnInfo column, Object[] data)
insertColumn
in class IlvBasicFlatListModel
columnIndex
- The new column desired index, must be >= 0 and
<= getColumnCount()
.column
- The metainformation of this column.data
- The initial data of this column. This should be an array
of at least getObjects().size()
elements. Not used
if the column is a computed column.public void insertColumn(int columnIndex, IlvDataColumnInfo column, double[] data)
insertColumn
in class IlvBasicFlatListModel
columnIndex
- the new column desired index, must be >= 0 and
<= getColumnCount()
.column
- The metainformation of this column.data
- The initial data of this column. This should be an array
of at least getObjects().size()
elements. Not used
if the column is a computed column.public void removeColumn(int columnIndex)
removeColumn
in class IlvBasicFlatListModel
columnIndex
- The column index, must be >= 0 and
< getColumnCount()
.public boolean isNotifying()
true
when this model is a dynamically updated cache
of the underlying model. Returns false
when this model is
a snapshot buffer of the underlying model.setNotifying(boolean)
public void setNotifying(boolean dynamic)
Note: If setNotifying(true)
is called, after the notification was
turned off, it has the effect of bringing the entire cache up to date;
this can be an expensive operation.
isNotifying()
public void dispose()
Note: After calling this function, this model is no longer functional.
dispose
in class IlvDefaultFlatListModel
public void disconnect()
Note: After calling this function, and after some changes occurred in the underlying model or columns, this model is no longer functional.
disconnect
in class IlvBasicFlatListModel
public Object clone()
clone
in class IlvDefaultFlatListModel
© Copyright 2024 Rogue Wave Software, Inc., a Perforce company.. All Rights Reserved.