All Downloads are FREE. Search and download functionalities are using the official Maven repository.

javax.jmdns.impl.constants.DNSRecordClass Maven / Gradle / Ivy

Go to download

JmDNS is a Java implementation of multi-cast DNS and can be used for service registration and discovery in local area networks. JmDNS is fully compatible with Apple's Bonjour. The project was originally started in December 2002 by Arthur van Hoff at Strangeberry. In November 2003 the project was moved to SourceForge, and the name was changed from JRendezvous to JmDNS for legal reasons. Many thanks to Stuart Cheshire for help and moral support.

The newest version!
/**
 *
 */
package javax.jmdns.impl.constants;

import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * DNS Record Class
 * 
 * @author Arthur van Hoff, Jeff Sonstein, Werner Randelshofer, Pierre Frisch, Rick Blair
 */
public enum DNSRecordClass {
    /**
     *
     */
    CLASS_UNKNOWN("?", 0),
    /**
     * static final Internet
     */
    CLASS_IN("in", 1),
    /**
     * CSNET
     */
    CLASS_CS("cs", 2),
    /**
     * CHAOS
     */
    CLASS_CH("ch", 3),
    /**
     * Hesiod
     */
    CLASS_HS("hs", 4),
    /**
     * Used in DNS UPDATE [RFC 2136]
     */
    CLASS_NONE("none", 254),
    /**
     * Not a DNS class, but a DNS query class, meaning "all classes"
     */
    CLASS_ANY("any", 255);

    private static Logger       logger       = Logger.getLogger(DNSRecordClass.class.getName());

    /**
     * Multicast DNS uses the bottom 15 bits to identify the record class...
* Except for pseudo records like OPT. */ public static final int CLASS_MASK = 0x7FFF; /** * For answers the top bit indicates that all other cached records are now invalid.
* For questions it indicates that we should send a unicast response. */ public static final int CLASS_UNIQUE = 0x8000; /** * */ public static final boolean UNIQUE = true; /** * */ public static final boolean NOT_UNIQUE = false; private final String _externalName; private final int _index; DNSRecordClass(String name, int index) { _externalName = name; _index = index; } /** * Return the string representation of this type * * @return String */ public String externalName() { return _externalName; } /** * Return the numeric value of this type * * @return String */ public int indexValue() { return _index; } /** * Checks if the class is unique * * @param index * @return true is the class is unique, false otherwise. */ public boolean isUnique(int index) { return (this != CLASS_UNKNOWN) && ((index & CLASS_UNIQUE) != 0); } /** * @param name * @return class for name */ public static DNSRecordClass classForName(String name) { if (name != null) { String aName = name.toLowerCase(); for (DNSRecordClass aClass : DNSRecordClass.values()) { if (aClass._externalName.equals(aName)) return aClass; } } logger.log(Level.WARNING, "Could not find record class for name: " + name); return CLASS_UNKNOWN; } /** * @param index * @return class for name */ public static DNSRecordClass classForIndex(int index) { int maskedIndex = index & CLASS_MASK; for (DNSRecordClass aClass : DNSRecordClass.values()) { if (aClass._index == maskedIndex) return aClass; } logger.log(Level.WARNING, "Could not find record class for index: " + index); return CLASS_UNKNOWN; } @Override public String toString() { return this.name() + " index " + this.indexValue(); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy