|  |  | 
 |  |  |          } | 
 |  |  |       } | 
 |  |  |    } | 
 |  |  | 	 | 
 |  |  |  | 
 |  |  |    /** | 
 |  |  |     * 检查元素是否存在 | 
 |  |  |     * @param doc doc对象 | 
 |  |  |     * @param elementName 元素名称 | 
 |  |  |     * @return 返回结果  返回结果 | 
 |  |  |     */ | 
 |  |  |    public Element getElement(Document doc, String elementName){ | 
 |  |  |       if(doc == null){ | 
 |  |  |          return null ; | 
 |  |  |       } | 
 |  |  |       if(elementName == null){ | 
 |  |  |          return null ; | 
 |  |  |       } | 
 |  |  |       elementName = elementName.trim() ; | 
 |  |  |       if(elementName.equals("")){ | 
 |  |  |          return null ; | 
 |  |  |       } | 
 |  |  |       return this.get_element(doc, elementName) ; | 
 |  |  |    } | 
 |  |  |  | 
 |  |  |    /** | 
 |  |  |     * 检查元素是否存在 | 
 |  |  |     * @param doc doc对象 | 
 |  |  | 
 |  |  |       elementName = elementName.trim() ; | 
 |  |  |       if(elementName.equals("")){ | 
 |  |  |          return false ; | 
 |  |  |       }	 | 
 |  |  |       Element e = this.getElement(doc, elementName) ; | 
 |  |  |       } | 
 |  |  |       Element e = this.get_element(doc, elementName) ; | 
 |  |  |       return e != null; | 
 |  |  |    } | 
 |  |  |  | 
 |  |  | 
 |  |  |     * @throws Exception  抛出异常 | 
 |  |  |     */ | 
 |  |  |    public String getSetAttrTxt(Document doc, String elementName, String attrName, String attPropertyNameFix, Boolean canBlank, String setValue) throws Exception{ | 
 |  |  |       Element e = this.checkAndGetElement(doc, elementName); | 
 |  |  |       Element e = this.check_and_get_element(doc, elementName); | 
 |  |  |       return this.getSetAttrTxt(e, attrName, attPropertyNameFix, canBlank, setValue) ; | 
 |  |  |    } | 
 |  |  |     | 
 |  |  | 
 |  |  |     * @throws Exception  抛出异常 | 
 |  |  |     */ | 
 |  |  |    public Integer getSetAttrPlusInt(Document doc, String elementName, String attrName, String attPropertyNameFix, Integer min, Integer max, String setValue) throws Exception{ | 
 |  |  |       Element e = this.checkAndGetElement(doc, elementName); | 
 |  |  |       Element e = this.check_and_get_element(doc, elementName); | 
 |  |  |       return this.getSetAttrPlusInt(e, attrName, attPropertyNameFix, min, max, setValue) ; | 
 |  |  |    } | 
 |  |  |  | 
 |  |  | 
 |  |  |     * @throws Exception  抛出异常 | 
 |  |  |     */ | 
 |  |  |    public Integer getSetAttrInt(Document doc, String elementName, String attrName, String attPropertyNameFix, Integer min, Integer max, String setValue) throws Exception{ | 
 |  |  |       Element e = this.checkAndGetElement(doc, elementName); | 
 |  |  |       Element e = this.check_and_get_element(doc, elementName); | 
 |  |  |       return this.getSetAttrInt(e, attrName, attPropertyNameFix, min, max, setValue) ; | 
 |  |  |    } | 
 |  |  |     | 
 |  |  | 
 |  |  |     * @throws Exception  抛出异常 | 
 |  |  |     */ | 
 |  |  |    public Double getSetAttrPlusDouble(Document doc, String elementName, String attrName, String attPropertyNameFix, Double min, Double max, String setValue) throws Exception{ | 
 |  |  |       Element e = this.checkAndGetElement(doc, elementName); | 
 |  |  |       Element e = this.check_and_get_element(doc, elementName); | 
 |  |  |       return this.getSetAttrPlusDouble(e, attrName, attPropertyNameFix, min, max, setValue) ; | 
 |  |  |    } | 
 |  |  |     | 
 |  |  | 
 |  |  |     * @throws Exception  抛出异常 | 
 |  |  |     */ | 
 |  |  |    public Double getSetAttrDouble(Document doc, String elementName, String attrName, String attPropertyNameFix, Double min, Double max, String setValue) throws Exception{ | 
 |  |  |       Element e = this.checkAndGetElement(doc, elementName); | 
 |  |  |       Element e = this.check_and_get_element(doc, elementName); | 
 |  |  |       return this.getSetAttrDouble(e, attrName, attPropertyNameFix, min, max, setValue) ; | 
 |  |  |    } | 
 |  |  |     | 
 |  |  | 
 |  |  |     * @param elementName 元素名称 元素名,形如"config.base.test" | 
 |  |  |     * @return 返回结果 | 
 |  |  |     */ | 
 |  |  |    private Element getElement(Document doc, String elementName){ | 
 |  |  |    private Element get_element(Document doc, String elementName){ | 
 |  |  |       Element e = null ; | 
 |  |  |       Element root ; | 
 |  |  |       String nm ; | 
 |  |  | 
 |  |  |             if(eNames.length == 1){ | 
 |  |  |                e = root ; | 
 |  |  |             }else{ | 
 |  |  |                e = this.getNextElement(root, eNames, 1) ; | 
 |  |  |                e = this.get_next_element(root, eNames, 1) ; | 
 |  |  |             } | 
 |  |  |          } | 
 |  |  |       } | 
 |  |  | 
 |  |  |     * @param index 数组下标 | 
 |  |  |     * @return 返回结果 | 
 |  |  |     */ | 
 |  |  |    private Element getNextElement(Element base, String[] eNames, int index){ | 
 |  |  |    private Element get_next_element(Element base, String[] eNames, int index){ | 
 |  |  |       Element e = null ; | 
 |  |  |       String nm ; | 
 |  |  |       List<Element> list = base.getChildren() ; | 
 |  |  | 
 |  |  |                if(eNames.length == index + 1){ | 
 |  |  |                   e = el ; | 
 |  |  |                }else{ | 
 |  |  |                   e = this.getNextElement(el, eNames, index + 1) ; | 
 |  |  |                   e = this.get_next_element(el, eNames, index + 1) ; | 
 |  |  |                } | 
 |  |  |                break ; | 
 |  |  |             } | 
 |  |  | 
 |  |  |     * @return 返回结果 | 
 |  |  |     * @throws Exception  抛出异常 | 
 |  |  |     */ | 
 |  |  |    private Element checkAndGetElement(Document doc, String elementName)throws Exception{ | 
 |  |  |    private Element check_and_get_element(Document doc, String elementName)throws Exception{ | 
 |  |  |       if(doc == null){ | 
 |  |  |          throw new Exception("配置文件的DOM对象为空!"); | 
 |  |  |       } | 
 |  |  | 
 |  |  |       if(elementName.equals("")){ | 
 |  |  |          throw new Exception("元素名为空!"); | 
 |  |  |       }    | 
 |  |  |       Element e = this.getElement(doc, elementName) ; | 
 |  |  |       Element e = this.get_element(doc, elementName) ; | 
 |  |  |       if(e == null){ | 
 |  |  |          throw new Exception("未得到名称为" + elementName + "的元素!"); | 
 |  |  |       } |