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"); }
public void throwError(String error) throws IOException { throw new IOException(error + " at file pointer " + file.getFilePointer()); }
public int getFilePointer() throws IOException { return file.getFilePointer(); }