私は面倒な大きなプログラムのコードを修正しようとしています(作成しませんでした)、有名人のIndexOutOfBoundsException
を取得し続けています。オブジェクト[]宣言のIndexOutOfBoundsException
私は既に答えを広範囲に検索しているので、エラーの意味を知っていることを言いたいと思いますが、私は単に理解できません。なぜ私はそれを得ています。 ..ここ
エラーである:ここ
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.rangeCheck(ArrayList.java:635)
at java.util.ArrayList.get(ArrayList.java:411)
at edu.harvard.i2b2.crc.loader.dao.ObservationFactDAO$ObservationFactInsert.insert(ObservationFactDAO.java:359)
at edu.harvard.i2b2.crc.loader.dao.ObservationFactInsertHandle.insertObservationFact(ObservationFactInsertHandle.java:25)
at edu.harvard.i2b2.crc.loader.ejb.ObservationFactXmlDbLoader.process(ObservationFactXmlDbLoader.java:84)
at edu.harvard.i2b2.crc.loader.xml.TypePullParser.doParsing(TypePullParser.java:73)...
は、問題の原因ObservationFactDAO.javaの一部である(エラーによって参照される):
protected void insert(ObservationType observationType) {
Object[] objs = new Object[] {
observationType.getEventId().getValue(),
observationType.getEventId().getSource(),
observationType.getConceptCd().getValue(),
(observationType.getPatientId() != null) ? observationType
.getPatientId().getValue() : null,
(observationType.getPatientId() != null) ? observationType
.getPatientId().getSource() : null,
(observationType.getObserverCd() != null) ? observationType
.getObserverCd().getValue() : null,
(observationType.getStartDate() != null) ? observationType
.getStartDate().toGregorianCalendar().getTime()
: null,
(observationType.getModifierCd() != null) ? observationType
.getModifierCd().getValue() : null,
(observationType.getInstanceNum() != null) ? observationType
.getInstanceNum().getValue()
: null,
observationType.getValuetypeCd(),
observationType.getTvalChar(),
(observationType.getNvalNum() != null) ? observationType
.getNvalNum().getValue() : null,
(observationType.getValueflagCd() != null) ? observationType
.getValueflagCd().getValue()
: null,
(observationType.getQuantityNum() != null) ? observationType
.getQuantityNum()
: null,
null,
(observationType.getObservationBlob() != null) ? observationType
.getObservationBlob().getContent().get(0)
.toString()
: null,
observationType.getUnitsCd(),
(observationType.getEndDate() != null) ? observationType
.getEndDate().toGregorianCalendar().getTime()
: null,
(observationType.getLocationCd() != null) ? observationType
.getLocationCd().getValue() : null,
(observationType.getUpdateDate() != null) ? observationType
.getUpdateDate().toGregorianCalendar().getTime()
: null,
(observationType.getDownloadDate() != null) ? observationType
.getDownloadDate().toGregorianCalendar().getTime()
: null,
(observationType.getImportDate() != null) ? observationType
.getImportDate().toGregorianCalendar().getTime()
: null,
observationType.getSourcesystemCd(),
observationType.getUploadId() };
update(objs);
}
具体的には、最初の行Object[] objs = new Object[]
が参照されます。
ご覧のとおり、リストはここで定義されているので、ここで例外が送信される理由はわかりません。
オブジェクト宣言で呼び出されるメソッドは、有効で単純な 'return'ステートメントです。さらに、私は同じ結果を実際の値に置き換えようとしました。
私はまだ研究中ですが、この例外に関する既存の記事のほとんどは、既存の空のリストに値を追加し、その初期化を行わないことを懸念しています。
私は、ひどい探しの配列初心者を書き換えて、少なくとも読むことができるようにしたいと思っています。 –
配列リストがエラーをスローしています。 Object []とは何の関係もありません。 – matt