示例#1
0
        protected static Header ManufactureHeader(Array[] row, String[] columnNames,
            Object[] tnull, int nRows)
        {
            Header hdr = new Header();
              Object[][] table = new Object[1][];
              table[0] = row;
              new BinaryTable(table).FillHeader(hdr);

              if(columnNames == null)
              {
            columnNames = new String[row.Length];
            for(int i = 0; i < columnNames.Length; ++i)
            {
              columnNames[i] = "Column" + (i + 1);
            }
              }

              for(HeaderCard c = hdr.NextCard(); c != null; c = hdr.NextCard());

              Type t = null;
              for(int i = 0; i < columnNames.Length; ++i)
              {
            if(!hdr.ContainsKey("TTYPE" + (i + 1)))
            {
              hdr.AddLine(new HeaderCard("TTYPE" + (i + 1), columnNames[i], null));
            }

            t = row[i].GetType();
            if(t == typeof(short[]))
            {
              hdr.AddLine(new HeaderCard("TNULL" + (i + 1), (short)tnull[i], null));
            }
            else if(t == typeof(int[]))
            {
              hdr.AddLine(new HeaderCard("TNULL" + (i + 1), (int)tnull[i], null));
            }
            else if(t == typeof(long[]))
            {
              hdr.AddLine(new HeaderCard("TNULL" + (i + 1), (long)tnull[i], null));
            }
              }

              hdr.RemoveCard("NAXIS2");
              hdr.SetNaxis(2, nRows);

              return hdr;
        }