View Javadoc
1 /*** 2 * LayeringEventSupport.java 3 * 4 * Project: Dependency Tool 5 * 6 * WHEN WHO WHAT 7 * 06.06.2003 pko initial public release 8 * 20.01.2003 pko creation 9 * 10 * Copyright 2003 ELCA Informatique SA 11 * Av. de la Harpe 22-24, 1000 Lausanne 13, Switzerland 12 * www.elca.ch 13 * 14 * This library is free software; you can redistribute it and/or 15 * modify it under the terms of the GNU Lesser General Public License 16 * as published by the Free Software Foundation; either version 2.1 of 17 * the License, or (at your option) any later version. 18 * 19 * This library is distributed in the hope that it will be useful, but 20 * WITHOUT ANY WARRANTY; without even the implied warranty of 21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 * Lesser General Public License for more details. 23 * 24 * You should have received a copy of the GNU Lesser General Public 25 * License along with this library; if not, write to the Free Software 26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 27 * USA 28 */ 29 30 package ch.elca.dependency.graph; 31 32 import java.util.ArrayList; 33 import java.util.Iterator; 34 35 import att.grappa.Edge; 36 37 /*** 38 * This is an utility class which supports LayeringEvents. You can use 39 * an instance of this class as a member field of a class firing 40 * LayeringEvents and delegate various work associated with 41 * LayeringEvents to it. 42 * 43 * @author Pawel Kowalski 44 * @version 1.0-beta 45 */ 46 public class LayeringEventSupport { 47 48 /*** 49 * A list holding references to all LayeringListeners. 50 */ 51 private ArrayList m_listeners = new ArrayList(); 52 53 /*** 54 * Fire an LayeringEvent with an Edge associated with it. 55 * 56 * @param edge an <code>Edge</code> value 57 */ 58 public void fireLayeringEvent(Edge edge) { 59 LayeringEvent event = new LayeringEvent(edge); 60 for (Iterator iter = m_listeners.iterator(); iter.hasNext();) { 61 ((LayeringListener)iter.next()).layeringViolated(event); 62 } 63 } 64 65 /*** 66 * Add a LayeringListener to the list of Listeners. Each Listener 67 * will receive a LayeringEvent. Each added Listener will receive 68 * the LayeringEvents only once. 69 * 70 * @param listener a <code>LayeringListener</code> value 71 */ 72 public void addLayeringListener(LayeringListener listener) { 73 if (!m_listeners.contains(listener)) { 74 m_listeners.add(listener); 75 } 76 } 77 78 /*** 79 * Remove a Listener from the list of Listeners receiving 80 * LayeringEvents. 81 * 82 * @param listener a <code>LayeringListener</code> value 83 */ 84 public void removeLayeringListener(LayeringListener listener) { 85 if (m_listeners.contains(listener)) { 86 m_listeners.remove(m_listeners.indexOf(listener)); 87 } 88 } 89 }

This page was automatically generated by Maven