把一个对象的list改造成castor可以识别的对象

public ResInfoLevelStruct demo2()
    {
       
      
        returnObj = new ResInfoLevelStruct();
        ResInfoLevelStruct root = new ResInfoLevelStruct();
        root.setIResourceId(0);
       
       
        List<ResInfoLevelStruct> tmp = null;
        try
        {
           
            StringBuilder resultxml = new StringBuilder("D:\\ecu\\security\\src\\");
            resultxml.append("com\\ecm\\demo\\security\\test-result.xml");
           
            tmp = securityWebServer.getAllWebSvrSecResByLoginUser(0, 0);
            Marshaller marshaller = new Marshaller(new FileWriter(resultxml.toString()));
            marshaller.marshal(tmp);
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
       
        return searchChildList(tmp,root);
    }
   
   
    /**
     *通过该 方法把 ResInfoLevelStruct对象封装成有层次结构的对象
     */
    public ResInfoLevelStruct searchChildList(List<ResInfoLevelStruct> reslist, ResInfoLevelStruct root)
    {
       
       
        if ((null != reslist && reslist.size()>0) && (null != root))
        {
           
            for (ResInfoLevelStruct rls : reslist)
            {
               
                //找对应的孩子结点,加工list
                if (rls.getIFresourceId() == root.getIResourceId())
                {
                   
                    root.getRlsList().add(rls);
                    searchChildList(reslist, rls);
                  
                }
            }
        }
        return root;
    }

你可能感兴趣的:(xml,Security)