package net.sf.arianne.marboard.server.action;
import java.util.HashMap;
import java.util.Map;
import net.sf.arianne.marboard.server.action.create.CreateDotAction;
import net.sf.arianne.marboard.server.action.create.CreateOvalAction;
import net.sf.arianne.marboard.server.action.create.CreateRectangleAction;
import net.sf.arianne.marboard.server.action.create.CreateStraightLineAction;
import net.sf.arianne.marboard.server.action.create.ImportShapesAction;
/**
* creates actions
*
* @author hendrik
*/
public class ActionFactory {
Map<String, Action> actions = new HashMap<String, Action>();
UnknownAction unknownAction = new UnknownAction();
/**
* registers all actions
*/
public void register() {
actions.put("clear_action", new ClearAction());
actions.put("create_dot_action", new CreateDotAction());
actions.put("create_rectangle_action", new CreateRectangleAction());
actions.put("create_straight_line_action", new CreateStraightLineAction());
actions.put("create_oval_action", new CreateOvalAction());
actions.put("import_shapes_action", new ImportShapesAction());
}
/**
* returns an action object
*
* @param type type of actions
* @return Action
*/
public Action create(String type) {
Action action = actions.get(type);
if (action != null) {
return action;
}
return unknownAction;
}
}