/** * Add an answer to the message. */ void addAnswer(DNSRecord rec, long now) throws IOException { if (numAuthorities > 0 || numAdditionals > 0) { throw new IllegalStateException("Questions must be added before answers"); } if (rec != null) { if ((now == 0) || !rec.isExpired(now)) { writeRecord(rec, now); numAnswers++; } } }
if (c.isExpired(now))
boolean expired = rec.isExpired(now); String type = rec.getName(); String name = ((DNSRecord.Pointer) rec).getAlias();
/** * Add a listener for a question. The listener will receive updates * of answers to the question as they arrive, or from the cache if they * are already available. */ void addListener(DNSListener listener, DNSQuestion question) { long now = System.currentTimeMillis(); // add the new listener synchronized (this) { listeners.add(listener); } // report existing matched records if (question != null) { for (DNSCache.CacheNode i = cache.find(question.name); i != null; i = i.next()) { DNSRecord c = (DNSRecord) i.getValue(); if (question.answeredBy(c) && !c.isExpired(now)) { listener.updateRecord(this, now, c); } } } }
if ((rec != null) && !rec.isExpired(now))
if ((a.type == DNSConstants.TYPE_SRV) && !a.isExpired(now))
boolean expired = rec.isExpired(now);