String tform = header.getStringValue("TFORM" + (col + 1)).trim();
String tdims = header.getStringValue("TDIM" + (col + 1), null);
if (tform == null) {
throw new FitsException("No TFORM for column:" + col);
}
if (tdims != null) {
tdims = tdims.trim();
}
char type = getTformType(tform);
if (type == 'P') {
flags[col] |= COL_VARYING;
type = getTformVarType(tform);
}
int size = getTformLength(tform);
// Get number of bytes for a bit array.
if (type == 'X') {
size = (size + 7) / 8;
flags[col] |= COL_BIT;
} else if ((flags[col] & COL_VARYING) != 0) {
size = 2;
}
int bSize = size;
int[] dims = null;
// Cannot really handle arbitrary arrays of bits.
if (tdims != null && type != 'X' && (flags[col] & COL_VARYING) == 0) {
dims = getTDims(tdims);
}
if (dims == null) {
dims = new int[]{size};
}
if (type == 'C' || type == 'M') {
flags[col] |= COL_COMPLEX;
}
Class colBase = null;
switch (type) {
case 'A' :
colBase = byte.class;
flags[col] |= COL_STRING;
bases[col] = String.class;
break;
case 'L' :
colBase = byte.class;
bases[col] = boolean.class;
flags[col] |= COL_BOOLEAN;
break;
case 'X' :
case 'B' :
colBase = byte.class;
bases[col] = byte.class;
break;
case 'I' :
colBase = short.class;
bases[col] = short.class;
bSize *= 2;
break;
case 'J' :
colBase = int.class;
bases[col] = int.class;
bSize *= 4;
break;
case 'K' :
colBase = long.class;
bases[col] = long.class;
bSize *= 8;
break;
case 'E' :
case 'C' :
colBase = float.class;
bases[col] = float.class;
bSize *= 4;
break;
case 'D' :
case 'M' :
colBase = double.class;
bases[col] = double.class;
bSize *= 8;
break;
default :
throw new FitsException("Invalid type in column:" + col);
}
if ((flags[col] & COL_VARYING) != 0) {
dims = new int[]{nRow, 2};
colBase = int.class;