$search
00001 // Copyright 2003-2005 Arthur van Hoff, Rick Blair 00002 // Licensed under Apache License version 2.0 00003 // Original license LGPL 00004 00005 package javax.jmdns.impl.tasks.resolver; 00006 00007 import java.io.IOException; 00008 00009 import javax.jmdns.impl.DNSOutgoing; 00010 import javax.jmdns.impl.DNSQuestion; 00011 import javax.jmdns.impl.DNSRecord; 00012 import javax.jmdns.impl.JmDNSImpl; 00013 import javax.jmdns.impl.JmDNSImpl.ServiceTypeEntry; 00014 import javax.jmdns.impl.constants.DNSConstants; 00015 import javax.jmdns.impl.constants.DNSRecordClass; 00016 import javax.jmdns.impl.constants.DNSRecordType; 00017 00025 public class TypeResolver extends DNSResolverTask { 00026 00030 public TypeResolver(JmDNSImpl jmDNSImpl) { 00031 super(jmDNSImpl); 00032 } 00033 00034 /* 00035 * (non-Javadoc) 00036 * @see javax.jmdns.impl.tasks.DNSTask#getName() 00037 */ 00038 @Override 00039 public String getName() { 00040 return "TypeResolver(" + (this.getDns() != null ? this.getDns().getName() : "") + ")"; 00041 } 00042 00043 /* 00044 * (non-Javadoc) 00045 * @see javax.jmdns.impl.tasks.Resolver#addAnswers(javax.jmdns.impl.DNSOutgoing) 00046 */ 00047 @Override 00048 protected DNSOutgoing addAnswers(DNSOutgoing out) throws IOException { 00049 DNSOutgoing newOut = out; 00050 long now = System.currentTimeMillis(); 00051 for (String type : this.getDns().getServiceTypes().keySet()) { 00052 ServiceTypeEntry typeEntry = this.getDns().getServiceTypes().get(type); 00053 newOut = this.addAnswer(newOut, new DNSRecord.Pointer("_services._dns-sd._udp.local.", DNSRecordClass.CLASS_IN, DNSRecordClass.NOT_UNIQUE, DNSConstants.DNS_TTL, typeEntry.getType()), now); 00054 } 00055 return newOut; 00056 } 00057 00058 /* 00059 * (non-Javadoc) 00060 * @see javax.jmdns.impl.tasks.Resolver#addQuestions(javax.jmdns.impl.DNSOutgoing) 00061 */ 00062 @Override 00063 protected DNSOutgoing addQuestions(DNSOutgoing out) throws IOException { 00064 return this.addQuestion(out, DNSQuestion.newQuestion("_services._dns-sd._udp.local.", DNSRecordType.TYPE_PTR, DNSRecordClass.CLASS_IN, DNSRecordClass.NOT_UNIQUE)); 00065 } 00066 00067 /* 00068 * (non-Javadoc) 00069 * @see javax.jmdns.impl.tasks.Resolver#description() 00070 */ 00071 @Override 00072 protected String description() { 00073 return "querying type"; 00074 } 00075 }