Exemplo n.º 1
0
  @Override
  public RRset next() {
    if (!this.hasNext()) {
      throw new NoSuchElementException();
    }
    if (current == null) {
      wantLastSoa = false;
      return originNode.getRRset(Type.SOA);
    }
    RRset set = current[count++];
    if (count == current.length) {
      current = null;
      while (domainIter.hasNext()) {

        String domainString = domainIter.next();
        if (domainString.equalsIgnoreCase(zone.getRootDomain())) {
          continue;
        }

        DomainResource dr = getDomainResource(domainString);
        if (dr == null) {
          continue;
        }
        List<RRset> sets = dr.getAllRRsets();
        if (sets == null || sets.size() == 0) {
          continue;
        }
        current = sets.toArray(new RRset[0]);
        count = 0;
        break;
      }
    }
    return set;
  }
Exemplo n.º 2
0
  RRsetIterator(Zone zone, DomainFactory factory) {

    this.zone = zone;
    this.factory = factory;
    this.domainIter = zone.iterator();
    if (domainIter == null) {
      throw new RuntimeException("Null Domain iterator");
    }

    String rootString = zone.getRootDomain();
    this.originNode = getDomainResource(rootString);

    if (originNode.getRRset(Type.SOA) == null) {
      throw new RuntimeException("Zone " + rootString + " missing SOA record");
    }
    if (originNode.getRRset(Type.NS) == null) {
      throw new RuntimeException("Zone " + rootString + " missing NS rrset");
    }

    List<RRset> sets = originNode.getAllRRsets();
    this.current = new RRset[sets.size()];
    for (int j = 2, k = 0; k < sets.size(); k++) {
      RRset rrset = sets.get(k);
      int type = rrset.getType();

      if (type == Type.SOA) {
        current[0] = rrset;
      } else if (type == Type.NS) {
        current[1] = rrset;
      } else {
        current[j++] = rrset;
      }
    }
  }