public int addColumn(Object newCol,int length) throws FitsException {
  if (this.nFields > 0 && Array.getLength(newCol) != this.nRows) {
    throw new FitsException("New column has different number of rows");
  }
  if (this.nFields == 0) {
    this.nRows=Array.getLength(newCol);
  }
  Object[] newData=new Object[this.nFields + 1];
  int[] newOffsets=new int[this.nFields + 1];
  int[] newLengths=new int[this.nFields + 1];
  Class<?>[] newTypes=new Class[this.nFields + 1];
  String[] newNulls=new String[this.nFields + 1];
  System.arraycopy(this.data,0,newData,0,this.nFields);
  System.arraycopy(this.offsets,0,newOffsets,0,this.nFields);
  System.arraycopy(this.lengths,0,newLengths,0,this.nFields);
  System.arraycopy(this.types,0,newTypes,0,this.nFields);
  System.arraycopy(this.nulls,0,newNulls,0,this.nFields);
  this.data=newData;
  this.offsets=newOffsets;
  this.lengths=newLengths;
  this.types=newTypes;
  this.nulls=newNulls;
  newData[this.nFields]=newCol;
  this.offsets[this.nFields]=this.rowLen + 1;
  this.lengths[this.nFields]=length;
  this.types[this.nFields]=ArrayFuncs.getBaseClass(newCol);
  this.rowLen+=length + 1;
  if (this.isNull != null) {
    boolean[] newIsNull=new boolean[this.nRows * (this.nFields + 1)];
    int add=0;
    for (int i=0; i < this.isNull.length; i+=1) {
      if (i % this.nFields == 0) {
        add+=1;
      }
      if (this.isNull[i]) {
        newIsNull[i + add]=true;
      }
    }
    this.isNull=newIsNull;
  }
  this.nFields+=1;
  this.buffer=null;
  return this.nFields;
}

public int addColumn ( Object newCol , int length ) throws FitsException { if ( this . nFields > 0 && Array . getLength ( newCol ) != this . nRows ) { throw new FitsException ( "New column has different number of rows" ) ; } if ( this . nFields == 0 ) { this . nRows = Array . getLength ( newCol ) ; } Object [ ] newData = new Object [ this . nFields + 1 ] ; int [ ] newOffsets = new int [ this . nFields + 1 ] ; int [ ] newLengths = new int [ this . nFields + 1 ] ; Class < ? > [ ] newTypes = new Class [ this . nFields + 1 ] ; String [ ] newNulls = new String [ this . nFields + 1 ] ; System . arraycopy ( this . data , 0 , newData , 0 , this . nFields ) ; System . arraycopy ( this . offsets , 0 , newOffsets , 0 , this . nFields ) ; System . arraycopy ( this . lengths , 0 , newLengths , 0 , this . nFields ) ; System . arraycopy ( this . types , 0 , newTypes , 0 , this . nFields ) ; System . arraycopy ( this . nulls , 0 , newNulls , 0 , this . nFields ) ; this . data = newData ; this . offsets = newOffsets ; this . lengths = newLengths ; this . types = newTypes ; this . nulls = newNulls ; newData [ this . nFields ] = newCol ; this . offsets [ this . nFields ] = this . rowLen + 1 ; this . lengths [ this . nFields ] = length ; this . types [ this . nFields ] = ArrayFuncs . getBaseClass ( newCol ) ; this . rowLen += length + 1 ; if ( this . isNull != null ) { boolean [ ] newIsNull = new boolean [ this . nRows * ( this . nFields + 1 ) ] ; int add = 0 ; for ( int i = 0 ; i < this . isNull . length ; i += 1 ) { if ( i % this . nFields == 0 ) { add += 1 ; } if ( this . isNull [ i ] ) { newIsNull [ i + add ] = true ; } } this . isNull = newIsNull ; } this . nFields += 1 ; this . buffer = null ; return this . nFields ; }
this version of addcolumn allows the user to override the default length associated with each column type .
