Exemple #1
0
 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;
 }
Exemple #2
0
 public static void assertValues(Vec v, String[] expValues) {
   Assert.assertEquals("Number of rows", expValues.length, v.length());
   BufferedString tmpStr = new BufferedString();
   for (int i = 0; i < v.length(); i++) {
     if (v.isNA(i)) Assert.assertEquals("NAs should match", null, expValues[i]);
     else Assert.assertEquals("Values should match", expValues[i], v.atStr(tmpStr, i).toString());
   }
 }
Exemple #3
0
 public static String[] collectS(Vec v) {
   String[] res = new String[(int) v.length()];
   BufferedString tmpStr = new BufferedString();
   for (int i = 0; i < v.length(); i++) res[i] = v.isNA(i) ? null : v.atStr(tmpStr, i).toString();
   return res;
 }