cff992c8dc1d17a61e6ecdf8e7c486b23cdaf099.svn-base 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. package UIB.UIB03.ZBS;
  2. import java.util.HashMap;
  3. import org.w3c.dom.Element;
  4. import org.w3c.dom.NamedNodeMap;
  5. import org.w3c.dom.Node;
  6. import org.w3c.dom.NodeList;
  7. import UIB.COM.DomParserFactory;
  8. /**
  9. *
  10. * @desc 质保书配置文件解析
  11. * @author meiguiping
  12. * @date 2010 4:31:18 PM
  13. */
  14. public class QltyTmplParser
  15. {
  16. // private ArrayList<HashMap> al;
  17. private HashMap map;
  18. public QltyTmplParser()
  19. {
  20. map = new HashMap();
  21. // String currentPath = Thread.currentThread().getContextClassLoader().getResource("").getPath();
  22. String currentPath = this.getClass().getClassLoader().getResource("/").getPath().replaceFirst("classes/", "");
  23. String filePath = currentPath+"excelConfig/qltyExcel_Config.xml";//质保书配置文件
  24. // System.out.println("========================currentPath"+filePath);
  25. DomParserFactory dpf = new DomParserFactory(filePath);
  26. Element e = dpf.getElement();
  27. setParamer(e);
  28. }
  29. // public ArrayList getParamer()
  30. // {
  31. // return al;
  32. // }
  33. public HashMap getParamer()
  34. {
  35. return map;
  36. }
  37. public void setParamer(Element e)
  38. {
  39. if(e.hasChildNodes())
  40. {
  41. NodeList nodelist = e.getChildNodes();
  42. int len = nodelist.getLength();
  43. HashMap attMap = null; //存储属性
  44. HashMap picMap = null; //存储图片
  45. HashMap codeMap = null; //存储二维码图片
  46. for(int i = 0; i < len ; i++)
  47. {
  48. Node node = nodelist.item(i);
  49. if(node.getNodeType() == Node.ELEMENT_NODE)
  50. {
  51. if("propertys".equals(node.getNodeName()))
  52. {
  53. attMap = new HashMap();
  54. NamedNodeMap nnm = node.getAttributes();
  55. int nnmLen = nnm.getLength();
  56. for(int j = 0; j < nnmLen ; j++)
  57. {
  58. attMap.put(nnm.item(j).getNodeName(), nnm.item(j).getNodeValue());
  59. }
  60. String str = node.getParentNode().getAttributes().getNamedItem("tmplName").getNodeValue();
  61. map.put(str+"ATT", attMap);
  62. }
  63. else if("images".equals(node.getNodeName()))
  64. {
  65. picMap = new HashMap();
  66. NamedNodeMap nnm = node.getAttributes();
  67. int nnmLen = nnm.getLength();
  68. for(int j = 0; j < nnmLen ; j++)
  69. {
  70. picMap.put(nnm.item(j).getNodeName(), nnm.item(j).getNodeValue());
  71. }
  72. String str = node.getParentNode().getAttributes().getNamedItem("tmplName").getNodeValue();
  73. map.put(str+"PIC", picMap);
  74. }
  75. else if("codes".equals(node.getNodeName()))
  76. {
  77. codeMap = new HashMap();
  78. NamedNodeMap nnm = node.getAttributes();
  79. int nnmLen = nnm.getLength();
  80. for(int j = 0; j < nnmLen ; j++)
  81. {
  82. codeMap.put(nnm.item(j).getNodeName(), nnm.item(j).getNodeValue());
  83. }
  84. String str = node.getParentNode().getAttributes().getNamedItem("tmplName").getNodeValue();
  85. map.put(str+"CODE", codeMap);
  86. }
  87. Element element = (Element)node;
  88. setParamer(element);
  89. }
  90. }
  91. }
  92. }
  93. }