Ejemplo n.º 1
0
  /** Returns the next record in the master file */
  public Record nextRecord() throws IOException {
    String line;
    MyStringTokenizer st;

    if (included != null) {
      Record rec = included.nextRecord();
      if (rec != null) return rec;
      included = null;
    }
    while (true) {
      line = readExtendedLine(br);
      if (line == null) return null;
      if (line.length() == 0 || line.startsWith(";")) continue;

      boolean space = line.startsWith(" ") || line.startsWith("\t");
      st = new MyStringTokenizer(line);

      String s = st.nextToken();
      if (s.equals("$ORIGIN")) {
        origin = parseOrigin(st);
        continue;
      }
      if (s.equals("$TTL")) {
        defaultTTL = parseTTL(st);
        continue;
      }
      if (s.equals("$INCLUDE")) {
        parseInclude(st);
        /*
         * If we continued, we wouldn't be looking in
         * the new file.  Recursing works better.
         */
        return nextRecord();
      } else if (s.charAt(0) == '$') throw new IOException("Invalid directive: " + s);
      st.putBackToken(s);
      return (last = parseRR(st, space, last, origin));
    }
  }