2016-08-18 65 views
0

私は次のクラスを持っていますが、私のリストにデータを入れることができません。私はエラーやnullポインタ例外を取得していません。それは私のリストを除いて私のすべてのデータを通過し、私にすべてのデータを与えます。誰かが私が間違ったことを理解するのを助けることができますか?ここでリストをクラスに追加するにはどうすればよいですか?

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));

ありがとう!

+0

?そして、あなたはその欠席をどのように確認していますか? – Marvin

+1

私はあなたがあなたのリストに移入した後、スケジュール変数、 を設定するのを忘れたと思う: 'スケジュール= scheduleReportsを;' またはそのこのクラス外の場合: 'setSchedule(scheduledReports)無関係' – msumera

+0

が、物事のリストには、名前を付ける必要があります単数ではなく複数である。 (私が個人的に気にしないsingularThingListと呼ぶのでない限り) –

答えて

0

私はそれを手に入れました。データがリストに入ることを妨げていた別の結果セットが参照されていたことを忘れていますが、Msumeraが提案したことを行う必要もありました。私はオブジェクトを設定する必要がありました。あなたが実際にあなたのリストを移入しようとしている

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)));

関連する問題