IndexOutOfBoundsException in Object[] declaration
<p>I'm trying to fix the code of an annoyingly large program (I didn't create it) and I keep getting the famous <code>IndexOutOfBoundsException</code>.</p>

<p>I'd like to mention that I know what the error means, as I've already searched far and wide for an answer but I simply don't understand <strong>why</strong> I'm getting it, so here goes...</p>

<p>Here is the Error:</p>

<pre><code>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)...
</code></pre>

<p>Here is the part of ObservationFactDAO.java causing the problem (as referenced by the error):</p>

<pre><code>    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);
    }
</code></pre>

<p>More specifically, the first line <code>Object[] objs = new Object[]</code> is referenced.</p>

<p>As you can see, the list is being defined here so I don't understand why the exception is sent here.</p>

<p>The methods called in the Object declaration are valid and simple 'return' statements. Furthermore, I've tried replacing them with actual values with the same results.</p>

<p>I'm still researching on my end but most of the existing posts about this exception concern adding values to an existing empty list and not its initialization.</p>