本文整理汇总了Java中javax.jmdns.ServiceInfo.Fields类的典型用法代码示例。如果您正苦于以下问题:Java Fields类的具体用法?Java Fields怎么用?Java Fields使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Fields类属于javax.jmdns.ServiceInfo包,在下文中一共展示了Fields类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testDecodeQualifiedNameMap
import javax.jmdns.ServiceInfo.Fields; //导入依赖的package包/类
@Test
public void testDecodeQualifiedNameMap() {
String domain = "test.com";
String protocol = "udp";
String application = "ftp";
String name = "My Service";
String subtype = "printer";
String type = "_" + application + "._" + protocol + "." + domain + ".";
Map<Fields, String> map = ServiceInfoImpl.decodeQualifiedNameMap(type, name, subtype);
assertEquals("We did not get the right domain:", domain, map.get(Fields.Domain));
assertEquals("We did not get the right protocol:", protocol, map.get(Fields.Protocol));
assertEquals("We did not get the right application:", application, map.get(Fields.Application));
assertEquals("We did not get the right name:", name, map.get(Fields.Instance));
assertEquals("We did not get the right subtype:", subtype, map.get(Fields.Subtype));
}
示例2: testDecodeQualifiedNameMapDefaults
import javax.jmdns.ServiceInfo.Fields; //导入依赖的package包/类
@Test
public void testDecodeQualifiedNameMapDefaults() {
String domain = "local";
String protocol = "tcp";
String application = "ftp";
String name = "My Service";
String subtype = "";
Map<Fields, String> map = ServiceInfoImpl.decodeQualifiedNameMap(application, name, subtype);
assertEquals("We did not get the right domain:", domain, map.get(Fields.Domain));
assertEquals("We did not get the right protocol:", protocol, map.get(Fields.Protocol));
assertEquals("We did not get the right application:", application, map.get(Fields.Application));
assertEquals("We did not get the right name:", name, map.get(Fields.Instance));
assertEquals("We did not get the right subtype:", subtype, map.get(Fields.Subtype));
}
示例3: DNSEntry
import javax.jmdns.ServiceInfo.Fields; //导入依赖的package包/类
/**
* Create an entry.
*/
DNSEntry(String name, DNSRecordType type, DNSRecordClass recordClass, boolean unique) {
_name = name;
// _key = (name != null ? name.trim().toLowerCase() : null);
_recordType = type;
_dnsClass = recordClass;
_unique = unique;
_qualifiedNameMap = ServiceInfoImpl.decodeQualifiedNameMapForType(this.getName());
String domain = _qualifiedNameMap.get(Fields.Domain);
String protocol = _qualifiedNameMap.get(Fields.Protocol);
String application = _qualifiedNameMap.get(Fields.Application);
String instance = _qualifiedNameMap.get(Fields.Instance).toLowerCase();
_type = (application.length() > 0 ? "_" + application + "." : "") + (protocol.length() > 0 ? "_" + protocol + "." : "") + domain + ".";
_key = ((instance.length() > 0 ? instance + "." : "") + _type).toLowerCase();
}
示例4: isDomainDiscoveryQuery
import javax.jmdns.ServiceInfo.Fields; //导入依赖的package包/类
public boolean isDomainDiscoveryQuery() {
// b._dns-sd._udp.<domain>.
// db._dns-sd._udp.<domain>.
// r._dns-sd._udp.<domain>.
// dr._dns-sd._udp.<domain>.
// lb._dns-sd._udp.<domain>.
if (_qualifiedNameMap.get(Fields.Application).equals("dns-sd")) {
String name = _qualifiedNameMap.get(Fields.Instance);
return "b".equals(name) || "db".equals(name) || "r".equals(name) || "dr".equals(name) || "lb".equals(name);
}
return false;
}
示例5: addAnswers
import javax.jmdns.ServiceInfo.Fields; //导入依赖的package包/类
@Override
public void addAnswers(JmDNSImpl jmDNSImpl, Set<DNSRecord> answers) {
// find matching services
for (ServiceInfo serviceInfo : jmDNSImpl.getServices().values()) {
this.addAnswersForServiceInfo(jmDNSImpl, answers, (ServiceInfoImpl) serviceInfo);
}
if (this.isServicesDiscoveryMetaQuery()) {
for (String serviceType : jmDNSImpl.getServiceTypes().keySet()) {
ServiceTypeEntry typeEntry = jmDNSImpl.getServiceTypes().get(serviceType);
answers.add(new DNSRecord.Pointer("_services._dns-sd._udp.local.", DNSRecordClass.CLASS_IN, DNSRecordClass.NOT_UNIQUE, DNSConstants.DNS_TTL, typeEntry.getType()));
}
} else if (this.isReverseLookup()) {
String ipValue = this.getQualifiedNameMap().get(Fields.Instance);
if ((ipValue != null) && (ipValue.length() > 0)) {
InetAddress address = jmDNSImpl.getLocalHost().getInetAddress();
String hostIPAddress = (address != null ? address.getHostAddress() : "");
if (ipValue.equalsIgnoreCase(hostIPAddress)) {
if (this.isV4ReverseLookup()) {
answers.add(jmDNSImpl.getLocalHost().getDNSReverseAddressRecord(DNSRecordType.TYPE_A, DNSRecordClass.NOT_UNIQUE, DNSConstants.DNS_TTL));
}
if (this.isV6ReverseLookup()) {
answers.add(jmDNSImpl.getLocalHost().getDNSReverseAddressRecord(DNSRecordType.TYPE_AAAA, DNSRecordClass.NOT_UNIQUE, DNSConstants.DNS_TTL));
}
}
}
} else if (this.isDomainDiscoveryQuery()) {
// FIXME [PJYF Nov 16 2010] We do not currently support domain discovery
}
}
示例6: DNSEntry
import javax.jmdns.ServiceInfo.Fields; //导入依赖的package包/类
/**
* Create an entry.
*/
DNSEntry(String name, DNSRecordType type, DNSRecordClass recordClass, boolean unique)
{
_name = name;
// _key = (name != null ? name.trim().toLowerCase() : null);
_type = type;
_dnsClass = recordClass;
_unique = unique;
_qualifiedNameMap = ServiceInfoImpl.decodeQualifiedNameMapForType(this.getName());
String domain = _qualifiedNameMap.get(Fields.Domain);
String protocol = _qualifiedNameMap.get(Fields.Protocol);
String application = _qualifiedNameMap.get(Fields.Application);
String instance = _qualifiedNameMap.get(Fields.Instance).toLowerCase();
_key = (instance.length() > 0 ? instance + "." : "") + (application.length() > 0 ? "_" + application + "." : "") + (protocol.length() > 0 ? "_" + protocol + "." : "") + domain + ".";
}
示例7: isDomainDiscoveryQuery
import javax.jmdns.ServiceInfo.Fields; //导入依赖的package包/类
public boolean isDomainDiscoveryQuery()
{
// b._dns-sd._udp.<domain>.
// db._dns-sd._udp.<domain>.
// r._dns-sd._udp.<domain>.
// dr._dns-sd._udp.<domain>.
// lb._dns-sd._udp.<domain>.
if (_qualifiedNameMap.get(Fields.Application).equals("dns-sd"))
{
String name = _qualifiedNameMap.get(Fields.Instance);
return name.equals("b") || name.equals("db") || name.equals("r") || name.equals("dr") || name.equals("lb");
}
return false;
}
示例8: addAnswers
import javax.jmdns.ServiceInfo.Fields; //导入依赖的package包/类
@Override
public void addAnswers(JmDNSImpl jmDNSImpl, Set<DNSRecord> answers)
{
// find matching services
for (ServiceInfo serviceInfo : jmDNSImpl.getServices().values())
{
this.addAnswersForServiceInfo(jmDNSImpl, answers, (ServiceInfoImpl) serviceInfo);
}
if (this.isServicesDiscoveryMetaQuery())
{
for (String serviceType : jmDNSImpl.getServiceTypes().keySet())
{
answers.add(new DNSRecord.Pointer("_services._dns-sd._udp.local.", DNSRecordClass.CLASS_IN, DNSRecordClass.NOT_UNIQUE, DNSConstants.DNS_TTL, serviceType));
}
}
else if (this.isReverseLookup())
{
String ipValue = this.getQualifiedNameMap().get(Fields.Instance);
if ((ipValue != null) && (!ipValue.isEmpty()))
{
InetAddress address = jmDNSImpl.getLocalHost().getInetAddress();
String hostIPAddress = (address != null ? address.getHostAddress() : "");
if (ipValue.equalsIgnoreCase(hostIPAddress))
{
if (this.isV4ReverseLookup()) {
answers.add(jmDNSImpl.getLocalHost().getDNSReverseAddressRecord(DNSRecordType.TYPE_A, DNSRecordClass.NOT_UNIQUE, DNSConstants.DNS_TTL));
}
if (this.isV6ReverseLookup()) {
answers.add(jmDNSImpl.getLocalHost().getDNSReverseAddressRecord(DNSRecordType.TYPE_AAAA, DNSRecordClass.NOT_UNIQUE, DNSConstants.DNS_TTL));
}
}
}
}
else if (this.isDomainDiscoveryQuery())
{
// FIXME [PJYF Nov 16 2010] We do not currently support domain discovery
}
}
示例9: testDecodeServiceType
import javax.jmdns.ServiceInfo.Fields; //导入依赖的package包/类
@Test
public void testDecodeServiceType() {
String type = "_home-sharing._tcp.local.";
Map<Fields, String> map = ServiceInfoImpl.decodeQualifiedNameMapForType(type);
assertEquals("We did not get the right domain:", "local", map.get(Fields.Domain));
assertEquals("We did not get the right protocol:", "tcp", map.get(Fields.Protocol));
assertEquals("We did not get the right application:", "home-sharing", map.get(Fields.Application));
assertEquals("We did not get the right name:", "", map.get(Fields.Instance));
assertEquals("We did not get the right subtype:", "", map.get(Fields.Subtype));
}
示例10: testDecodeServiceWithUnderscoreType
import javax.jmdns.ServiceInfo.Fields; //导入依赖的package包/类
@Test
public void testDecodeServiceWithUnderscoreType() {
String type = "_x_lumenera_mjpeg1._udp.local.";
Map<Fields, String> map = ServiceInfoImpl.decodeQualifiedNameMapForType(type);
assertEquals("We did not get the right domain:", "local", map.get(Fields.Domain));
assertEquals("We did not get the right protocol:", "udp", map.get(Fields.Protocol));
assertEquals("We did not get the right application:", "x_lumenera_mjpeg1", map.get(Fields.Application));
assertEquals("We did not get the right name:", "", map.get(Fields.Instance));
assertEquals("We did not get the right subtype:", "", map.get(Fields.Subtype));
}
示例11: testDecodeServiceTCPType
import javax.jmdns.ServiceInfo.Fields; //导入依赖的package包/类
@Test
public void testDecodeServiceTCPType() {
String type = "_afpovertcp._tcp.local.";
Map<Fields, String> map = ServiceInfoImpl.decodeQualifiedNameMapForType(type);
assertEquals("We did not get the right domain:", "local", map.get(Fields.Domain));
assertEquals("We did not get the right protocol:", "tcp", map.get(Fields.Protocol));
assertEquals("We did not get the right application:", "afpovertcp", map.get(Fields.Application));
assertEquals("We did not get the right name:", "", map.get(Fields.Instance));
assertEquals("We did not get the right subtype:", "", map.get(Fields.Subtype));
}
示例12: testDecodeServiceTypeWithSubType
import javax.jmdns.ServiceInfo.Fields; //导入依赖的package包/类
@Test
public void testDecodeServiceTypeWithSubType() {
String type = "_00000000-0b44-f234-48c8-071c565644b3._sub._home-sharing._tcp.local.";
Map<Fields, String> map = ServiceInfoImpl.decodeQualifiedNameMapForType(type);
assertEquals("We did not get the right domain:", "local", map.get(Fields.Domain));
assertEquals("We did not get the right protocol:", "tcp", map.get(Fields.Protocol));
assertEquals("We did not get the right application:", "home-sharing", map.get(Fields.Application));
assertEquals("We did not get the right name:", "", map.get(Fields.Instance));
assertEquals("We did not get the right subtype:", "00000000-0b44-f234-48c8-071c565644b3", map.get(Fields.Subtype));
}
示例13: testDecodeServiceName
import javax.jmdns.ServiceInfo.Fields; //导入依赖的package包/类
@Test
public void testDecodeServiceName() {
String type = "My New Itunes Service._home-sharing._tcp.local.";
Map<Fields, String> map = ServiceInfoImpl.decodeQualifiedNameMapForType(type);
assertEquals("We did not get the right domain:", "local", map.get(Fields.Domain));
assertEquals("We did not get the right protocol:", "tcp", map.get(Fields.Protocol));
assertEquals("We did not get the right application:", "home-sharing", map.get(Fields.Application));
assertEquals("We did not get the right name:", "My New Itunes Service", map.get(Fields.Instance));
assertEquals("We did not get the right subtype:", "", map.get(Fields.Subtype));
}
示例14: testDecodeServiceNameWithSpecialCharacter
import javax.jmdns.ServiceInfo.Fields; //导入依赖的package包/类
@Test
public void testDecodeServiceNameWithSpecialCharacter() {
String type = "&test._home-sharing._tcp.local.";
Map<Fields, String> map = ServiceInfoImpl.decodeQualifiedNameMapForType(type);
assertEquals("We did not get the right domain:", "local", map.get(Fields.Domain));
assertEquals("We did not get the right protocol:", "tcp", map.get(Fields.Protocol));
assertEquals("We did not get the right application:", "home-sharing", map.get(Fields.Application));
assertEquals("We did not get the right name:", "&test", map.get(Fields.Instance));
assertEquals("We did not get the right subtype:", "", map.get(Fields.Subtype));
}
示例15: testDecodeDNSMetaQuery
import javax.jmdns.ServiceInfo.Fields; //导入依赖的package包/类
@Test
public void testDecodeDNSMetaQuery() {
String type = "_services._dns-sd._udp.local.";
Map<Fields, String> map = ServiceInfoImpl.decodeQualifiedNameMapForType(type);
assertEquals("We did not get the right domain:", "local", map.get(Fields.Domain));
assertEquals("We did not get the right protocol:", "udp", map.get(Fields.Protocol));
assertEquals("We did not get the right application:", "dns-sd", map.get(Fields.Application));
assertEquals("We did not get the right name:", "_services", map.get(Fields.Instance));
assertEquals("We did not get the right subtype:", "", map.get(Fields.Subtype));
}