1 17 18 19 20 package org.apache.fop.layoutmgr; 21 22 import java.util.Iterator ; 23 import java.util.List ; 24 25 30 public class ElementListObserver { 31 32 private static List activeObservers = null; 33 34 38 public static void addObserver(Observer observer) { 39 if (!isObservationActive()) { 40 activeObservers = new java.util.ArrayList (); 41 } 42 activeObservers.add(observer); 43 } 44 45 50 public static void removeObserver(Observer observer) { 51 if (isObservationActive()) { 52 activeObservers.remove(observer); 53 } 54 } 55 56 62 public static void observe(List elementList, String category, String id) { 63 if (isObservationActive()) { 64 if (category == null) { 65 throw new NullPointerException ("category must not be null"); 66 } 67 Iterator i = activeObservers.iterator(); 68 while (i.hasNext()) { 69 ((Observer)i.next()).observe(elementList, category, id); 70 } 71 } 72 } 73 74 75 public static boolean isObservationActive() { 76 return activeObservers != null; 77 } 78 79 82 public interface Observer { 83 84 91 void observe(List elementList, String category, String id); 92 93 } 94 95 } 96 | Popular Tags |