public class MessageStore<M extends Message> extends Object implements MessageReceiver<M>
Message
s with dynamic sorting, graphic
interfaces and propagation facilities. setOrder(Comparator)
.
Whenever this comparator is re-assigned, the store
is re-ordered and all graphical representations are notified.javax.swing
, namely MessageStore.TableModel
and MessageStore.ListModel
.
The user can derive from these classes and provide its own instance by
setTableModel(TableModel)
and setListModel(ListModel)
. If not,
a standard implementation will be provided by
getTableModel()
and getListModel()
.
MessageReceiver
by calling
drainTo(MessageReceiver)
.Modifier and Type | Class and Description |
---|---|
class |
MessageStore.ListModel
standard specialisation of
AbstractListModel . |
class |
MessageStore.TableModel
standard specialisation of
AbstractTableModel . |
Modifier and Type | Field and Description |
---|---|
protected MessageStore.ListModel |
listModel |
protected List<M> |
messages |
protected Comparator<? super M> |
order |
protected MessageStore.TableModel |
tableModel |
Constructor and Description |
---|
MessageStore() |
Modifier and Type | Method and Description |
---|---|
void |
clear()
clears the internal storage, deleting all messages.
|
void |
drainTo(MessageReceiver<? super M> receiver)
send all currently contained messages (in their stored order)
to the receiver.
|
MessageStore.ListModel |
getListModel()
returns the default (or a user-defined) list model, cf
MessageStore.ListModel . |
List<M> |
getMessages()
returns an unmodifiable façade to the current content.
|
Comparator |
getOrder()
Returns the comparator which rules the sequential order of storing.
|
int |
getSize()
returns the number of currently contained messages
|
MessageStore.TableModel |
getTableModel()
returns the default (or a user-defined) table model,
MessageStore.TableModel . |
protected void |
notifyGuiAdd(int i)
An item has been inserted at position "i".
|
protected void |
notifyGuiChanged_ALL()
Only called in case of sort order change: Re-arranged from-to.
|
void |
receive(M message)
adds the received message to the internal store and notifies all GUI objects.
|
void |
setListModel(MessageStore.ListModel lm)
only needed for inserting user-defined list model, cf
MessageStore.ListModel . |
void |
setOrder(Comparator<? super M> comp)
Set the comparator which rules the sequential order of storing.
|
void |
setTableModel(MessageStore.TableModel tm)
only needed for inserting user-defined table model, cf
MessageStore.TableModel . |
protected Comparator<? super M extends Message> order
protected MessageStore.TableModel tableModel
protected MessageStore.ListModel listModel
public void setOrder(Comparator<? super M> comp)
comp==null
, then no re-ordering takes place, and future messages
will again be appended to the end of the store.public Comparator getOrder()
public void drainTo(MessageReceiver<? super M> receiver)
public List<M> getMessages()
public int getSize()
public void setTableModel(MessageStore.TableModel tm)
MessageStore.TableModel
.public void setListModel(MessageStore.ListModel lm)
MessageStore.ListModel
.public MessageStore.TableModel getTableModel()
MessageStore.TableModel
.public MessageStore.ListModel getListModel()
MessageStore.ListModel
.public void clear()
protected void notifyGuiAdd(int i)
protected void notifyGuiChanged_ALL()
public void receive(M message)
setOrder(Comparator)
then the
new message is inserted directly before those which are of greater value,
ie. after all those of equal value, which are older.
In the absence of a comparator it is appended at the end.receive
in interface MessageReceiver<M extends Message>
see also the complete user documentation .