net.sf.borg.model
Class Model

java.lang.Object
  extended by net.sf.borg.model.Model
Direct Known Subclasses:
AddressModel, AppointmentModel, CategoryModel, CheckListModel, LinkModel, MemoModel, TaskModel

public abstract class Model
extends Object

base class for data models. A Model provides access to a data store to the outside world. Clients of the model can register as Listeners to be provided with feedback any time the model changes.


Nested Class Summary
static class Model.ChangeEvent
          The Class ChangeEvent.
static interface Model.Listener
          Listener for a Model.
 
Constructor Summary
Model()
          Instantiates a new model.
 
Method Summary
 void addListener(Model.Listener listener)
          Adds a listener.
abstract  void export(Writer fw)
          Export the models data to XML
static List<Model> getExistingModels()
          get a list of all instantiated models
abstract  String getExportName()
          get the root XML element name for this model's XML representation
abstract  String getInfo()
          return user readable information about the model
abstract  void importXml(InputStream is)
          Import model data from XML
protected  void refreshListeners()
          send an update message to all listeners with no change event
protected  void refreshListeners(Model.ChangeEvent event)
          send an update message to all listeners with a change event.
 void remove()
          Removes the listeners.
 void removeListener(Model.Listener listener)
          Removes a listener.
protected  void removeListeners()
          notify all listeners that the model is being destroyed
protected  void sync()
          sync the model with the underlying DB for DBs that can be changed without going through Borg (i.e.
static void syncModels()
          sync all models
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Model

public Model()
Instantiates a new model.

Method Detail

getExistingModels

public static List<Model> getExistingModels()
get a list of all instantiated models

Returns:
list of models

syncModels

public static void syncModels()
sync all models


sync

protected void sync()
sync the model with the underlying DB for DBs that can be changed without going through Borg (i.e. MySQL)


addListener

public void addListener(Model.Listener listener)
Adds a listener.

Parameters:
listener - the listener

refreshListeners

protected void refreshListeners()
send an update message to all listeners with no change event


refreshListeners

protected void refreshListeners(Model.ChangeEvent event)
send an update message to all listeners with a change event.


remove

public void remove()
Removes the listeners.


removeListener

public void removeListener(Model.Listener listener)
Removes a listener.

Parameters:
listener - the listener

removeListeners

protected void removeListeners()
notify all listeners that the model is being destroyed


export

public abstract void export(Writer fw)
                     throws Exception
Export the models data to XML

Parameters:
fw - - writer to write the XML to
Throws:
Exception

importXml

public abstract void importXml(InputStream is)
                        throws Exception
Import model data from XML

Parameters:
is - input stream containing XML
Throws:
Exception

getExportName

public abstract String getExportName()
get the root XML element name for this model's XML representation

Returns:
the XML root element name

getInfo

public abstract String getInfo()
                        throws Exception
return user readable information about the model

Returns:
user readable information String
Throws:
Exception


Generated December 30 2011 by mbb using Apache Ant(TM) version 1.8.2 compiled on December 20 2010 and Java version 1.6.0_30 from Sun Microsystems Inc. on Linux i386 3.0.0-14-generic-pae