Beispiel #1
0
 private static long attemptTimeParse_1( ValueString str ) {
   final byte[] buf = str.get_buf();
   int i=str.get_off();
   final int end = i+str.get_length();
   while( i < end && buf[i] == ' ' ) i++;
   if   ( i < end && buf[i] == '"' ) i++;
   if( (end-i) < 8 ) return Long.MIN_VALUE;
   int yy=0, MM=0, dd=0;
   dd = digit(dd,buf[i++]);
   if( buf[i] != '-' ) dd = digit(dd,buf[i++]);
   if( dd < 1 || dd > 31 ) return Long.MIN_VALUE;
   if( buf[i++] != '-' ) return Long.MIN_VALUE;
   byte[]mm=null;
   OUTER: for( ; MM<MMS.length; MM++ ) {
     byte[][] mms = MMS[MM];
     INNER: for( int k=0; k<mms.length; k++ ) {
       mm = mms[k];
       if( mm == null ) continue;
       for( int j=0; j<mm.length; j++ )
         if( mm[j] != Character.toLowerCase(buf[i+j]) )
           continue INNER;
       break OUTER;
     }
   }
   if( MM == MMS.length ) return Long.MIN_VALUE; // No matching month
   i += mm.length;             // Skip month bytes
   MM++;                       // 1-based month
   if( buf[i++] != '-' ) return Long.MIN_VALUE;
   yy = digit(yy,buf[i++]);
   yy = digit(yy,buf[i++]);
   yy += 2000;                 // Y2K bug
   if( i<end && buf[i] == '"' ) i++;
   if( i<end ) return Long.MIN_VALUE;
   return new GregorianCalendar(yy,MM,dd).getTimeInMillis();
 }
Beispiel #2
0
 // Print fixed-width row & fixed-width headers (more compressed print
 // format).  Returns the column formats.
 public String[] toStringHdr(StringBuilder sb) {
   String[] fs = new String[numCols()];
   for (int c = 0; c < fs.length; c++) {
     String n = (c < _names.length) ? _names[c] : ("C" + c);
     if (numRows() == 0) {
       sb.append(n).append(' ');
       continue;
     }
     int w = 0;
     if (_vecs[c].isEnum()) {
       String ss[] = _vecs[c]._domain;
       for (int i = 0; i < ss.length; i++) w = Math.max(w, ss[i].length());
       w = Math.min(w, 10);
       fs[c] = "%" + w + "." + w + "s";
     } else {
       Chunk C = _vecs[c].elem2BV(0); // 1st Chunk
       String f = fs[c] = C.pformat(); // Printable width
       for (int x = 0; x < f.length(); x++) // Get printable width from format
       if (Character.isDigit(f.charAt(x))) w = w * 10 + (f.charAt(x) - '0');
         else if (w > 0) break;
       if (f.charAt(1) == ' ') w++; // Leading blank is not in print-width
     }
     int len = sb.length();
     if (n.length() <= w) { // Short name, big digits
       sb.append(n);
       for (int i = n.length(); i < w; i++) sb.append(' ');
     } else if (w == 1) { // First char only
       sb.append(n.charAt(0));
     } else if (w == 2) { // First 2 chars only
       sb.append(n.charAt(0)).append(n.charAt(1));
     } else { // First char dot lastchars; e.g. Compress "Interval" to "I.val"
       sb.append(n.charAt(0)).append('.');
       for (int i = n.length() - (w - 2); i < n.length(); i++) sb.append(n.charAt(i));
     }
     assert len + w == sb.length();
     sb.append(' '); // Column seperator
   }
   sb.append('\n');
   return fs;
 }