📄 servercommand.java
字号:
/* CRMS, customer relationship management system Copyright (C) 2003 Service To Youth Council This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA For further information contact the SYC ICT department on GPL@syc.net.au 98 Kermode Street North Adelaide South Australia SA 5006 +61 (0)8 8367 0755 */package crms.util;import java.util.*;import crms.form.FormSubmission;/** * <p>Represents a command or request made from the client to the server.</p> * <p>May simply be a request for information, or could be a command * to update information.</p> * * @author dmurphy */public class ServerCommand { public static String PARAM_USER = "user"; public static String PARAM_REQUEST_FORM = "form.request"; public static String PARAM_FORM_NAME = "form.name"; public static String PARAM_FORM_SUBMIT = "form.submit"; private String key = null; private HashMap params = new HashMap(); private String user = null; /** Creates a new instance of ServerCommand */ public ServerCommand() { } public ServerCommand(String key) { this.key = key; } public ServerCommand(FormSubmission result) { setKey(ServerCommand.PARAM_FORM_SUBMIT); Iterator it = result.fieldNames(); setParameter(ServerCommand.PARAM_FORM_NAME, result.getFormName()); while (it.hasNext()) { String field = (String) it.next(); String value = result.getFieldValue(field); setParameter(field, value); } } public void setKey(String key) { this.key = key; } public String getKey() { return key; } public void setUser(String user) { this.user = user; } public String getUser() { return user; } public HashMap getParameters() { return params; } public void setParameters(HashMap params) { this.params = params; } public Object getParameterValue(String paramName) { if (paramName.equals(PARAM_USER)) { return getUser(); } return params.get(paramName.toLowerCase()); } public void setParameter(String name, AbstractCode code) { if (code != null) { setParameter(name, code.getCode()); } } public void setParameter(String name, Object value) { if (name.equals(PARAM_USER)) { throw new RuntimeException("Can't set user with setParameter!"); } if (params.containsKey(name.toLowerCase())) { params.remove(name); } params.put(name.toLowerCase(), value); } public Iterator getParameterNames() { return params.keySet().iterator(); } public static ServerCommand requestForm(String formName) { ServerCommand command = new ServerCommand(); command.setKey(PARAM_REQUEST_FORM); command.setParameter(PARAM_FORM_NAME, formName); return command; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -