package net.common.utils;

import net.common.utils.config.xml.server.Server;
import net.common.utils.config.xml.server.Servers;
import net.common.utils.xml.JAXBUtil;

import java.util.Map;
import java.util.Set;

/**
 * <p/>
 * User : krisibm@163.com
 * Date: 2015/6/30
 * Time: 17:44
 */
public class XmlTest {

    public static void main(String[] args) {

        Servers servers = JAXBUtil.unmarshal(Servers.class, "redis-servers.xml");

        Map<String, Server> map = servers.getServers();
        Set<Map.Entry<String, Server>> entrySet = map.entrySet();
        for (Map.Entry<String, Server> entry : entrySet) {

            String name = entry.getKey();
            Server server = entry.getValue();
            System.out.println(server);
        }
    }
}

@@ -20,16 +20,178 @@
 utils;%0A%0A
+import net.common.utils.config.xml.client.Group;%0Aimport net.common.utils.config.xml.client.ServerElement;%0Aimport net.common.utils.config.xml.client.ServiceGroup;%0A
 import n
@@ -232,16 +232,16 @@
 Server;%0A
-
 import n
@@ -322,16 +322,39 @@
 BUtil;%0A%0A
+import java.util.List;%0A
 import j
@@ -796,25 +796,24 @@
 entrySet) %7B%0A
-%0A
             
@@ -919,16 +919,23 @@
 println(
+name + 
 server);
@@ -945,16 +945,679 @@
       %7D%0A
+%0A%0A        ServiceGroup serviceGroup = JAXBUtil.unmarshal(ServiceGroup.class, %22redis-client.xml%22);%0A%0A        Map%3CString, Group%3E groupMap = serviceGroup.getGroups();%0A%0A        Set%3CMap.Entry%3CString, Group%3E%3E groupSet = groupMap.entrySet();%0A%0A        for (Map.Entry%3CString, Group%3E entry : groupSet) %7B%0A%0A            System.out.println(entry.getKey());%0A            Group group = entry.getValue();%0A            Group.ServerList serverList = group.getServerList();%0A%0A            List%3CServerElement%3E serverElements = serverList.getServerElements();%0A%0A            for (ServerElement se : serverElements) %7B%0A                System.out.println(se.getName());%0A            %7D%0A        %7D%0A%0A
     %7D%0A%7D%0A

update xml