Example #1
0
 public void nextValidToken() throws IOException {
   int level = 0;
   String n1 = null;
   String n2 = null;
   int ptr = 0;
   while (nextToken()) {
     if (type == TK_COMMENT) continue;
     switch (level) {
       case 0:
         {
           if (type != TK_NUMBER) return;
           ptr = file.getFilePointer();
           n1 = stringValue;
           ++level;
           break;
         }
       case 1:
         {
           if (type != TK_NUMBER) {
             file.seek(ptr);
             type = TK_NUMBER;
             stringValue = n1;
             return;
           }
           n2 = stringValue;
           ++level;
           break;
         }
       default:
         {
           if (type != TK_OTHER || !stringValue.equals("R")) {
             file.seek(ptr);
             type = TK_NUMBER;
             stringValue = n1;
             return;
           }
           type = TK_REF;
           reference = Integer.parseInt(n1);
           generation = Integer.parseInt(n2);
           return;
         }
     }
   }
   // if we hit here, the file is either corrupt (stream ended unexpectedly),
   // or the last token ended exactly at the end of a stream.  This last
   // case can occur inside an Object Stream.
 }
Example #2
0
 public void nextValidToken() throws IOException {
   int level = 0;
   String n1 = null;
   String n2 = null;
   int ptr = 0;
   while (nextToken()) {
     if (type == TK_COMMENT) continue;
     switch (level) {
       case 0:
         {
           if (type != TK_NUMBER) return;
           ptr = file.getFilePointer();
           n1 = stringValue;
           ++level;
           break;
         }
       case 1:
         {
           if (type != TK_NUMBER) {
             file.seek(ptr);
             type = TK_NUMBER;
             stringValue = n1;
             return;
           }
           n2 = stringValue;
           ++level;
           break;
         }
       default:
         {
           if (type != TK_OTHER || !stringValue.equals("R")) {
             file.seek(ptr);
             type = TK_NUMBER;
             stringValue = n1;
             return;
           }
           type = TK_REF;
           reference = Integer.valueOf(n1).intValue();
           generation = Integer.valueOf(n2).intValue();
           return;
         }
     }
   }
   throwError("Unexpected end of file");
 }
Example #3
0
 public void throwError(String error) throws IOException {
   throw new IOException(error + " at file pointer " + file.getFilePointer());
 }
Example #4
0
 public int getFilePointer() throws IOException {
   return file.getFilePointer();
 }