| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- package UIB.UIB03.ZBS;
- import java.util.HashMap;
- import org.w3c.dom.Element;
- import org.w3c.dom.NamedNodeMap;
- import org.w3c.dom.Node;
- import org.w3c.dom.NodeList;
- import UIB.COM.DomParserFactory;
- /**
- *
- * @desc 质保书配置文件解析
- * @author meiguiping
- * @date 2010 4:31:18 PM
- */
- public class QltyTmplParser
- {
- // private ArrayList<HashMap> al;
- private HashMap map;
-
- public QltyTmplParser()
- {
- map = new HashMap();
-
- // String currentPath = Thread.currentThread().getContextClassLoader().getResource("").getPath();
-
- String currentPath = this.getClass().getClassLoader().getResource("/").getPath().replaceFirst("classes/", "");
- String filePath = currentPath+"excelConfig/qltyExcel_Config.xml";//质保书配置文件
- // System.out.println("========================currentPath"+filePath);
- DomParserFactory dpf = new DomParserFactory(filePath);
- Element e = dpf.getElement();
- setParamer(e);
- }
-
- // public ArrayList getParamer()
- // {
- // return al;
- // }
-
- public HashMap getParamer()
- {
- return map;
- }
-
- public void setParamer(Element e)
- {
- if(e.hasChildNodes())
- {
- NodeList nodelist = e.getChildNodes();
- int len = nodelist.getLength();
-
- HashMap attMap = null; //存储属性
- HashMap picMap = null; //存储图片
- HashMap codeMap = null; //存储二维码图片
- for(int i = 0; i < len ; i++)
- {
- Node node = nodelist.item(i);
- if(node.getNodeType() == Node.ELEMENT_NODE)
- {
- if("propertys".equals(node.getNodeName()))
- {
- attMap = new HashMap();
- NamedNodeMap nnm = node.getAttributes();
- int nnmLen = nnm.getLength();
- for(int j = 0; j < nnmLen ; j++)
- {
- attMap.put(nnm.item(j).getNodeName(), nnm.item(j).getNodeValue());
- }
- String str = node.getParentNode().getAttributes().getNamedItem("tmplName").getNodeValue();
- map.put(str+"ATT", attMap);
- }
- else if("images".equals(node.getNodeName()))
- {
- picMap = new HashMap();
- NamedNodeMap nnm = node.getAttributes();
- int nnmLen = nnm.getLength();
- for(int j = 0; j < nnmLen ; j++)
- {
- picMap.put(nnm.item(j).getNodeName(), nnm.item(j).getNodeValue());
- }
- String str = node.getParentNode().getAttributes().getNamedItem("tmplName").getNodeValue();
- map.put(str+"PIC", picMap);
- }
- else if("codes".equals(node.getNodeName()))
- {
- codeMap = new HashMap();
- NamedNodeMap nnm = node.getAttributes();
- int nnmLen = nnm.getLength();
- for(int j = 0; j < nnmLen ; j++)
- {
- codeMap.put(nnm.item(j).getNodeName(), nnm.item(j).getNodeValue());
- }
- String str = node.getParentNode().getAttributes().getNamedItem("tmplName").getNodeValue();
- map.put(str+"CODE", codeMap);
- }
- Element element = (Element)node;
- setParamer(element);
- }
- }
- }
- }
- }
|