Clover Coverage Report - JmDNS 3.4.1
Coverage timestamp: Thu Aug 25 2011 13:06:33 CEST
../../../../img/srcFileCovDistChart7.png 18% of files have more coverage
11   87   7   1.83
2   35   0.64   6
6     1.17  
1    
 
  DNSLabel       Line # 11 11 0% 7 7 63.2% 0.6315789
 
  (21)
 
1    /**
2    *
3    */
4    package javax.jmdns.impl.constants;
5   
6    /**
7    * DNS label.
8    *
9    * @author Arthur van Hoff, Jeff Sonstein, Werner Randelshofer, Pierre Frisch, Rick Blair
10    */
 
11    public enum DNSLabel {
12    /**
13    * This is unallocated.
14    */
15    Unknown("", 0x80),
16    /**
17    * Standard label [RFC 1035]
18    */
19    Standard("standard label", 0x00),
20    /**
21    * Compressed label [RFC 1035]
22    */
23    Compressed("compressed label", 0xC0),
24    /**
25    * Extended label [RFC 2671]
26    */
27    Extended("extended label", 0x40);
28   
29    /**
30    * DNS label types are encoded on the first 2 bits
31    */
32    static final int LABEL_MASK = 0xC0;
33    static final int LABEL_NOT_MASK = 0x3F;
34   
35    private final String _externalName;
36   
37    private final int _index;
38   
 
39  4 toggle DNSLabel(String name, int index) {
40  4 _externalName = name;
41  4 _index = index;
42    }
43   
44    /**
45    * Return the string representation of this type
46    *
47    * @return String
48    */
 
49  0 toggle public String externalName() {
50  0 return _externalName;
51    }
52   
53    /**
54    * Return the numeric value of this type
55    *
56    * @return String
57    */
 
58  0 toggle public int indexValue() {
59  0 return _index;
60    }
61   
62    /**
63    * @param index
64    * @return label
65    */
 
66  3616 toggle public static DNSLabel labelForByte(int index) {
67  3631 int maskedIndex = index & LABEL_MASK;
68  3630 for (DNSLabel aLabel : DNSLabel.values()) {
69  3642 if (aLabel._index == maskedIndex) return aLabel;
70    }
71  0 return Unknown;
72    }
73   
74    /**
75    * @param index
76    * @return masked value
77    */
 
78  1100 toggle public static int labelValue(int index) {
79  1104 return index & LABEL_NOT_MASK;
80    }
81   
 
82  0 toggle @Override
83    public String toString() {
84  0 return this.name() + " index " + this.indexValue();
85    }
86   
87    }