/*
 * Copyright (c) 2006-2008 MiniMe. Code released under The MIT/X Window System
 * License. Full license text can be found in license.txt
 */
package minime;

import java.util.Vector;
/**
 * 
 * @author hongbo
 *
 */
public abstract class Observable {
	private Vector observers = new Vector();
	public void addObserver(Observer vo){
		observers.addElement(vo);
	}
	public void removeObserver(Observer vo){
		if(observers.size()==0)
			return;
		else
			observers.removeElement(vo);
	}
	
	/**
	 * @param arg: the only parameter
	 */
	
	public void notify(Object arg){
		for(int i=0;i<observers.size();i++)
		{
			Observer vo=(Observer)observers.elementAt(i);
			vo.update(arg);
		}
	}
	
	
	/**
	 * 
	 * @param arg1: the first parameter
	 * @param arg2: the second parameter
	 */
	public void notify(Object arg1,Object arg2){
		for(int i=0;i<observers.size();i++)
		{
			Observer vo=(Observer)observers.elementAt(i);
			vo.update(arg1, arg2);
		}
	}
	
	
}
