Пример #1
0
  private Record parseRR(MyStringTokenizer st, boolean useLast, Record last, Name origin)
      throws IOException {
    Name name;
    int ttl;
    short type, dclass;

    if (!useLast) name = new Name(st.nextToken(), origin);
    else name = last.getName();

    String s = st.nextToken();

    try {
      ttl = TTL.parseTTL(s);
      s = st.nextToken();
    } catch (NumberFormatException e) {
      if (!useLast || last == null) ttl = defaultTTL;
      else ttl = last.getTTL();
    }

    if ((dclass = DClass.value(s)) > 0) s = st.nextToken();
    else dclass = DClass.IN;

    if ((type = Type.value(s)) < 0) throw new IOException("Parse error");

    return Record.fromString(name, type, dclass, ttl, st, origin);
  }
Пример #2
0
 /**
  * Constructs and returns the next record in the expansion.
  *
  * @throws IOException The name or rdata was invalid after substitutions were performed.
  */
 public Record nextRecord() throws IOException {
   if (current > end) return null;
   String namestr = substitute(namePattern, current);
   Name name = Name.fromString(namestr, origin);
   String rdata = substitute(rdataPattern, current);
   current += step;
   return Record.fromString(name, type, dclass, ttl, rdata, origin);
 }
Пример #3
0
 /**
  * Constructs and returns all records in the expansion.
  *
  * @throws IOException The name or rdata of a record was invalid after substitutions were
  *     performed.
  */
 public Record[] expand() throws IOException {
   List list = new ArrayList();
   for (long i = start; i < end; i += step) {
     String namestr = substitute(namePattern, current);
     Name name = Name.fromString(namestr, origin);
     String rdata = substitute(rdataPattern, current);
     list.add(Record.fromString(name, type, dclass, ttl, rdata, origin));
   }
   return (Record[]) list.toArray(new Record[list.size()]);
 }