예제 #1
0
 /**
  * 删除配置信息
  *
  * @param xpath
  */
 public void removeConfigs(String xpath) {
   List<?> nodes = doc.selectNodes(xpath);
   for (int i = 0; i < nodes.size(); i++) {
     XmlUtilsEx.removeNode((Node) nodes.get(i));
   }
 }
예제 #2
0
 /**
  * 获取简单配置信息,按映射表形式返回,其中key=属性名,value=属性值
  *
  * @param xpath 节点元素路径,如:/root/param1/param2
  * @return
  * @see XmlUtilsEx#parseAsSimpleMap(Document, String)
  */
 public Map<String, Object> getSimpleValues(String xpath) {
   return XmlUtilsEx.parseAsSimpleMap(doc, xpath);
 }
예제 #3
0
 /**
  * 设置单值配置信息
  *
  * @param xpath
  * @param value
  */
 public void setSingleValue(String xpath, String value) {
   XmlUtilsEx.setNodeText(doc, xpath, value);
 }
예제 #4
0
 /**
  * 设置节点的属性集,详细参见 {@link XmlUtilsEx#setNodeValues(Element, Map, Map, boolean)}
  *
  * @param xpath 节点路径
  * @param params 设置的子节点配置信息
  * @return
  */
 public Element setValues(String xpath, Map<String, Object> params) {
   Element elem = (Element) doc.selectSingleNode(xpath);
   if (elem == null) elem = DocumentHelper.makeElement(doc, xpath);
   return XmlUtilsEx.setElement(elem, params, true);
 }
예제 #5
0
 /**
  * 获取某同类节点值的数据集
  *
  * @param xpath 节点路径
  * @return
  */
 public String[] getValues(String xpath) {
   return XmlUtilsEx.getSingleTexts(doc, xpath);
 }
예제 #6
0
 /**
  * 获取某个节点中的配置属性值
  *
  * @param elem 节点
  * @param paramName 属性名
  * @return
  */
 public String getSingleValue(Element elem, String paramName) {
   return XmlUtilsEx.getSingleText(elem, paramName);
 }
예제 #7
0
 /**
  * 获取某单一节点的属性值
  *
  * @param xpath 节点元素路径,如:/root/param1/param2
  * @return
  */
 public String getSingleValue(String xpath) {
   return XmlUtilsEx.getSingleText(doc, xpath);
 }
예제 #8
0
 /**
  * 获取一个较复杂节点的属性值,如果节点包含子节点,则子节点的属性也组装为一个Map返回
  *
  * @param xpath
  * @return
  * @see XmlUtilsEx#parseAsComplexMap(Node)
  */
 public Map<String, Object> getComplexValues(String xpath) {
   Node node = doc.selectSingleNode(xpath);
   return XmlUtilsEx.parseAsComplexMap(node);
 }
예제 #9
0
 /**
  * 这里获取的是存在多个同类节点情况下的配置信息
  *
  * @param xpath 节点元素路径,如:/root/param1/param2
  * @return
  * @see XmlUtilsEx#parseAsSimpleMaps(Document, String)
  */
 public List<Map<String, Object>> getSimpleValueList(String xpath) {
   return XmlUtilsEx.parseAsSimpleMaps(doc, xpath);
 }