| 1 46 51 package org.mr.core.cmc; 52 53 import java.util.ArrayList ; 54 import java.util.HashMap ; 55 import java.util.List ; 56 57 58 59 64 public class CommandRegistry { 65 private HashMap map= new HashMap (); 66 private ArrayList commandlist = new ArrayList (); 67 68 72 public void registerCommand(CMCCommand command){ 73 if(map.containsKey(command.getRegisterName())){ 74 throw new IllegalArgumentException ("A command is already registered to this name can not over write entry"); 75 } 76 map.put(command.getRegisterName() , command); 77 commandlist.add(command); 78 } 80 85 public CMCCommand getCommand(String registerName){ 86 return (CMCCommand)map.get(registerName); 87 } 88 89 public List getCommands(){ 90 return commandlist; 91 } 92 } 93 | Popular Tags |