1 5 package org.infohazard.maverick.flow; 6 7 import java.util.Map ; 8 import org.jdom.Element; 9 10 18 class CommandFactory 19 { 20 21 protected final static String TAG_VIEW = "view"; 22 23 24 protected final static String TAG_CONTROLLER = "controller"; 25 26 27 protected ViewRegistry viewRegistry; 28 29 30 protected ControllerFactory controllerFactory = new DefaultControllerFactory(); 31 32 35 public CommandFactory(ViewRegistry viewReg) 36 { 37 this.viewRegistry = viewReg; 38 } 39 40 47 public Command createCommand(Element commandNode) throws ConfigException 48 { 49 Controller ctl = this.controllerFactory.createController(commandNode.getChild(TAG_CONTROLLER)); 50 51 Map viewsMap = this.viewRegistry.createViewsMap(commandNode.getChildren(TAG_VIEW)); 52 if (viewsMap.size() > 1) 53 return new CommandMultipleViews(ctl, viewsMap); 54 else 55 { 56 View theView = (View)viewsMap.values().iterator().next(); 59 return new CommandSingleView(ctl, theView); 60 } 61 } 62 63 67 public ViewRegistry getViewRegistry() 68 { 69 return viewRegistry; 70 } 71 75 public void setViewRegistry(ViewRegistry viewReg) 76 { 77 this.viewRegistry = viewReg; 78 } 79 83 public ControllerFactory getControllerFactory() 84 { 85 return controllerFactory; 86 } 87 91 public void setControllerFactory(ControllerFactory controllerFactory) 92 { 93 this.controllerFactory = controllerFactory; 94 } 95 } 96 97 | Popular Tags |