示例#1
0
文件: Frame.java 项目: vmlaker/h2o
 public StringBuilder toString(StringBuilder sb, String[] fs, long idx) {
   Vec vecs[] = vecs();
   for (int c = 0; c < fs.length; c++) {
     Vec vec = vecs[c];
     if (vec.isEnum()) {
       String s = "----------";
       if (!vec.isNA(idx)) {
         int x = (int) vec.at8(idx);
         if (x >= 0 && x < vec._domain.length) s = vec._domain[x];
       }
       sb.append(String.format(fs[c], s));
     } else if (vec.isInt()) {
       if (vec.isNA(idx)) {
         Chunk C = vec.elem2BV(0); // 1st Chunk
         int len = C.pformat_len0(); // Printable width
         for (int i = 0; i < len; i++) sb.append('-');
       } else {
         try {
           sb.append(String.format(fs[c], vec.at8(idx)));
         } catch (IllegalFormatException ife) {
           System.out.println("Format: " + fs[c] + " col=" + c + " not for ints");
           ife.printStackTrace();
         }
       }
     } else {
       sb.append(String.format(fs[c], vec.at(idx)));
       if (vec.isNA(idx)) sb.append(' ');
     }
     sb.append(' '); // Column seperator
   }
   sb.append('\n');
   return sb;
 }