View Javadoc
1 /*** 2 * Copyright (c) 2003 held jointly by the individual authors. 3 * 4 * This library is free software; you can redistribute it and/or modify it 5 * under the terms of the GNU Lesser General Public License as published 6 * by the Free Software Foundation; either version 2.1 of the License, or 7 * (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, but 10 * WITHOUT ANY WARRANTY; with out even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU Lesser General Public License for more details. 13 * 14 * You should have received a copy of the GNU Lesser General Public License 15 * along with this library; if not, write to the Free Software Foundation, 16 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 17 * 18 * > http://www.gnu.org/copyleft/lesser.html 19 * > http://www.opensource.org/licenses/lgpl-license.php 20 */ 21 package net.mlw.gfw.event; 22 23 import java.util.ArrayList; 24 import java.util.Iterator; 25 import java.util.List; 26 27 /*** A PublisherGroup holds meany Publisher(s), and allows 28 * them to be treated as one. 29 * 30 * @author Matthew L. Wilson 31 * @version $Revision: 1.4 $ $Date: 2004/06/29 20:32:57 $ 32 */ 33 public class EventHandlerList implements EventHandler, EventHandlerContainer 34 { 35 /*** Holds all the publisher. */ 36 private List eventHandlers = new ArrayList(); 37 38 /*** Adds a EventHandler to the internal List of EventHandlers. 39 * 40 * @param eventHandler The EventHandler to add. 41 */ 42 public EventHandler addEventHandler(EventHandler eventHandler) 43 { 44 eventHandlers.add(eventHandler); 45 return eventHandler; 46 } 47 48 /*** Removes the EventHandler from the List. 49 * 50 * @param eventHandler The EventHandler to remove. 51 */ 52 public EventHandler removeEventHandler(EventHandler eventHandler) 53 { 54 if(eventHandlers.remove(eventHandler)) 55 { 56 return eventHandler; 57 } 58 else 59 { 60 return null; 61 } 62 } 63 64 /*** @see net.mlw.gfw.event.EventHandler#onEvent(net.mlw.gfw.event.Event) 65 */ 66 public void onEvent(Event event) 67 { 68 for (Iterator iter = eventHandlers.iterator(); iter.hasNext();) 69 { 70 ((EventHandler) iter.next()).onEvent(event); 71 } 72 } 73 74 /*** 75 * @see java.lang.Object#toString() 76 */ 77 public String toString() 78 { 79 return eventHandlers.toString(); 80 } 81 82 }

This page was automatically generated by Maven