net.sf.nachocalendar.model

Class DefaultDataModel

Implemented Interfaces:
DataModel

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(Date date, 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.
Map
getAll()
Returns a Collection with the data.
Object
getData(Date date)
Checks if the date provided has data.
int
getSize()
Returns the quantity of data in the Collection.
void
removeData(Date date)
Removes the provided data from the Collection.
void
removeDataModelListener(DataModelListener listener)
Removes DataModelListener from the list of listeners.

Constructor Details

DefaultDataModel

public DefaultDataModel()
Creates a new instance of DefaultDataModel.

Method Details

addData

public void addData(Date date,
                    Object o)
Adds new data to the Collection.
Parameters:
date - the new date
o - the new data

addDataModelListener

public void addDataModelListener(DataModelListener listener)
Registers DataModelListener to receive events.
Parameters:
listener - The listener to register.

clear

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

getAll

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

getData

public Object getData(Date date)
Checks if the date provided has data.
Parameters:
date - Date to be checked
Returns:
the data or null if it has not

getSize

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

removeData

public void removeData(Date date)
Removes the provided data from the Collection.
Parameters:
date - date to be removed

removeDataModelListener

public void removeDataModelListener(DataModelListener listener)
Removes DataModelListener from the list of listeners.
Parameters:
listener - The listener to remove.