1 16 package org.apache.commons.chain.impl; 17 18 19 import java.util.HashMap ; 20 import java.util.Collections ; 21 import java.util.Iterator ; 22 import java.util.Map ; 23 import org.apache.commons.chain.Catalog; 24 import org.apache.commons.chain.Command; 25 26 27 37 38 public class CatalogBase implements Catalog { 39 40 41 43 44 47 protected Map commands = Collections.synchronizedMap(new HashMap ()); 48 49 50 52 53 public void addCommand(String name, Command command) { 55 56 commands.put(name, command); 57 58 } 59 60 public Command getCommand(String name) { 62 63 return ((Command) commands.get(name)); 64 65 } 66 67 68 public Iterator getNames() { 70 71 return (commands.keySet().iterator()); 72 73 } 74 75 79 public String toString() { 80 81 Iterator names = getNames(); 82 StringBuffer str = 83 new StringBuffer ("[" + this.getClass().getName() + ": "); 84 85 while (names.hasNext()) { 86 str.append(names.next()); 87 if (names.hasNext()) { 88 str.append(", "); 89 } 90 } 91 str.append("]"); 92 93 return str.toString(); 94 95 } 96 } 97 | Popular Tags |