如何将我的列表添加到班级?

时间:2016-08-18 23:22:53

标签: java arraylist

我有以下课程,但我无法填写我的列表。我没有得到任何错误甚至空指针异常。它只是贯穿并提供我的所有数据,除了我的列表。有人能帮助我理解我做错了吗?

import java.util.List;

public class SSRSReports {

  public static class Report {

    private String reportName;
    private String lastRunTime;
    private String lastStatus;
    private String deliveryExt;
    private String path;
    private String subscriptionId;
    private String jobId;
    private List < ReportSchedule > schedule;

    public Report(String reportName, String lastRunTime, String lastStatus, String deliveryExt, String path, String subscriptionId, String jobId, List < ReportSchedule > schedule) {
      this.setReportName(reportName);
      this.setLastRunTime(lastRunTime);
      this.setLastStatus(lastStatus);
      this.setDeliveryExt(deliveryExt);
      this.setPath(path);
      this.setSubscriptionId(subscriptionId);
      this.setJobId(jobId);
      this.setSchedule(schedule);
    }

    //Getters and Setters
    public List < ReportSchedule > getSchedule() {
      return schedule;
    }

    public void setSchedule(List < ReportSchedule > schedule) {
        this.schedule = schedule;
      }
      //The rest of Getters and Setters

  }

  public static class ReportSchedule {

    private String location;
    private String status;
    private String path;
    private String fileName;
    private String format;
    private String writeMode;
    private String site;

    public ReportSchedule(String location, String status, String path, String fileName, String format, String writeMode, String site) {

      this.setLocation(location);
      this.setStatus(status);
      this.setPath(path);
      this.setFileName(fileName);
      this.setFormat(format);
      this.setWriteMode(writeMode);
      this.setSite(site);
    }

    //Getters and Setters

  }



}

以下是我用来填充它们的对象和方法。

List < Report > scheduledReports = new ArrayList < Report > ();
List < ReportSchedule > reportSchedule = new ArrayList < ReportSchedule > ();

//Do stuff to get data

reportSchedule.add(new ReportSchedule(location, status, subPath, fileName, format, writeMode, site));

scheduledReports.add(new Report(reportName, lastRunTime, lastStatus, deliveryExt, path, subscriptionId, jobId, reportSchedule));

谢谢!

1 个答案:

答案 0 :(得分:0)

我能够得到它。我忘了我有另一个被引用的结果集阻止了数据进入列表但是,我还需要做Msumera建议的。我需要设置对象。

&#13;
&#13;
Report sch = new Report(jobId, jobId, jobId, jobId, jobId, jobId, jobId, reportSchedule);

scheduledReports.add(new Report(reportName, lastRunTime, lastStatus, deliveryExt, path, subscriptionId, jobId, sch.setSchedule(reportSchedule)));
&#13;
&#13;
&#13;