⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 actiondata.java

📁 Jodd是一个开源的公用Java基础类库
💻 JAVA
字号:
package jodd.servlet;

import java.util.HashMap;

/**
 * Util value object class for ActionController. It holds information for all
 * actions defined in the configuration xml file.
 *
 * @see ActionController
 */
final class ActionData {

	/**
	 * Default constructor.
	 */
	public ActionData() {
	}

	/**
	 * Constructor.
	 *
	 * @param path
	 * @param type
	 */
	public ActionData(String path, String type) {
		setPath(path);
		setType(type);
		setMethod(null);
	}

	/**
	 * Constructor.
	 *
	 * @param path
	 * @param type
	 */
	public ActionData(String path, String type, String method) {
		setPath(path);
		setType(type);
		setMethod(method);
	}

	// ---------------------------------------------------------------- path

	private String path;
	/**
	 * Sets the request path that triggers an ActionServlet.
	 *
	 * @param v
	 */
	public void setPath(String v) {
		path = v;
	}
	/**
	 * Get path that triggers an ActionServlet.
	 *
	 * @return
	 */
	public String getPath() {
		return path;
	}

	// ---------------------------------------------------------------- type
	
	private String type;
	/**
	 * Sets the type of the ActionServlet that will be executed. It is the name
	 * of the class that will be loaded and instanced first time when needed.
	 *
	 * @param v
	 */
	public void setType(String v) {
		type = v;
	}
	/**
	 * Returns name of the ActionServlet type.
	 *
	 * @return
	 */
	public String getType() {
		return type;
	}

	// ---------------------------------------------------------------- method

	private String method;
	/**
	 * Sets the ActionServlet method that will handle the action.
	 * If null, default doAction will be called.
	 *
	 * @param v      method name
	 */
	public void setMethod(String v) {
		method = v;
	}
	/**
	 * Returns the name of the method on wich action is mapped.
	 *
	 * @return name od the mapped action
	 */
	public String getMethod() {
		return method;
	}

	// ---------------------------------------------------------------- action
	
	private ActionServlet action = null;
	/**
	 * Assigns specific ActionServlet object to a request.
	 *
	 * @param v      ActionServlet object
	 */
	public void setAction(ActionServlet v) {
		action = v;
	}
	/**
	 * Returns assigned ActionServlet.
	 *
	 * @return assigned ActionServlet, or null if no object assigned
	 */
	public ActionServlet getAction() {
		return action;
	}
	
	// ---------------------------------------------------------------- forwards

	private HashMap forwards = new HashMap();
	
	/**
	 * Defines an forward. They are eather real forward eather redirects. This is
	 * just 1-1 list of names and associated paths where to forward/redirect.
	 *
	 * @param name     name of the action
	 * @param path     request path that will trigger ActionServlet
	 * @param redirect boolean-like string that defines if ActionServlet will forward (default)
	 *                 or redirect (if "true") after processing ActionServlet.
	 */
	public void putForwardPath(String name, String path, String redirect) {
		Boolean rdrct = Boolean.FALSE;
		if (redirect.equalsIgnoreCase("true")) {
			rdrct = Boolean.TRUE;
		}
		forwards.put(name, new Object[] {path, rdrct});
	}
	/**
	 * Returns forward path assigned with the given name.
	 *
	 * @param name
	 *
	 * @return assiged forward path, null if doesn't exist
	 */
	public String getForwardPath(String name) {
		Object[] fwds = (Object[]) forwards.get(name);
		if (fwds == null) {
			return null;
		}
		return (String)(fwds[0]);
	}
	/**
	 * Gets the information for a forward: will it be forwarded or redirected.
	 *
	 * @param name
	 *
	 * @return false for forward (or error), true for redirect
	 */
	public boolean isForwardRedirect(String name) {
		Object[] flag = (Object[]) forwards.get(name);
		if (flag == null) {
			return false;
		}
		Boolean b = (Boolean) (flag[1]);
		return b.booleanValue();
	}


	// ---------------------------------------------------------------- parameters

	private HashMap	parameters = new HashMap();

	/**
	 * Defines action parameters.
	 *
	 * @param name   parameter name
	 * @param value  parameter value
	 */
	public void putParameter(String name, String value) {
		if (name == null) {
			return;
		}
		parameters.put(name, value);
	}

	/**
	 * Returns action parameter value.
	 *
	 * @param name   parameer name
	 *
	 * @return action parameter value
	 */
	public String getParameter(String name) {
		return (String) parameters.get(name);
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -