1 17 package org.apache.bcel.verifier; 18 19 import java.util.HashMap ; 20 import java.util.Iterator ; 21 import java.util.List ; 22 import java.util.Map ; 23 import java.util.Vector ; 24 25 35 public class VerifierFactory { 36 37 40 private static Map hashMap = new HashMap (); 41 44 private static List observers = new Vector (); 45 46 47 50 private VerifierFactory() { 51 } 52 53 54 59 public static Verifier getVerifier( String fully_qualified_classname ) { 60 Verifier v = (Verifier) (hashMap.get(fully_qualified_classname)); 61 if (v == null) { 62 v = new Verifier(fully_qualified_classname); 63 hashMap.put(fully_qualified_classname, v); 64 notify(fully_qualified_classname); 65 } 66 return v; 67 } 68 69 70 73 private static void notify( String fully_qualified_classname ) { 74 Iterator i = observers.iterator(); 76 while (i.hasNext()) { 77 VerifierFactoryObserver vfo = (VerifierFactoryObserver) i.next(); 78 vfo.update(fully_qualified_classname); 79 } 80 } 81 82 83 90 public static Verifier[] getVerifiers() { 91 Verifier[] vs = new Verifier[hashMap.values().size()]; 92 return (Verifier[]) (hashMap.values().toArray(vs)); } 94 95 96 99 public static void attach( VerifierFactoryObserver o ) { 100 observers.add(o); 101 } 102 103 104 107 public static void detach( VerifierFactoryObserver o ) { 108 observers.remove(o); 109 } 110 } 111 | Popular Tags |