本文整理汇总了Java中javax.jmdns.impl.constants.DNSRecordType.TYPE_PTR属性的典型用法代码示例。如果您正苦于以下问题:Java DNSRecordType.TYPE_PTR属性的具体用法?Java DNSRecordType.TYPE_PTR怎么用?Java DNSRecordType.TYPE_PTR使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javax.jmdns.impl.constants.DNSRecordType
的用法示例。
在下文中一共展示了DNSRecordType.TYPE_PTR属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addAnswers
@Override
public void addAnswers(JmDNSImpl jmDNSImpl, Set<DNSRecord> answers) {
String loname = this.getName().toLowerCase();
if (jmDNSImpl.getLocalHost().getName().equalsIgnoreCase(loname)) {
// type = DNSConstants.TYPE_A;
answers.addAll(jmDNSImpl.getLocalHost().answers(this.getRecordClass(), this.isUnique(), DNSConstants.DNS_TTL));
return;
}
// Service type request
if (jmDNSImpl.getServiceTypes().containsKey(loname)) {
DNSQuestion question = new Pointer(this.getName(), DNSRecordType.TYPE_PTR, this.getRecordClass(), this.isUnique());
question.addAnswers(jmDNSImpl, answers);
return;
}
this.addAnswersForServiceInfo(jmDNSImpl, answers, (ServiceInfoImpl) jmDNSImpl.getServices().get(loname));
}
示例2: addAnswers
@Override
public void addAnswers(JmDNSImpl jmDNSImpl, Set<DNSRecord> answers) {
String loname = this.getName().toLowerCase();
if (jmDNSImpl.getLocalHost().getName().equalsIgnoreCase(loname)) {
// type = DNSConstants.TYPE_A;
answers.addAll(jmDNSImpl.getLocalHost().answers(this.isUnique(), DNSConstants.DNS_TTL));
return;
}
// Service type request
if (jmDNSImpl.getServiceTypes().containsKey(loname)) {
DNSQuestion question = new Pointer(this.getName(), DNSRecordType.TYPE_PTR, this.getRecordClass(), this.isUnique());
question.addAnswers(jmDNSImpl, answers);
return;
}
this.addAnswersForServiceInfo(jmDNSImpl, answers, (ServiceInfoImpl) jmDNSImpl.getServices().get(loname));
}
示例3: addAnswers
@Override
public void addAnswers(JmDNSImpl jmDNSImpl, Set<DNSRecord> answers)
{
String name = this.getName().toLowerCase();
if (jmDNSImpl.getLocalHost().getName().equalsIgnoreCase(name))
{
// type = DNSConstants.TYPE_A;
answers.addAll(jmDNSImpl.getLocalHost().answers(this.isUnique(), DNSConstants.DNS_TTL));
return;
}
// Service type request
if (jmDNSImpl.getServiceTypes().containsKey(name))
{
DNSQuestion question = new Pointer(this.getName(), DNSRecordType.TYPE_PTR, this.getRecordClass(), this.isUnique());
question.addAnswers(jmDNSImpl, answers);
return;
}
this.addAnswersForServiceInfo(jmDNSImpl, answers, (ServiceInfoImpl) jmDNSImpl.getServices().get(name));
}
示例4: handleRecord
void handleRecord(DNSRecord record, long now) {
DNSRecord newRecord = record;
Operation cacheOperation = Operation.Noop;
final boolean expired = newRecord.isExpired(now);
if (logger.isLoggable(Level.FINE)) {
logger.fine(this.getName() + " handle response: " + newRecord);
}
// update the cache
if (!newRecord.isServicesDiscoveryMetaQuery() && !newRecord.isDomainDiscoveryQuery()) {
final boolean unique = newRecord.isUnique();
final DNSRecord cachedRecord = (DNSRecord) this.getCache().getDNSEntry(newRecord);
if (logger.isLoggable(Level.FINE)) {
logger.fine(this.getName() + " handle response cached record: " + cachedRecord);
}
if (unique) {
for (DNSEntry entry : this.getCache().getDNSEntryList(newRecord.getKey())) {
if (newRecord.getRecordType().equals(entry.getRecordType()) && newRecord.getRecordClass().equals(entry.getRecordClass()) && (entry != cachedRecord)) {
((DNSRecord) entry).setWillExpireSoon(now);
}
}
}
if (cachedRecord != null) {
if (expired) {
// if the record has a 0 ttl that means we have a cancel record we need to delay the removal by 1s
if (newRecord.getTTL() == 0) {
cacheOperation = Operation.Noop;
cachedRecord.setWillExpireSoon(now);
// the actual record will be disposed of by the record reaper.
} else {
cacheOperation = Operation.Remove;
this.getCache().removeDNSEntry(cachedRecord);
}
} else {
// If the record content has changed we need to inform our listeners.
if (!newRecord.sameValue(cachedRecord) || (!newRecord.sameSubtype(cachedRecord) && (newRecord.getSubtype().length() > 0))) {
if (newRecord.isSingleValued()) {
cacheOperation = Operation.Update;
this.getCache().replaceDNSEntry(newRecord, cachedRecord);
} else {
// Address record can have more than one value on multi-homed machines
cacheOperation = Operation.Add;
this.getCache().addDNSEntry(newRecord);
}
} else {
cachedRecord.resetTTL(newRecord);
newRecord = cachedRecord;
}
}
} else {
if (!expired) {
cacheOperation = Operation.Add;
this.getCache().addDNSEntry(newRecord);
}
}
}
// Register new service types
if (newRecord.getRecordType() == DNSRecordType.TYPE_PTR) {
// handle DNSConstants.DNS_META_QUERY records
boolean typeAdded = false;
if (newRecord.isServicesDiscoveryMetaQuery()) {
// The service names are in the alias.
if (!expired) {
typeAdded = this.registerServiceType(((DNSRecord.Pointer) newRecord).getAlias());
}
return;
}
typeAdded |= this.registerServiceType(newRecord.getName());
if (typeAdded && (cacheOperation == Operation.Noop)) {
cacheOperation = Operation.RegisterServiceType;
}
}
// notify the listeners
if (cacheOperation != Operation.Noop) {
this.updateRecord(now, newRecord, cacheOperation);
}
}
示例5: Pointer
public Pointer(String name, DNSRecordClass recordClass, boolean unique, int ttl, String alias) {
super(name, DNSRecordType.TYPE_PTR, recordClass, unique, ttl);
this._alias = alias;
}
示例6: handleRecord
void handleRecord(DNSRecord record, long now)
{
DNSRecord newRecord = record;
Operation cacheOperation = Operation.Noop;
final boolean expired = newRecord.isExpired(now);
if (logger.isLoggable(Level.FINE))
{
logger.fine(this.getName() + " handle response: " + newRecord);
}
// update the cache
// if ((newRecord.getRecordType() != DNSRecordType.TYPE_PTR) || (!newRecord.isServicesDiscoveryMetaQuery()))
if (!newRecord.isServicesDiscoveryMetaQuery() && !newRecord.isDomainDiscoveryQuery())
{
final DNSRecord cachedRecord = (DNSRecord) this.getCache().getDNSEntry(newRecord);
if (logger.isLoggable(Level.FINE))
{
logger.fine(this.getName() + " handle response cached record: " + cachedRecord);
}
if (cachedRecord != null)
{
if (expired)
{
cacheOperation = Operation.Remove;
this.getCache().removeDNSEntry(cachedRecord);
}
else
{
// If the record content has changed we need to inform our listeners.
if (!newRecord.sameValue(cachedRecord) || (!newRecord.sameSubtype(cachedRecord) && (newRecord.getSubtype().length() > 0)))
{
cacheOperation = Operation.Update;
this.getCache().replaceDNSEntry(newRecord, cachedRecord);
}
else
{
cachedRecord.resetTTL(newRecord);
newRecord = cachedRecord;
}
}
}
else
{
if (!expired)
{
cacheOperation = Operation.Add;
this.getCache().addDNSEntry(newRecord);
}
}
}
// Register new service types
if (newRecord.getRecordType() == DNSRecordType.TYPE_PTR)
{
// handle DNSConstants.DNS_META_QUERY records
boolean typeAdded = false;
if (newRecord.isServicesDiscoveryMetaQuery())
{
// The service names are in the alias.
if (!expired)
{
typeAdded = this.registerServiceType(((DNSRecord.Pointer) newRecord).getAlias());
}
return;
}
typeAdded |= this.registerServiceType(newRecord.getName());
if (typeAdded && (cacheOperation == Operation.Noop))
{
cacheOperation = Operation.RegisterServiceType;
}
}
// notify the listeners
if (cacheOperation != Operation.Noop)
{
this.updateRecord(now, newRecord, cacheOperation);
}
}
示例7: Pointer
public Pointer(String name, DNSRecordClass recordClass, boolean unique, int ttl, String alias)
{
super(name, DNSRecordType.TYPE_PTR, recordClass, unique, ttl);
this._alias = alias;
}