actionparser.java
来自「稿件名称:基于JAVA的JNDI技术和反射机制 稿件作者:段谟意 」· Java 代码 · 共 77 行
JAVA
77 行
package ddd.com.parse;
import javax.servlet.*;
import java.util.*;
import org.w3c.dom.*;
import ddd.com.ConfigConstants;
import ddd.com.config.*;
public class ActionParser extends AbstractParser
{
private HashMap actions;
private HashMap formbeans;
public void init(ServletContext sct,String xmlSource)
{
super.init(sct,xmlSource);
actions=new HashMap();
formbeans=new HashMap();
handlerActions();
handlerFormbeans();
clearup();
}
private void handlerActions()
{
NodeList actionList=getElements(root,ConfigConstants.ACTION);
for(int i=0;i<actionList.getLength();i++)
{
ActionConfig actionConfig=new ActionConfig();
String path=this.getProperty(actionList.item(i),ConfigConstants.PATH);
String type=this.getProperty(actionList.item(i),ConfigConstants.TYPE);
String name=this.getProperty(actionList.item(i),ConfigConstants.NAME);
String sValidate=this.getProperty(actionList.item(i),ConfigConstants.VALIDATE);
String input=this.getProperty(actionList.item(i),ConfigConstants.INPUT);
actionConfig.setPath(path);
actionConfig.setType(type);
actionConfig.setName(name);
if(sValidate!=null && sValidate.equals("true"))
actionConfig.setValidate(true);
else
actionConfig.setValidate(false);
actionConfig.setInput(input);
if(actionList.item(i).hasChildNodes())
{
NodeList forwardList=this.getElements(actionList.item(i),ConfigConstants.FORWARD);
for(int j=0;j<forwardList.getLength();j++)
{
ForwardConfig fConfig=new ForwardConfig();
String fname=this.getProperty(forwardList.item(j),ConfigConstants.NAME);
String uri=this.getProperty(forwardList.item(j),ConfigConstants.URI);
fConfig.setPath(path);
fConfig.setName(fname);
fConfig.setUri(uri);
actionConfig.addForward(fConfig);
}
}
actions.put(path,actionConfig);
}
}
private void handlerFormbeans()
{
NodeList nodeList=this.getElements(root,ConfigConstants.FORM_BEAN);
for(int i=0;i<nodeList.getLength();i++)
{
FormbeanConfig formConfig=new FormbeanConfig();
String name=this.getProperty(nodeList.item(i),ConfigConstants.NAME);
String type=this.getProperty(nodeList.item(i),ConfigConstants.TYPE);
formConfig.setName(name);
formConfig.setType(type);
formbeans.put(name,formConfig);
}
}
public HashMap getActions()
{
return actions;
}
public HashMap getFormbeans()
{
return formbeans;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?