Esempio n. 1
0
 @SuppressWarnings("rawtypes")
 public static void mergeSataMap(SataMap target, SataMap source) {
   for (Iterator it = target.entrySet().iterator(); it.hasNext(); ) {
     Map.Entry entry = (Map.Entry) it.next();
     if (!source.containsKey(entry.getKey())) it.remove();
     if (entry.getValue().equals(source.get(entry.getKey()))) it.remove();
   }
 }
Esempio n. 2
0
 @SuppressWarnings("unchecked")
 private static SataList getSubSataList(JSONArray jsonArray) {
   SataList list = new SataListImpl();
   for (int i = 0; i < jsonArray.size(); i++) {
     JSONObject object = jsonArray.getJSONObject(i);
     SataMap sataMap = new SataMapImpl();
     sataMap.putAll(json2SataMap(object));
     list.add(sataMap);
   }
   return list;
 }
Esempio n. 3
0
 /** @Author:LZY @Date:2015/2/26 @Fuction:JSONObject SataMap 互转 */
 @SuppressWarnings("unchecked")
 public static SataMap json2SataMap(JSONObject json) {
   SataMap sataMap = new SataMapImpl();
   for (Iterator<Entry<String, Object>> it = json.entrySet().iterator(); it.hasNext(); ) {
     Entry<String, Object> entry = it.next();
     if (entry.getValue() instanceof JSONArray) {
       SataList list = getSubSataList((JSONArray) entry.getValue());
       sataMap.put(entry.getKey(), list);
     } else {
       sataMap.put(entry.getKey(), entry.getValue());
     }
   }
   return sataMap;
 }
Esempio n. 4
0
 @SuppressWarnings("unchecked")
 public static SataMap sataMapGetSubSataMap(SataMap sataMap) {
   SataMap tempSataMap = new SataMapImpl();
   for (Iterator<Map.Entry<String, Object>> it = sataMap.entrySet().iterator(); it.hasNext(); ) {
     Entry<String, Object> entry = it.next();
     if (entry.getValue() instanceof SataList) {
       String key = entry.getKey();
       SataList sataList = (SataList) entry.getValue();
       for (int i = 0; i < sataList.size(); i++) {
         if (sataList.get(i) instanceof SataMap) {
           SataMap map = (SataMap) sataList.get(i);
           if (map.containsKey("PARA_ID")) {
             String para_id = map.getString("PARA_ID").toUpperCase();
             String para_value = map.getString("PARA_VALUE");
             tempSataMap.put(para_id, para_value);
           }
         }
       }
       // sataMap.remove(key);
     } else {
       tempSataMap.put(entry.getKey(), entry.getValue());
     }
   }
   return tempSataMap;
 }
Esempio n. 5
0
  @SuppressWarnings("unchecked")
  public static SataMap sataMap2SataMap(SataMap subSataMap) {
    SataMap sataMap = new SataMapImpl();
    for (Iterator<Map.Entry<String, Object>> it = subSataMap.entrySet().iterator();
        it.hasNext(); ) {
      Entry<String, Object> entry = it.next();
      if (entry.getValue() instanceof SataList) {
        SataList sataList = (SataList) entry.getValue();
        for (int i = 0; i < sataList.size(); i++) {
          if (sataList.get(i) instanceof SataMap) {
            sataMap.putAll(sataMap2SataMap((SataMap) sataList.get(i)));
          }
        }
      } else {

        sataMap.put(entry.getKey().toString(), entry.getValue());
      }
    }
    return sataMap;
  }
Esempio n. 6
0
 /** @Author:LZY @Date:2015/2/26 @Fuction:JSONObject SataMap 互转 */
 @SuppressWarnings("unchecked")
 public static JSONObject sataMap2JSON(SataMap sataMap) {
   JSONObject jsonObject = new JSONObject();
   for (Iterator<Map.Entry<String, Object>> it = sataMap.entrySet().iterator(); it.hasNext(); ) {
     Entry<String, Object> entry = it.next();
     if (entry.getValue() instanceof SataList) {
       JSONArray array = getSubJsonArray((SataList) entry.getValue());
       jsonObject.put(entry.getKey().toString(), array);
     } else {
       jsonObject.put(entry.getKey().toString(), entry.getValue());
     }
   }
   return jsonObject;
 }
Esempio n. 7
0
 // 将data里面指定的值除以100
 public static void div100(SataMap data, String key) {
   if (key == null || key.equals("")) key = "0";
   data.put(key, div100(data.getString(key)));
 }