int xRow = Array.getLength(o) / size;
if (getNCols() == 0) {
nRow = xRow;
} else if (xRow > 0) {
if (xRow != nRow) {
throw new FitsException(
"Added column does not have correct row count");
}
}
if ((flags[nCol] & COL_VARYING) == 0) {
modelRow[nCol] = ArrayFuncs.newInstance(ArrayFuncs.getBaseClass(o),
dims);
rowLen += size * ArrayFuncs.getBaseLength(o);
} else {
modelRow[nCol] = new int[2];
rowLen += 8;
}
// Only add to table if table already exists or if we
// are filling up the last element in columns.
// This way if we allocate a bunch of columns at the beginning
// we only create the column table after we have all the columns
// ready.
columns[nCol] = o;
try {
if (table != null) {
table.addColumn(o, sizes[nCol]);
} else if (nCol == columns.length - 1) {
table = new ColumnTable(columns, sizes);
}
} catch (TableException e) {
throw new FitsException("Error in ColumnTable:" + e);
}
nCol += 1;
return nCol;
}