|
Sharkysoft home | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--lava.mv.MvModel
Abstract base class for models.
Details: MvModel should be used as the base class for objects representing models in programs that implement model-view separation.
IMvView| Constructor Summary | |
protected |
MvModel()
|
protected |
MvModel(java.lang.Object id)
Specifies model id. |
| Method Summary | |
protected IMvEventDispatcher |
getEventDispatcher()
|
protected void |
notifyViews(int type,
java.lang.Object[] params)
Sends MvModelEvent message. |
protected void |
notifyViews(java.lang.Object message)
Notifies all registered views of a change in the model. |
void |
registerView(IMvView view)
Registers a IMvView with this MvModel. |
protected void |
setEventDispatcher(IMvEventDispatcher dispatcher)
|
void |
unregisterView(IMvView view)
Unregisters a IMvView with this MvModel. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
protected MvModel(java.lang.Object id)
Details: This constructor allows the caller to specify the object that is used to identify the model in calls to views' updateView method.
id - the model idprotected MvModel()
| Method Detail |
protected void setEventDispatcher(IMvEventDispatcher dispatcher)
protected IMvEventDispatcher getEventDispatcher()
protected void notifyViews(java.lang.Object message)
Details: notifyViews calls the updateView method of all IMvViews registered with this MvModel, sending each IMvView the indicated message. This message should be an Object that each IMvView expects to receive.
Usually, you will want to make a special message class for this purpose. Ideally, each message contains "delta information" (i.e., model change information) that each view can use to determine an appropriate and efficient view update strategy.
If a view throws an Exception while being notified, notifyViews catches it and dumps the stack trace using the Exception's printStackTrace method.
message - the update message
protected void notifyViews(int type,
java.lang.Object[] params)
Details: notifyViews is a helper method designed to make message dispatching easier. notifyViews first creates a new MvModelEvent object based on the supplied parameters (type, params), and then it dispatches it using the original notifyViews method.
type - the message type IDparams - the message parameter listpublic void registerView(IMvView view)
Details: registerView registers the given IMvView to receive update messsages from this MvModel when it changes. The IMvView should expect to receive messages from this MvModel and know how to handle them.
IMvViews that register with this MvModel should unregister themselves when the views are no longer used. See unregisterView.
view - the IMvView to registerpublic void unregisterView(IMvView view)
Details: unregisterView removes the given IMvView from the this MvModel's list of registered views. The IMvView will no long receive update messages from this MvModel.
IMvViews should unregister themselves when they are no longer in use.
view - the IMvView to unregister
|
Sharkysoft home | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||