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

📄 commandmap.java

📁 java系统通用框架 很实用的东东 一般人都看的懂,
💻 JAVA
字号:
/*****************************************************************************
* (C) Copyright 2004 。
* 保留对所有使用、复制、修改和发布整个软件和相关文档的权利。
* 本计算机程序受著作权法和国际公约的保护,未经授权擅自复制或
* 传播本程序的全部或部分,可能受到严厉的民事和刑事制裁,并
* 在法律允许的范围内受到最大可能的起诉。
*/

 /*****************************************************************************
  * @作者:Golden Peng
  * @版本: 1.0
  * @时间: 2002-10-08
  */
 /*****************************************************************************
  * 修改记录清单
  * 修改人  :
  * 修改记录:
  * 修改时间:
  * 修改描述:
  *
  */
package com.corp.bisc.ebiz.base;

import org.w3c.dom.*;
import java.util.*;
import java.lang.reflect.*;
import com.corp.bisc.ebiz.exception.*;
import com.corp.bisc.ebiz.util.XMLUtil;

/**
 * Insert the type's description here.
 * Creation date: (2002-5-13 11:16:10)
 * @author: Administrator
 */
public class CommandMap extends ObjectBase
{
	private int index;
	private String name = null;
	private String transId = null;
	private String nextTransId = null;
	private String prevTransId = null;
	private boolean resultNext = false;
	private Class cmdClass = null;
	private PresentManager presentMgr = null;
	private Hashtable specialParams = null;

/**
 * CommandMap constructor comment.
 */
public CommandMap() {
	super();
}
protected Command getCommand() throws PortalException
{
	enter("getCommand()");

	Command cmd = null;

	try
	{
		cmd = (Command)cmdClass.newInstance();
	}
	catch(Exception e)
	{
		throw new CommandInitException(e.getLocalizedMessage());
	}

	leave("getCommand()");

	return cmd;
}
/**
 * Insert the method's description here.
 * Creation date: (2002-5-13 12:38:40)
 * @return int
 */
public int getIndex() {
	return index;
}
/**
 * Insert the method's description here.
 * Creation date: (2002-5-13 12:38:40)
 * @return java.lang.String
 */
public java.lang.String getName() {
	return name;
}
	public PresentManager getPresentManager()
	{
		return presentMgr;
	}
	public Hashtable getSpecialParams()
	{
		return specialParams;
	}
/**
 * Insert the method's description here.
 * Creation date: (2002-5-13 12:38:40)
 * @return int
 */
public String getTransId()
{
	return transId;
}
protected void init(Node aNode , Hashtable cmdDefMap) throws InvalidConfigException
{
	NamedNodeMap attribs = aNode.getAttributes();
	Node indexAttrib = attribs.getNamedItem("index");
	Node nameAttrib = attribs.getNamedItem("name");
	Node transAttrib = attribs.getNamedItem("transid");
	Node resultAttrib = attribs.getNamedItem("resultnext");

	if (indexAttrib == null)
		throw new InvalidConfigException("command/@index");
	else
	{
		String indexText = indexAttrib.getNodeValue();

		try
		{
			index = Integer.parseInt(indexText);
		}
		catch(NumberFormatException e)
		{
			throw new InvalidConfigException("command/[@index=" + indexText + "]");
		}
	}

	if (transAttrib != null)
		transId = transAttrib.getNodeValue();
	else
		transId = "1";

	if (nameAttrib == null)
		throw new InvalidConfigException("command/@name");
	else
	{
		name = nameAttrib.getNodeValue();

		String className = (String)cmdDefMap.get(name);

		if (className == null)
			throw new InvalidConfigException("command/[@name=" + name + "]");

		try
		{
			cmdClass = Class.forName(className);

			Method method = cmdClass.getMethod("execute" , new Class[]{RequestContext.class , CommandMap.class});
//			method.getReturnType().
		}
		catch(NoSuchMethodException e)
		{
			throw new InvalidConfigException("command/[@class=" + className + "]");
		}
		catch(ClassNotFoundException e)
		{
			throw new InvalidConfigException("command/[@class=" + className + "]");
		}
	}

	if (resultAttrib != null)
	{
		String resultText = resultAttrib.getNodeValue();

		if (resultText.equalsIgnoreCase("true"))
			resultNext = true;
		else if (resultText.equalsIgnoreCase("false"))
			resultNext = false;
		else
			throw new InvalidConfigException("command/[@resultnext=" + resultNext + "]");
	}

	Node presentMgrNode = XMLUtil.selectSingleNode2(aNode , "PresentManager");
	if (presentMgrNode != null)
	{
		PresentManager manager = new PresentManager();
		manager.init(presentMgrNode);

		presentMgr = manager;
	}

	Vector specialNodes = XMLUtil.selectNodes2(aNode , "specialparams/param");
	specialParams = new Hashtable();
	int size = specialNodes.size();

	for(int i = 0 ; i < size ; i ++)
	{
		Node paramNode = (Node)specialNodes.elementAt(i);
		attribs = paramNode.getAttributes();

		Node nameNode = (Node)attribs.getNamedItem("name");
		Node valueNode = (Node)attribs.getNamedItem("value");

		if (nameNode == null)
			throw new InvalidConfigException("actions/action/commands/command/specialparams/@name");

		if (valueNode == null)
			throw new InvalidConfigException("actions/action/commands/command/specialparams/@value");

		specialParams.put(nameNode.getNodeValue() , valueNode.getNodeValue());
	}
}
/**
 * Insert the method's description here.
 * Creation date: (2002-5-13 12:38:40)
 * @return boolean
 */
public boolean isResultnext() {
	return resultNext;
}
	public boolean isTransBegin()
	{
		enter("isTransBegin()");

		boolean result = false;
		if (transId != null)
		{
			if (prevTransId == null)
				result = true;
			else
				result = !transId.equals(prevTransId);
		}

		leave("isTransBegin()");

		return result;
	}
	public boolean isTransEnd()
	{
		enter("isTransEnd()");

		boolean result = false;
		if (transId != null)
		{
			if (nextTransId == null)
				result = true;
			else
				result = !transId.equals(nextTransId);
		}

		leave("isTransEnd()");

		return result;
	}
/**
 * 此处插入方法描述。
 * 创建日期:(2002-5-16 21:39:57)
 * @param newNextTransId java.lang.String
 */
protected void setNextTransId(java.lang.String newNextTransId) {
	nextTransId = newNextTransId;
}
/**
 * 此处插入方法描述。
 * 创建日期:(2002-5-16 21:39:57)
 * @param newNextTransId java.lang.String
 */
protected void setPrevTransId(java.lang.String newPrevTransId)
{
	prevTransId = newPrevTransId;
}
}

⌨️ 快捷键说明

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