mvp
Class Model

java.lang.Object
  |
  +--java.util.Observable
        |
        +--mvp.Model
All Implemented Interfaces:
java.io.Serializable

public abstract class Model
extends java.util.Observable
implements java.io.Serializable

Class Model is an abstract parent class for model classes in an MVP design. See Fisher SE lecture notes for further discussion of the MVP design methodology.

See Also:
Serialized Form

Field Summary
protected  View view
          The canonical view for this model.
 
Constructor Summary
Model()
          Construct a model with no view.
Model(View view)
          Construct a model with the given View.
 
Method Summary
 java.lang.String dump()
          Dump the entire contents of this in String form.
 void exit()
          Perform appropriate exit processing, which typically includes exiting the application program of which this model is a component.
 View getView()
          Return the view of this.
 void setView(View v)
          Set the view of this to the given view, if the view is not already set.
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

view

protected View view
The canonical view for this model. Models with multiple views can add additional view data members as necessary.

Constructor Detail

Model

public Model(View view)
Construct a model with the given View.
 post: this'.view = view;
                                                                   


Model

public Model()
Construct a model with no view. This constructor is typically used for submodel objects that have no individual view of their own, but have a subview that is part of a larger parent's view.
 post: this'.view = null;
                                                                   

Method Detail

setView

public void setView(View v)
Set the view of this to the given view, if the view is not already set. This setView method is used if this must be constructed before its companion view is constructed, and therefore the view will not be available to pass to the constructor.

Models with multiple and/or dynamically changeable views must manage view changes with additional data members. This' canonical view can be set only once, with either the constructor or one call to setView.

 pre: this.view == null;

 post: this'.view == view;
                                                                   


getView

public View getView()
Return the view of this.
 post: return == view;
                                                                   


exit

public void exit()
Perform appropriate exit processing, which typically includes exiting the application program of which this model is a component. This method is called from a companion view when the view's window is closed, and such closing means that the application should exit. See View.setExitOnClose for more information.
 post: ;   // must be specialized in subclasses
                                                                  


dump

public java.lang.String dump()
Dump the entire contents of this in String form. This method is intended to be called during testing to produce an inspectable and difference version of this model's data. This dump method is distinct from the Object.toString method in Java, since toString may be used for other purposes than producing a complete data dump.
 post: ;   // must be specialized in subclasses