首页 新闻 搜索 专区 学院

这个没循环的地方怎么搞?

0
悬赏园豆:30 [已解决问题] 解决于 2016-04-08 14:39
<?xml version="1.0" encoding="utf-8"?>

<Conf> 
  <global desc="预留"> 
    <processName alias="" desc="预留">GZTR</processName>  
    <ns_model desc="corba对象获取方式 ns-命名服务 ior-IOR字符串">ior</ns_model>  
    <channel_ip>10.45.7.22</channel_ip>  
    <channel_port>3001</channel_port>  
    <load_database desc="是否加载数据库 n-不加载">y</load_database>  
    <ior_server_url>http://10.45.32.30:80/NameService/Server</ior_server_url>  
    <dirverClass>com.mysql.jdbc.Driver</dirverClass>  
    <url>jdbc:mysql://10.45.7.23:3306/gztr_ema?autoReconnect=true</url>  
    <username>root</username>  
    <password>rootroot</password>  
    <maxPoolSize>15</maxPoolSize>  
    <minPoolSize>3</minPoolSize> 
  </global>  
  <channel desc="系统事件发送通道" name="SystemEventConsumer" type="supplier" trace="1" loglevel="0" status="load"> 
    <channel_name>Notifier</channel_name> 
  </channel>  
  <channel desc="ALE事件接收通道" name="ReaderToALEEventConsumer" type="consumer" trace="1" loglevel="0" status="unload"> 
    <channel_name>Notifier</channel_name>  
    <channel_filter>protocol=READER1.0</channel_filter>  
    <processModule>ALEModule</processModule> 
  </channel>  
  <module desc="ALE模块" name="ALEModule" type="" trace="1" loglevel="0" status="unload" class="com.ztesoft.ale.ALEModule"> 
    <durationValue>2000</durationValue>  
    <intervalValue>0</intervalValue>  
    <channel_name>Notifier</channel_name> 
  </module>  
  <channel desc="ETL事件接收通道" name="ALEToETLEventConsumer" type="consumer" trace="1" loglevel="0" status="unload"> 
    <channel_name>Notifier</channel_name>  
    <channel_filter>protocol=(ALE1.0|ETL_REQ1.0)</channel_filter>  
    <processModule>ETLModule</processModule> 
  </channel>  
  <module desc="ETL模块" name="ETLModule" type="" trace="1" loglevel="0" status="unload" class="com.ztesoft.etl.core.ETLModule"> 
    <channel_name>Notifier</channel_name>  
    <updateInterval>1000</updateInterval> 
  </module>  
  <channel desc="Schedule事件接收通道" name="ScheduleEventConsumer" type="consumer" trace="1" loglevel="0" status=""> 
    <channel_name>Notifier</channel_name>  
    <channel_filter>protocol=SCHEDULE_REQ1.0</channel_filter>  
    <processModule>ScheduleModule</processModule> 
  </channel>  
  <module desc="Schedule模块" name="ScheduleModule" type="" trace="1" loglevel="-1" status="" class="com.ztesoft.schedule.ScheduleModule"> 
    <channel_name>Notifier</channel_name>  
    <dbModel desc="ONCE,ALWAY">ALWAYS</dbModel>  
    <dbInterval desc="second">10</dbInterval>  
    <schInterval desc="microsecond">2</schInterval> 
  </module>  
  <channel desc="GZTR接收通道" name="MobileEventConsumer" type="consumer" trace="1" loglevel="0" status="unload"> 
    <channel_name>Notifier</channel_name>  
    <channel_filter>protocol=ETL1.0</channel_filter>  
    <processModule>GZTRModule</processModule> 
  </channel>  
  <module desc="GZTR处理模块" name="GZTRModule" type="" trace="1" loglevel="1" status="unload" class="com.ztesoft.customize.GZTRModule"> 
    <channel_name>Notifier</channel_name>  
    <updateInterval desc="检测周期/秒">10</updateInterval> 
  </module>  
  <channel desc="手持终端事件接收通道" name="MobileEventConsumer" type="consumer" trace="1" loglevel="0" status="unload"> 
    <channel_name>Notifier</channel_name>  
    <channel_filter>protocol=MOBILE_REQ1.0</channel_filter>  
    <processModule>MobileEventModule</processModule> 
  </channel>  
  <module desc="手持终端消息处理模块" name="MobileEventModule" type="" trace="1" loglevel="0" status="unload" class="com.ztesoft.mobile.MobileEventModule"> 
    <channel_name>Notifier</channel_name> 
  </module>  
  <channel desc="TMF接收通道" name="MobileEventConsumer" type="consumer" trace="1" loglevel="0" status="unload"> 
    <channel_name>Notifier</channel_name>  
    <channel_filter>protocol=(ALE1.0|ETL1.0)</channel_filter>  
    <processModule>TMFModule</processModule> 
  </channel>  
  <module desc="TMF处理模块" name="TMFModule" type="" trace="1" loglevel="5" status="unload" class="com.ztesoft.customize.TMFModule"> 
    <channel_name>Notifier</channel_name>  
    <updateInterval desc="检测周期/秒">720</updateInterval>  
    <expireTime desc="过期时长/秒">1440</expireTime> 
  </module>  
  <module1 desc="预留" name="ALE" type="" trace="1" loglevel="0" status=""> 
    <initializer dll="" class="" trace="1" loglevel="0" threads="1" queuesize="10000"/>  
    <config></config> 
  </module1> 
</Conf>

如以上代码  global  只有一个所以不需要循环,然后就傻眼了..

package per.sww.eight.mideight;

import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name="global")
public class Global {
    public Global(){
        super();
    }
    
    
    private String desc;
    private ProcessName processName;
    private Ns_model ns_model;
    private String channel_ip;
    private String channel_port;
    private Load_database load_database;
    private String ior_server_url;
    private String dirverClass;
    private String url;
    private String username;
    private String password;
    private String maxPoolSize;
    private String minPoolSize;
    
    @XmlAttribute(name="desc")
    public String getDesc() {
        return desc;
    }
    public void setDesc(String desc) {
        this.desc = desc;
    }
    @XmlElement(name="processName")
    public ProcessName getProcessName() {
        return processName;
    }
    public void setProcessName(ProcessName processName) {
        this.processName = processName;
    }
    @XmlElement(name="ns_model")
    public Ns_model getNs_model() {
        return ns_model;
    }
    public void setNs_model(Ns_model ns_model) {
        this.ns_model = ns_model;
    }
    @XmlElement(name="channel_ip")
    public String getChannel_ip() {
        return channel_ip;
    }
    public void setChannel_ip(String channel_ip) {
        this.channel_ip = channel_ip;
    }
    @XmlElement(name="channel_port")
    public String getChannel_port() {
        return channel_port;
    }
    public void setChannel_port(String channel_port) {
        this.channel_port = channel_port;
    }
    @XmlElement(name="load_database")
    public Load_database getLoad_database() {
        return load_database;
    }
    public void setLoad_database(Load_database load_database) {
        this.load_database = load_database;
    }
    @XmlElement(name="ior_server_url")
    public String getIor_server_url() {
        return ior_server_url;
    }
    public void setIor_server_url(String ior_server_url) {
        this.ior_server_url = ior_server_url;
    }
    @XmlElement(name="dirverClass")
    public String getDirverClass() {
        return dirverClass;
    }
    public void setDirverClass(String dirverClass) {
        this.dirverClass = dirverClass;
    }
    @XmlElement(name="url")
    public String getUrl() {
        return url;
    }
    public void setUrl(String url) {
        this.url = url;
    }
    @XmlElement(name="username")
    public String getUsername() {
        return username;
    }
    public void setUsername(String username) {
        this.username = username;
    }
    @XmlElement(name="password")
    public String getPassword() {
        return password;
    }
    public void setPassword(String password) {
        this.password = password;
    }
    @XmlElement(name="maxPoolSize")
    public String getMaxPoolSize() {
        return maxPoolSize;
    }
    public void setMaxPoolSize(String maxPoolSize) {
        this.maxPoolSize = maxPoolSize;
    }
    @XmlElement(name="minPoolSize")
    public String getMinPoolSize() {
        return minPoolSize;
    }
    public void setMinPoolSize(String minPoolSize) {
        this.minPoolSize = minPoolSize;
    }

    
    
}
 1 package per.sww.eight.mideight;
 2 
 3 import java.util.List;
 4 
 5 import javax.xml.bind.annotation.XmlElement;
 6 import javax.xml.bind.annotation.XmlElements;
 7 import javax.xml.bind.annotation.XmlRootElement;
 8 
 9 @XmlRootElement(name="Conf")
10 public class Conf {
11     public Conf(){
12         super();
13     }
14     
15     
16     //Channel
17     List<Channel> channelsList;
18     @XmlElements(value={@XmlElement(name="channel",type=Channel.class)})
19     public List<Channel> getChannelsList() {
20         return channelsList;
21     }
22     public void setChannelsList(List<Channel> channelsList) {
23         this.channelsList = channelsList;
24     }
25     
26     //Module
27     List<Module> modulesList;
28     @XmlElements(value={@XmlElement(name="module",type=Module.class)})
29     public List<Module> getModulesList() {
30         return modulesList;
31     }
32     public void setModulesList(List<Module> modulesList) {
33         this.modulesList = modulesList;
34     }
35     
36     List<Module1> module1sList;
37     @XmlElements(value={@XmlElement(name="module1",type=Module1.class)})
38     public List<Module1> getModule1sList() {
39         return module1sList;
40     }
41     public void setModule1sList(List<Module1> module1sList) {
42         this.module1sList = module1sList;
43     }
44     
45 }
package per.sww.eight.mideight;

import java.io.File;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement.GlobalScope;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;

public class ReadConf {
    public static void main(String[] args) {
        try{
            JAXBContext jc=JAXBContext.newInstance(Conf.class);
            Unmarshaller u=jc.createUnmarshaller();
            Conf conf=(Conf)u.unmarshal(new File("D:"+File.separator+"middleware.conf.xml"));
            System.out.println("-------------------------------------------------");
                Global g=new Global();
                System.out.println(g.getProcessName().getAlias());
                System.out.println(g.getProcessName().getDesc());
                System.out.println(g.getProcessName().getText());
                System.out.println(g.getNs_model().getDesc());
                System.out.println(g.getNs_model().getTwotest());
                System.out.println(g.getChannel_ip());
                System.out.println(g.getChannel_port());
                System.out.println(g.getLoad_database().getDesc());
                System.out.println(g.getLoad_database().getThreetext());
                System.out.println(g.getIor_server_url());
                System.out.println(g.getDirverClass());
                System.out.println(g.getUrl());
                System.out.println(g.getUsername());
                System.out.println(g.getPassword());
                System.out.println(g.getMaxPoolSize());
                System.out.println(g.getMinPoolSize());
                System.out.println("**********************************************");
                
            for(Channel channel:conf.getChannelsList()){
                System.out.println(channel.getDesc());
                System.out.println(channel.getName());
                System.out.println(channel.getType());
                System.out.println(channel.getTrace());
                System.out.println(channel.getLoglevel());
                System.out.println(channel.getStatus());
                System.out.println(channel.getChannel_name());
                if(null!=channel.getChannel_filter()){
                    System.out.println(channel.getChannel_filter());
                }
                if(null!=channel.getProcessModule()){
                    System.out.println(channel.getProcessModule());
                }
                
                System.out.println("===============================================");
            }
            for(Module module:conf.getModulesList()){
                System.out.println(module.getDesc());
                System.out.println(module.getName());
                System.out.println(module.getType());
                System.out.println(module.getTrace());
                System.out.println(module.getLoglevel());
                System.out.println(module.getStatus());
                System.out.println(module.getClazz());
                System.out.println(module.getDurationValue());
                System.out.println(module.getChannel_name());
                if (null!=module.getUpdateInterval()) {
                    System.out.println(module.getUpdateInterval().getDesc());
                    System.out.println(module.getUpdateInterval().getFourtext());
                }
                if (null!=module.getDbModel()) {
                    System.out.println(module.getDbModel().getDesc());
                    System.out.println(module.getDbModel().getFivetext());
                }
                if (null!=module.getDbInterval()) {
                    System.out.println(module.getDbInterval().getDesc());
                    System.out.println(module.getDbInterval().getSextext());
                }
                if (null!=module.getSchInterval()) {
                    System.out.println(module.getSchInterval().getDesc());
                    System.out.println(module.getSchInterval().getSenventext());
                }
                if (null!=module.getExpireTime()) {
                    System.out.println(module.getExpireTime().getDesc());
                    System.out.println(module.getExpireTime().getEighttext());
                }
                System.out.println("|||||||||||||||||||||||||||||||||||||||||||||||||||||");
            }
            for(Module1 module1:conf.getModule1sList()){
                System.out.println(module1.getDesc());
                System.out.println(module1.getName());
                System.out.println(module1.getType());
                System.out.println(module1.getTrace());
                System.out.println(module1.getLoglevel());
                System.out.println(module1.getStatus());
                if(null!=module1.getInitializer()){
                    System.out.println(module1.getInitializer().getDll());
                    System.out.println(module1.getInitializer().getClazz());
                    System.out.println(module1.getInitializer().getTrace());
                    System.out.println(module1.getInitializer().getLoglevel());
                    System.out.println(module1.getInitializer().getThreads());
                    System.out.println(module1.getInitializer().getQueuesize());
                }
                System.out.println(module1.getConfig());
                System.out.println("-----------------------------------------------");
            }
        }catch(JAXBException e){
            e.printStackTrace();
        }
    }
}

本来是用List循环全取出来了(其他代码做好了就这第一块不让用循环懵住了),然后现在第一块不用循环怎么做?

师太来老道这坐坐的主页 师太来老道这坐坐 | 初学一级 | 园豆:34
提问于:2016-04-08 13:52
< >
分享
最佳答案
1

什么意思。。。

你的global没用循环取呀

收获园豆:30
小光 | 小虾三级 |园豆:1880 | 2016-04-08 14:07
package per.sww.eight.mideight;

import java.util.List;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElements;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name="Conf")
public class Conf {
    public Conf(){
        super();
    }
    //Global
    List<Global> globalsList;
    @XmlElements(value={@XmlElement(name="global",type=Global.class)})
    public List<Global> getGlobalsList() {
        return globalsList;
    }
    public void setGlobalsList(List<Global> globalsList) {
        this.globalsList = globalsList;
    }
    
    //Channel
    List<Channel> channelsList;
    @XmlElements(value={@XmlElement(name="channel",type=Channel.class)})
    public List<Channel> getChannelsList() {
        return channelsList;
    }
    public void setChannelsList(List<Channel> channelsList) {
        this.channelsList = channelsList;
    }
    
    //Module
    List<Module> modulesList;
    @XmlElements(value={@XmlElement(name="module",type=Module.class)})
    public List<Module> getModulesList() {
        return modulesList;
    }
    public void setModulesList(List<Module> modulesList) {
        this.modulesList = modulesList;
    }
    
    List<Module1> module1sList;
    @XmlElements(value={@XmlElement(name="module1",type=Module1.class)})
    public List<Module1> getModule1sList() {
        return module1sList;
    }
    public void setModule1sList(List<Module1> module1sList) {
        this.module1sList = module1sList;
    }
    
}
package per.sww.eight.mideight;

import java.io.File;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;

public class ReadConf {
    public static void main(String[] args) {
        try{
            JAXBContext jc=JAXBContext.newInstance(Conf.class);
            Unmarshaller u=jc.createUnmarshaller();
            Conf conf=(Conf)u.unmarshal(new File("D:"+File.separator+"middleware.conf.xml"));
            System.out.println("-------------------------------------------------");
            for(Global global:conf.getGlobalsList()){
                System.out.println(global.getProcessName().getAlias());
                System.out.println(global.getProcessName().getDesc());
                System.out.println(global.getProcessName().getText());
                System.out.println(global.getNs_model().getDesc());
                System.out.println(global.getNs_model().getTwotest());
                System.out.println(global.getChannel_ip());
                System.out.println(global.getChannel_port());
                System.out.println(global.getLoad_database().getDesc());
                System.out.println(global.getLoad_database().getThreetext());
                System.out.println(global.getIor_server_url());
                System.out.println(global.getDirverClass());
                System.out.println(global.getUrl());
                System.out.println(global.getUsername());
                System.out.println(global.getPassword());
                System.out.println(global.getMaxPoolSize());
                System.out.println(global.getMinPoolSize());
                System.out.println("**********************************************");
            }
                
            for(Channel channel:conf.getChannelsList()){
                System.out.println(channel.getDesc());
                System.out.println(channel.getName());
                System.out.println(channel.getType());
                System.out.println(channel.getTrace());
                System.out.println(channel.getLoglevel());
                System.out.println(channel.getStatus());
                System.out.println(channel.getChannel_name());
                if(null!=channel.getChannel_filter()){
                    System.out.println(channel.getChannel_filter());
                }
                if(null!=channel.getProcessModule()){
                    System.out.println(channel.getProcessModule());
                }
                
                System.out.println("===============================================");
            }
            for(Module module:conf.getModulesList()){
                System.out.println(module.getDesc());
                System.out.println(module.getName());
                System.out.println(module.getType());
                System.out.println(module.getTrace());
                System.out.println(module.getLoglevel());
                System.out.println(module.getStatus());
                System.out.println(module.getClazz());
                System.out.println(module.getDurationValue());
                System.out.println(module.getChannel_name());
                if (null!=module.getUpdateInterval()) {
                    System.out.println(module.getUpdateInterval().getDesc());
                    System.out.println(module.getUpdateInterval().getFourtext());
                }
                if (null!=module.getDbModel()) {
                    System.out.println(module.getDbModel().getDesc());
                    System.out.println(module.getDbModel().getFivetext());
                }
                if (null!=module.getDbInterval()) {
                    System.out.println(module.getDbInterval().getDesc());
                    System.out.println(module.getDbInterval().getSextext());
                }
                if (null!=module.getSchInterval()) {
                    System.out.println(module.getSchInterval().getDesc());
                    System.out.println(module.getSchInterval().getSenventext());
                }
                if (null!=module.getExpireTime()) {
                    System.out.println(module.getExpireTime().getDesc());
                    System.out.println(module.getExpireTime().getEighttext());
                }
                System.out.println("|||||||||||||||||||||||||||||||||||||||||||||||||||||");
            }
            for(Module1 module1:conf.getModule1sList()){
                System.out.println(module1.getDesc());
                System.out.println(module1.getName());
                System.out.println(module1.getType());
                System.out.println(module1.getTrace());
                System.out.println(module1.getLoglevel());
                System.out.println(module1.getStatus());
                if(null!=module1.getInitializer()){
                    System.out.println(module1.getInitializer().getDll());
                    System.out.println(module1.getInitializer().getClazz());
                    System.out.println(module1.getInitializer().getTrace());
                    System.out.println(module1.getInitializer().getLoglevel());
                    System.out.println(module1.getInitializer().getThreads());
                    System.out.println(module1.getInitializer().getQueuesize());
                }
                System.out.println(module1.getConfig());
                System.out.println("-----------------------------------------------");
            }
        }catch(JAXBException e){
            e.printStackTrace();
        }
    }
}

这是先前做的,现在不让用循环了

师太来老道这坐坐 | 园豆:34 (初学一级) | 2016-04-08 14:10

@略知闻风雨: 那你的global不用集合不就行啦,直接对象啊,只有一个global

小光 | 园豆:1880 (小虾三级) | 2016-04-08 14:12

@博客园乄小光: 我是渣渣,你需要讲细点= =

师太来老道这坐坐 | 园豆:34 (初学一级) | 2016-04-08 14:15

@略知闻风雨: 。。。

小光 | 园豆:1880 (小虾三级) | 2016-04-08 14:16

@博客园乄小光: 康茂白壁

师太来老道这坐坐 | 园豆:34 (初学一级) | 2016-04-08 14:16

@略知闻风雨: List<Global> globalsList; 改成 Global global

小光 | 园豆:1880 (小虾三级) | 2016-04-08 14:19

@略知闻风雨: 吧list去掉试试

小光 | 园豆:1880 (小虾三级) | 2016-04-08 14:20

@博客园乄小光: 

System.out.println(global.getProcessName().getAlias());

 

global报错

师太来老道这坐坐 | 园豆:34 (初学一级) | 2016-04-08 14:21

@略知闻风雨: 你直接把循环改成conf.getGlobalsList().get(0)吧,就一个global,这样简单

小光 | 园豆:1880 (小虾三级) | 2016-04-08 14:25

@博客园乄小光: 

 

for(Global global:conf.getGlobal().get(0)){
System.out.println(global.getProcessName().getAlias());
System.out.println(global.getProcessName().getDesc());
System.out.println(global.getProcessName().getText());
System.out.println(global.getNs_model().getDesc());
System.out.println(global.getNs_model().getTwotest());
System.out.println(global.getChannel_ip());
System.out.println(global.getChannel_port());
System.out.println(global.getLoad_database().getDesc());
System.out.println(global.getLoad_database().getThreetext());
System.out.println(global.getIor_server_url());
System.out.println(global.getDirverClass());
System.out.println(global.getUrl());
System.out.println(global.getUsername());
System.out.println(global.getPassword());
System.out.println(global.getMaxPoolSize());
System.out.println(global.getMinPoolSize());
System.out.println("**********************************************");
}

 

这个样子?这样子get(0)还是报错撒

师太来老道这坐坐 | 园豆:34 (初学一级) | 2016-04-08 14:28

@略知闻风雨: 

public class ReadConf {
    public static void main(String[] args) {
        try{
            JAXBContext jc=JAXBContext.newInstance(Conf.class);
            Unmarshaller u=jc.createUnmarshaller();
            Conf conf=(Conf)u.unmarshal(new File("D:"+File.separator+"middleware.conf.xml"));
            System.out.println("-------------------------------------------------");
//            for(Global global:conf.getGlobalsList()){
//                System.out.println(global.getProcessName().getAlias());
//                System.out.println(global.getProcessName().getDesc());
//                System.out.println(global.getProcessName().getText());
//                System.out.println(global.getNs_model().getDesc());
//                System.out.println(global.getNs_model().getTwotest());
//                System.out.println(global.getChannel_ip());
//                System.out.println(global.getChannel_port());
//                System.out.println(global.getLoad_database().getDesc());
//                System.out.println(global.getLoad_database().getThreetext());
//                System.out.println(global.getIor_server_url());
//                System.out.println(global.getDirverClass());
//                System.out.println(global.getUrl());
//                System.out.println(global.getUsername());
//                System.out.println(global.getPassword());
//                System.out.println(global.getMaxPoolSize());
//                System.out.println(global.getMinPoolSize());
//                System.out.println("**********************************************");
//            }
            Global g=conf.getGlobalsList().get(0);
            System.out.println(g.getProcessName().getAlias());
            System.out.println(g.getProcessName().getDesc());
            System.out.println(g.getProcessName().getText());
            System.out.println(g.getNs_model().getDesc());
            System.out.println(g.getNs_model().getTwotest());
            System.out.println(g.getChannel_ip());
            System.out.println(g.getChannel_port());
            System.out.println(g.getLoad_database().getDesc());
            System.out.println(g.getLoad_database().getThreetext());
            System.out.println(g.getIor_server_url());
            System.out.println(g.getDirverClass());
            System.out.println(g.getUrl());
            System.out.println(g.getUsername());
            System.out.println(g.getPassword());
            System.out.println(g.getMaxPoolSize());
            System.out.println(g.getMinPoolSize());
            System.out.println("**********************************************");

                
            for(Channel channel:conf.getChannelsList()){
                System.out.println(channel.getDesc());
                System.out.println(channel.getName());
                System.out.println(channel.getType());
                System.out.println(channel.getTrace());
                System.out.println(channel.getLoglevel());
                System.out.println(channel.getStatus());
                System.out.println(channel.getChannel_name());
                if(null!=channel.getChannel_filter()){
                    System.out.println(channel.getChannel_filter());
                }
                if(null!=channel.getProcessModule()){
                    System.out.println(channel.getProcessModule());
                }
                
                System.out.println("===============================================");
            }
            for(Module module:conf.getModulesList()){
                System.out.println(module.getDesc());
                System.out.println(module.getName());
                System.out.println(module.getType());
                System.out.println(module.getTrace());
                System.out.println(module.getLoglevel());
                System.out.println(module.getStatus());
                System.out.println(module.getClazz());
                System.out.println(module.getDurationValue());
                System.out.println(module.getChannel_name());
                if (null!=module.getUpdateInterval()) {
                    System.out.println(module.getUpdateInterval().getDesc());
                    System.out.println(module.getUpdateInterval().getFourtext());
                }
                if (null!=module.getDbModel()) {
                    System.out.println(module.getDbModel().getDesc());
                    System.out.println(module.getDbModel().getFivetext());
                }
                if (null!=module.getDbInterval()) {
                    System.out.println(module.getDbInterval().getDesc());
                    System.out.println(module.getDbInterval().getSextext());
                }
                if (null!=module.getSchInterval()) {
                    System.out.println(module.getSchInterval().getDesc());
                    System.out.println(module.getSchInterval().getSenventext());
                }
                if (null!=module.getExpireTime()) {
                    System.out.println(module.getExpireTime().getDesc());
                    System.out.println(module.getExpireTime().getEighttext());
                }
                System.out.println("|||||||||||||||||||||||||||||||||||||||||||||||||||||");
            }
            for(Module1 module1:conf.getModule1sList()){
                System.out.println(module1.getDesc());
                System.out.println(module1.getName());
                System.out.println(module1.getType());
                System.out.println(module1.getTrace());
                System.out.println(module1.getLoglevel());
                System.out.println(module1.getStatus());
                if(null!=module1.getInitializer()){
                    System.out.println(module1.getInitializer().getDll());
                    System.out.println(module1.getInitializer().getClazz());
                    System.out.println(module1.getInitializer().getTrace());
                    System.out.println(module1.getInitializer().getLoglevel());
                    System.out.println(module1.getInitializer().getThreads());
                    System.out.println(module1.getInitializer().getQueuesize());
                }
                System.out.println(module1.getConfig());
                System.out.println("-----------------------------------------------");
            }
        }catch(JAXBException e){
            e.printStackTrace();
        }
    }

这样,直接获取global数组第一个输出,反正就一个global,其他的跟你以前用循环写好的一样

小光 | 园豆:1880 (小虾三级) | 2016-04-08 14:29
package per.sww.eight.mideight;

import java.util.List;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElements;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name="Conf")
public class Conf {
    public Conf(){
        super();
    }
    //Global
    Global global;
    @XmlElements(value={@XmlElement(name="global",type=Global.class)})
    public Global getGlobal() {
        return global;
    }
    public void setGlobal(Global global) {
        this.global = global;
    }
    
    
    
    //Channel
    List<Channel> channelsList;
    @XmlElements(value={@XmlElement(name="channel",type=Channel.class)})
    public List<Channel> getChannelsList() {
        return channelsList;
    }
    public void setChannelsList(List<Channel> channelsList) {
        this.channelsList = channelsList;
    }
    
    //Module
    List<Module> modulesList;
    @XmlElements(value={@XmlElement(name="module",type=Module.class)})
    public List<Module> getModulesList() {
        return modulesList;
    }
    public void setModulesList(List<Module> modulesList) {
        this.modulesList = modulesList;
    }
    
    List<Module1> module1sList;
    @XmlElements(value={@XmlElement(name="module1",type=Module1.class)})
    public List<Module1> getModule1sList() {
        return module1sList;
    }
    public void setModule1sList(List<Module1> module1sList) {
        this.module1sList = module1sList;
    }
    
}

那这一块写不

师太来老道这坐坐 | 园豆:34 (初学一级) | 2016-04-08 14:31
package per.sww.eight.mideight;

import java.util.List;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElements;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name="Conf")
public class Conf {
    public Conf(){
        super();
    }
    //Global
    List<Global> globalsList;
    @XmlElements(value={@XmlElement(name="global",type=Global.class)})
    public List<Global> getGlobalsList() {
        return globalsList;
    }
    public void setGlobalsList(List<Global> globalsList) {
        this.globalsList = globalsList;
    }
    
    //Channel
    List<Channel> channelsList;
    @XmlElements(value={@XmlElement(name="channel",type=Channel.class)})
    public List<Channel> getChannelsList() {
        return channelsList;
    }
    public void setChannelsList(List<Channel> channelsList) {
        this.channelsList = channelsList;
    }
    
    //Module
    List<Module> modulesList;
    @XmlElements(value={@XmlElement(name="module",type=Module.class)})
    public List<Module> getModulesList() {
        return modulesList;
    }
    public void setModulesList(List<Module> modulesList) {
        this.modulesList = modulesList;
    }
    
    List<Module1> module1sList;
    @XmlElements(value={@XmlElement(name="module1",type=Module1.class)})
    public List<Module1> getModule1sList() {
        return module1sList;
    }
    public void setModule1sList(List<Module1> module1sList) {
        this.module1sList = module1sList;
    }
    
}

 

@略知闻风雨: 这个你别改呀,就用你以前用循环写好的

小光 | 园豆:1880 (小虾三级) | 2016-04-08 14:33

@博客园乄小光: 6666做好了,话说我的ecl现在用alt+tab切不到别的软件上是啥问题

师太来老道这坐坐 | 园豆:34 (初学一级) | 2016-04-08 14:36

@略知闻风雨: 。。。没遇见过

小光 | 园豆:1880 (小虾三级) | 2016-04-08 14:38
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册