<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    上善若水
    In general the OO style is to use a lot of little objects with a lot of little methods that give us a lot of plug points for overriding and variation. To do is to be -Nietzsche, To bei is to do -Kant, Do be do be do -Sinatra
    posts - 146,comments - 147,trackbacks - 0
     1public class MapDeserialize {
     2    public static void main(String[] args) {
     3        Map<String, String> map = new HashMap<String, String>();
     4        map.put("key1""value1");
     5        map.put("key2"null);
     6        map.put("key3""");
     7        
     8        System.out.println(map);
     9        
    10        Map<String, String> emptyMap = new HashMap<String, String>();
    11        System.out.println(emptyMap);
    12        
    13        MapDeserialize deserialize = new MapDeserialize();
    14        String str1 = "{key3=, key2=null, key1=value1}";
    15        String str2 = "{}";
    16        Map<String, String> map1 = deserialize.str2Map(str1);
    17        System.out.println("map1: " + map1);
    18        Map<String, String> map2 = deserialize.str2Map(str2);
    19        System.out.println("map2: " + map2);
    20    }

    21    
    22    // We are assuming that the str is generated by map.toString(), so the str will be something like:
    23    // '{key3=, key2=null, key1=value1}' or '{}'
    24    public Map<String, String> str2Map(String str) {
    25        Map<String, String> map = new HashMap<String, String>();
    26        // The parameters map is empty
    27        if("{}".equals(str) || str == null || str.length() == 0{
    28            return map;
    29        }

    30        
    31        // Remove the '{' prefix and '}' suffix
    32        str = str.substring(1, str.length() - 1);
    33        String[] entries = str.split(",");
    34        for(String entry : entries) {
    35            String[] pair = entry.split("=");
    36            String key = pair[0].trim();
    37            if(pair.length == 1{
    38                map.put(key, "");
    39            }
     else {
    40                String value = pair[1].trim();
    41                if("null".equals(value)) {
    42                    map.put(key, null);
    43                }
     else {
    44                    map.put(key, value);
    45                }

    46            }

    47        }

    48        
    49        return map;
    50    }

    51}
    這段代碼貌似沒什么價值,只是保留著,以后再遇到相應的情況,可以再做改進。
    posted on 2011-09-20 15:54 DLevin 閱讀(522) 評論(0)  編輯  收藏 所屬分類: CodeTools
    主站蜘蛛池模板: 亚洲综合国产一区二区三区| 国产免费福利体检区久久| 国产精品亚洲片在线观看不卡| 在线v片免费观看视频| 中文字幕免费在线看| 在线观看免费亚洲| 亚洲成AV人综合在线观看| 亚洲av无码潮喷在线观看| 亚洲欧洲自拍拍偷精品 美利坚| 成年女人视频网站免费m| 日本xxxx色视频在线观看免费| 国产va免费观看| 香港一级毛片免费看| 亚洲国产成人综合精品| 91丁香亚洲综合社区| 亚洲男女一区二区三区| 久久国产精品亚洲一区二区| 亚洲尤码不卡AV麻豆| 亚洲?V无码成人精品区日韩| 蜜桃精品免费久久久久影院| 久久午夜免费视频| 久久精品免费一区二区| 6080午夜一级毛片免费看| 精品在线免费观看| 91在线视频免费观看| 一区二区3区免费视频| 暖暖免费中文在线日本| 国产成人综合亚洲绿色| 亚洲av永久无码一区二区三区| 亚洲熟妇无码一区二区三区导航| 亚洲成a人片在线观看中文!!!| 亚洲毛片免费观看| 久久精品国产亚洲av麻豆色欲| 亚洲成人免费在线| 91精品国产亚洲爽啪在线观看| 久久亚洲精品AB无码播放| 亚洲Av无码专区国产乱码DVD| 亚洲AV中文无码乱人伦下载| 亚洲国产一区在线| 亚洲一区中文字幕久久| 亚洲免费黄色网址|