Beispiel #1
0
 /**
  * 字符串格式参数转换成HashMap
  *
  * @param str String 字符串参数
  * @return Map
  */
 public static Map splitParam(String str) {
   Map result = new HashMap();
   Document doc = XMLTools.stringToDocument(str);
   NodeList elements = doc.getElementsByTagName("param");
   for (int i = 0, j = elements.getLength(); i < j; i++) {
     Node param = elements.item(i);
     NodeList childs = param.getChildNodes();
     String paramName = null;
     String paramValue = null;
     for (int m = 0, n = childs.getLength(); m < n; m++) {
       Node child = childs.item(m);
       if (child.getNodeName().equalsIgnoreCase("name")) {
         paramName = child.getFirstChild().getNodeValue();
       } else {
         if (child.hasChildNodes()) {
           paramValue = child.getFirstChild().getNodeValue();
         } else {
           paramValue = "";
         }
       }
     }
     result.put(paramName, paramValue);
   }
   return result;
 }
Beispiel #2
0
 /**
  * 将字符串格式的页面元素信息解析成Java对象列表
  *
  * @param s String 元素字段串
  * @return List 对象列表
  */
 public static List extractLabel(String s) {
   List result = new ArrayList();
   if (!s.equalsIgnoreCase("")) {
     Document doc = XMLTools.stringToDocument(s);
     NodeList elements = doc.getElementsByTagName("element");
     for (int i = 0, j = elements.getLength(); i < j; i++) {
       Node node = elements.item(i);
       StaticTextInfor ele = new StaticTextInfor(node);
       result.add(ele);
     }
   }
   return result;
 }
Beispiel #3
0
 /**
  * 将字符串格式的页面元素信息解析成Java对象列表
  *
  * @param s String 元素字段串
  * @return Object 对象列表,第一个元素是参数对象列表,第二个对象是参数值
  */
 public static Object[] extractParam(String s) {
   Object[] results = new Object[2];
   List result = new ArrayList();
   Map paramValues = new HashMap();
   if (!s.equalsIgnoreCase("")) {
     Document doc = XMLTools.stringToDocument(s);
     NodeList elements = doc.getElementsByTagName("element");
     for (int i = 0, j = elements.getLength(); i < j; i++) {
       Node node = elements.item(i);
       ParamFieldInfor ele = new ParamFieldInfor(node);
       result.add(ele);
     }
     NodeList values = doc.getElementsByTagName("content");
     for (int i = 0, j = elements.getLength(); i < j; i++) {
       Node node = values.item(i);
       String value = node.getFirstChild().getNodeValue();
       String name = node.getAttributes().item(0).getNodeValue();
       paramValues.put(name, value);
     }
   }
   results[0] = result;
   results[1] = paramValues;
   return results;
 }