Changes between Version 1 and Version 2 of demo_08


Ignore:
Timestamp:
05/30/2012 09:58:10 AM (14 years ago)
Author:
qinhongyuan
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • demo_08

    v1 v2  
    1313    static UserGroup[] userGroups; 
    1414 
    15         /** 
    16         * 初始化数组 
    17         * @throws DocumentException 
    18         */ 
     15    /** 
     16    * 初始化数组 
     17    * @throws DocumentException 
     18    */ 
    1919    @BeforeClass 
    2020    public static void setUp() throws DocumentException { 
     
    2727                userRightService.userGroups = userGroups; 
    2828    } 
    29         public static UserGroup[] initUserGroups(String sourceFilePath, String sourceFileItemPath) throws DocumentException { 
     29    public static UserGroup[] initUserGroups(String sourceFilePath, String sourceFileItemPath) throws DocumentException { 
    3030 
    31                 XMLParser items = new XMLParser(sourceFileItemPath); 
    32                 Iterator iterItems = items.getIterator("row"); 
    33                 Map<Long, Map<String, Long>> itemMap = new HashMap<Long, Map<String, Long>>(); 
    34                 Element ele = null; 
     31        XMLParser items = new XMLParser(sourceFileItemPath); 
     32        Iterator iterItems = items.getIterator("row"); 
     33        Map<Long, Map<String, Long>> itemMap = new HashMap<Long, Map<String, Long>>(); 
     34        Element ele = null; 
    3535 
    36                 while (iterItems.hasNext()) { 
    37                         ele = (Element)iterItems.next(); 
    38                         long groupId = NumberUtils.toLong(ele.elementText("usergroupid")); 
    39                         if (itemMap.containsKey(groupId)) { 
    40                                 itemMap.get(groupId).put(ele.elementText("name"), NumberUtils.toLong(ele.elementText("value"))); 
    41                         } else { 
    42                                 Map<String, Long> tempMap = new HashMap<String, Long>(); 
    43                                 tempMap.put(ele.elementText("name"), NumberUtils.toLong(ele.elementText("value"))); 
    44                                 itemMap.put(groupId, tempMap); 
    45                         } 
     36        while (iterItems.hasNext()) { 
     37                ele = (Element)iterItems.next(); 
     38                long groupId = NumberUtils.toLong(ele.elementText("usergroupid")); 
     39                if (itemMap.containsKey(groupId)) { 
     40                        itemMap.get(groupId).put(ele.elementText("name"), NumberUtils.toLong(ele.elementText("value"))); 
     41                } else { 
     42                        Map<String, Long> tempMap = new HashMap<String, Long>(); 
     43                        tempMap.put(ele.elementText("name"), NumberUtils.toLong(ele.elementText("value"))); 
     44                        itemMap.put(groupId, tempMap); 
    4645                } 
     46        } 
    4747 
    48                 XMLParser iData = new XMLParser(sourceFilePath); 
    49                 Iterator iter = iData.getIterator("row"); 
    50                 List<UserGroup> userGroupsList = new ArrayList<UserGroup>(iData.getLength()); 
     48        XMLParser iData = new XMLParser(sourceFilePath); 
     49        Iterator iter = iData.getIterator("row"); 
     50        List<UserGroup> userGroupsList = new ArrayList<UserGroup>(iData.getLength()); 
    5151                 
    52                 while (iter.hasNext()) { 
    53                         UserGroup ug = new UserGroup(); 
    54                         ele = (Element)iter.next(); 
    55                         long groupId = NumberUtils.toLong(ele.elementText("usergroupid")); 
    56                         ug.setUserGroupId(groupId); 
    57                         ug.setType(NumberUtils.toInt(ele.elementText("type"))); 
    58                         ug.setName(ele.elementText("name")); 
    59                         ug.setLimitMin(NumberUtils.toInt(ele.elementText("limitmin"))); 
    60                         ug.setItems(itemMap.get(groupId)); 
    61                         userGroupsList.add(ug); 
    62                 } 
     52        while (iter.hasNext()) { 
     53                UserGroup ug = new UserGroup(); 
     54                ele = (Element)iter.next(); 
     55                long groupId = NumberUtils.toLong(ele.elementText("usergroupid")); 
     56                ug.setUserGroupId(groupId); 
     57                ug.setType(NumberUtils.toInt(ele.elementText("type"))); 
     58                ug.setName(ele.elementText("name")); 
     59                ug.setLimitMin(NumberUtils.toInt(ele.elementText("limitmin"))); 
     60                ug.setItems(itemMap.get(groupId)); 
     61                userGroupsList.add(ug); 
     62        } 
    6363 
    64                 return userGroupsList.toArray(new UserGroup[0]); 
    65         } 
     64        return userGroupsList.toArray(new UserGroup[0]); 
     65    } 
    6666 
    6767