📄 actionconfigreader.java.svn-base
字号:
package ase.assignment.sts.utils;
import org.jdom.*;
import org.jdom.input.*;
import java.io.*;
import java.util.List;
import java.util.HashMap;
public class ActionConfigReader{
// config xml file
String configFile = null;
// hashmap used to store action
HashMap actionMap;
// ctor
public ActionConfigReader(String _conffile ){
configFile = _conffile;
actionMap = new HashMap();
}
//
// Public method begins
public boolean hasMoreActionConfigs(){
return true;
}
public HashMap parse(){
SAXBuilder builder = new SAXBuilder();
try{
Document config = builder.build(new FileInputStream(configFile));
Element root = config.getRootElement();
List actionList = root.getChildren("action");
for( int i = 0; i < actionList.size(); i++ ){
Element eAction = (Element)actionList.get(i);
makeAction(eAction);
}
;
}catch(IOException e)
{
e.printStackTrace();
}
catch( JDOMException e)
{
e.printStackTrace();
}
catch( IllegalStateException e )
{
e.printStackTrace();
}
return actionMap;
}
//
// Private method begins
private void makeAction(Element action){
String actionName = action.getAttribute("name").getValue();
ActionConfig ac = new ActionConfig();
//
// get class name
ac.setClassName(action.getChild("class").getAttribute("name").getValue());
System.out.println(" ActionConfig : class <name> " + ac.getClassName());
List forwardList = action.getChildren("forward");
Element eForward;
for( int i = 0; i < forwardList.size(); i++ ){
eForward = (Element)forwardList.get(i);
//System.out.println(eForward.getAttribute("url").getValue());
ac.pushForwardURL(eForward.getAttribute("url").getValue());
// System.out.println(" ActionConfig : forward <url> " + ac.getForwardURL(i));
}
// get forward url
// ac.setForwardURL(action.getChild("forward").getAttribute("url").getValue());
actionMap.put(actionName, ac );
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -