DNSLabel.java
Go to the documentation of this file.
00001 
00004 package javax.jmdns.impl.constants;
00005 
00011 public enum DNSLabel {
00015     Unknown("", 0x80),
00019     Standard("standard label", 0x00),
00023     Compressed("compressed label", 0xC0),
00027     Extended("extended label", 0x40);
00028 
00032     static final int     LABEL_MASK     = 0xC0;
00033     static final int     LABEL_NOT_MASK = 0x3F;
00034 
00035     private final String _externalName;
00036 
00037     private final int    _index;
00038 
00039     DNSLabel(String name, int index) {
00040         _externalName = name;
00041         _index = index;
00042     }
00043 
00049     public String externalName() {
00050         return _externalName;
00051     }
00052 
00058     public int indexValue() {
00059         return _index;
00060     }
00061 
00066     public static DNSLabel labelForByte(int index) {
00067         int maskedIndex = index & LABEL_MASK;
00068         for (DNSLabel aLabel : DNSLabel.values()) {
00069             if (aLabel._index == maskedIndex) return aLabel;
00070         }
00071         return Unknown;
00072     }
00073 
00078     public static int labelValue(int index) {
00079         return index & LABEL_NOT_MASK;
00080     }
00081 
00082     @Override
00083     public String toString() {
00084         return this.name() + " index " + this.indexValue();
00085     }
00086 
00087 }


zeroconf_jmdns_suite
Author(s): Daniel Stonier
autogenerated on Thu Aug 27 2015 15:50:27