Пример #1
0
 /**
  * Returns an array containing all records in the given section grouped into RRsets.
  *
  * @see RRset
  * @see Section
  */
 public RRset[] getSectionRRsets(int section) {
   if (sections[section] == null) return emptyRRsetArray;
   List sets = new LinkedList();
   Record[] recs = getSectionArray(section);
   Set hash = new HashSet();
   for (int i = 0; i < recs.length; i++) {
     Name name = recs[i].getName();
     boolean newset = true;
     if (hash.contains(name)) {
       for (int j = sets.size() - 1; j >= 0; j--) {
         RRset set = (RRset) sets.get(j);
         if (set.getType() == recs[i].getRRsetType()
             && set.getDClass() == recs[i].getDClass()
             && set.getName().equals(name)) {
           set.addRR(recs[i]);
           newset = false;
           break;
         }
       }
     }
     if (newset) {
       RRset set = new RRset(recs[i]);
       sets.add(set);
       hash.add(name);
     }
   }
   return (RRset[]) sets.toArray(new RRset[sets.size()]);
 }
Пример #2
0
 /**
  * Adds a record to the Zone
  *
  * @param r The record to be added
  * @see Record
  */
 public void addRecord(Record r) {
   Name name = r.getName();
   short type = r.getRRsetType();
   RRset rrset = (RRset) findExactSet(name, type);
   if (rrset == null) addSet(name, type, rrset = new RRset());
   rrset.addRR(r);
 }
Пример #3
0
 /**
  * Adds a Record to the Zone
  *
  * @param r The record to be added
  * @see Record
  */
 public void addRecord(Record r) {
   Name name = r.getName();
   int rtype = r.getRRsetType();
   synchronized (this) {
     RRset rrset = findRRset(name, rtype);
     if (rrset == null) {
       rrset = new RRset(r);
       addRRset(name, rrset);
     } else {
       rrset.addRR(r);
     }
   }
 }
Пример #4
0
 /**
  * Adds a record to the Cache.
  *
  * @param r The record to be added
  * @param cred The credibility of the record
  * @param o The source of the record (this could be a Message, for example)
  * @see Record
  */
 public void addRecord(Record r, byte cred, Object o) {
   Name name = r.getName();
   short type = r.getRRsetType();
   if (!Type.isRR(type)) return;
   boolean addrrset = false;
   Element element = (Element) findExactSet(name, type);
   if (element == null || cred > element.credibility) {
     RRset rrset = new RRset();
     rrset.addRR(r);
     addRRset(rrset, cred);
   } else if (cred == element.credibility) {
     if (element instanceof PositiveElement) {
       PositiveElement pe = (PositiveElement) element;
       pe.rrset.addRR(r);
     }
   }
 }
Пример #5
0
 public Object next() {
   if (sentLastSOA) return null;
   if (!sentFirstSOA) {
     sentFirstSOA = true;
     return (RRset) findExactSet(origin, Type.SOA);
   }
   if (!sentNS) {
     sentNS = true;
     return getNS();
   }
   if (!sentOrigin) {
     if (currentName == null) {
       currentName = getOrigin();
       TypeMap tm = findName(currentName);
       current = (Object[]) tm.getAll();
       count = 0;
     }
     while (count < current.length) {
       RRset rrset = (RRset) current[count];
       if (rrset.getType() != Type.SOA && rrset.getType() != Type.NS) return current[count++];
       count++;
     }
     current = null;
     sentOrigin = true;
   }
   if (current != null && count < current.length) return current[count++];
   while (znames.hasNext()) {
     Name currentName = (Name) znames.next();
     if (currentName.equals(getOrigin())) continue;
     TypeMap tm = findName(currentName);
     current = (Object[]) tm.getAll();
     count = 0;
     if (count < current.length) return current[count++];
   }
   sentLastSOA = true;
   RRset rrset = new RRset();
   rrset.addRR(getSOA());
   return rrset;
 }