net.sf.nachocalendar.model
Class DefaultDataModel

java.lang.Object
  extended bynet.sf.nachocalendar.model.DefaultDataModel
All Implemented Interfaces:
DataModel
Direct Known Subclasses:
TaskDataModel

public class DefaultDataModel
extends java.lang.Object
implements DataModel

Default implementation for DataModel. It has a collection to contain the data and convenient accesor methods

Author:
Ignacio Merani

Constructor Summary
DefaultDataModel()
          Creates a new instance of DefaultDataModel.
 
Method Summary
 void addData(java.util.Date date, java.lang.Object o)
          Adds new data to the Collection.
 void addDataModelListener(DataModelListener listener)
          Registers DataModelListener to receive events.
 void clear()
          Removes all data from the Collection.
 java.util.Map getAll()
          Returns a Collection with the data.
 java.lang.Object getData(java.util.Date date)
          Checks if the date provided has data.
 int getSize()
          Returns the quantity of data in the Collection.
 void removeData(java.util.Date date)
          Removes the provided data from the Collection.
 void removeDataModelListener(DataModelListener listener)
          Removes DataModelListener from the list of listeners.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultDataModel

public DefaultDataModel()
Creates a new instance of DefaultDataModel.

Method Detail

addData

public void addData(java.util.Date date,
                    java.lang.Object o)
Adds new data to the Collection.

Parameters:
date - the new date
o - the new data

removeData

public void removeData(java.util.Date date)
Removes the provided data from the Collection.

Parameters:
date - date to be removed

getSize

public int getSize()
Returns the quantity of data in the Collection.

Returns:
the size of the Collection

getAll

public java.util.Map getAll()
Returns a Collection with the data.

Returns:
Collection with the data

clear

public void clear()
Removes all data from the Collection.


getData

public java.lang.Object getData(java.util.Date date)
Checks if the date provided has data.

Specified by:
getData in interface DataModel
Parameters:
date - Date to be checked
Returns:
the data or null if it has not

addDataModelListener

public void addDataModelListener(DataModelListener listener)
Registers DataModelListener to receive events.

Parameters:
listener - The listener to register.

removeDataModelListener

public void removeDataModelListener(DataModelListener listener)
Removes DataModelListener from the list of listeners.

Parameters:
listener - The listener to remove.