Clover Coverage Report - JmDNS 3.4.1
Coverage timestamp: Thu Aug 25 2011 13:06:33 CEST
../../../../img/srcFileCovDistChart5.png 47% of files have more coverage
19   138   10   2.71
6   54   0.53   7
7     1.43  
1    
 
  DNSRecordClass       Line # 14 19 0% 10 18 43.8% 0.4375
 
  (21)
 
1    /**
2    *
3    */
4    package javax.jmdns.impl.constants;
5   
6    import java.util.logging.Level;
7    import java.util.logging.Logger;
8   
9    /**
10    * DNS Record Class
11    *
12    * @author Arthur van Hoff, Jeff Sonstein, Werner Randelshofer, Pierre Frisch, Rick Blair
13    */
 
14    public enum DNSRecordClass {
15    /**
16    *
17    */
18    CLASS_UNKNOWN("?", 0),
19    /**
20    * static final Internet
21    */
22    CLASS_IN("in", 1),
23    /**
24    * CSNET
25    */
26    CLASS_CS("cs", 2),
27    /**
28    * CHAOS
29    */
30    CLASS_CH("ch", 3),
31    /**
32    * Hesiod
33    */
34    CLASS_HS("hs", 4),
35    /**
36    * Used in DNS UPDATE [RFC 2136]
37    */
38    CLASS_NONE("none", 254),
39    /**
40    * Not a DNS class, but a DNS query class, meaning "all classes"
41    */
42    CLASS_ANY("any", 255);
43   
44    private static Logger logger = Logger.getLogger(DNSRecordClass.class.getName());
45   
46    /**
47    * Multicast DNS uses the bottom 15 bits to identify the record class...<br/>
48    * Except for pseudo records like OPT.
49    */
50    public static final int CLASS_MASK = 0x7FFF;
51   
52    /**
53    * For answers the top bit indicates that all other cached records are now invalid.<br/>
54    * For questions it indicates that we should send a unicast response.
55    */
56    public static final int CLASS_UNIQUE = 0x8000;
57   
58    /**
59    *
60    */
61    public static final boolean UNIQUE = true;
62   
63    /**
64    *
65    */
66    public static final boolean NOT_UNIQUE = false;
67   
68    private final String _externalName;
69   
70    private final int _index;
71   
 
72  7 toggle DNSRecordClass(String name, int index) {
73  7 _externalName = name;
74  7 _index = index;
75    }
76   
77    /**
78    * Return the string representation of this type
79    *
80    * @return String
81    */
 
82  0 toggle public String externalName() {
83  0 return _externalName;
84    }
85   
86    /**
87    * Return the numeric value of this type
88    *
89    * @return String
90    */
 
91  1863 toggle public int indexValue() {
92  1863 return _index;
93    }
94   
95    /**
96    * Checks if the class is unique
97    *
98    * @param index
99    * @return <code>true</code> is the class is unique, <code>false</code> otherwise.
100    */
 
101  1403 toggle public boolean isUnique(int index) {
102  1427 return (this != CLASS_UNKNOWN) && ((index & CLASS_UNIQUE) != 0);
103    }
104   
105    /**
106    * @param name
107    * @return class for name
108    */
 
109  0 toggle public static DNSRecordClass classForName(String name) {
110  0 if (name != null) {
111  0 String aName = name.toLowerCase();
112  0 for (DNSRecordClass aClass : DNSRecordClass.values()) {
113  0 if (aClass._externalName.equals(aName)) return aClass;
114    }
115    }
116  0 logger.log(Level.WARNING, "Could not find record class for name: " + name);
117  0 return CLASS_UNKNOWN;
118    }
119   
120    /**
121    * @param index
122    * @return class for name
123    */
 
124  1399 toggle public static DNSRecordClass classForIndex(int index) {
125  1422 int maskedIndex = index & CLASS_MASK;
126  1413 for (DNSRecordClass aClass : DNSRecordClass.values()) {
127  1425 if (aClass._index == maskedIndex) return aClass;
128    }
129  0 logger.log(Level.WARNING, "Could not find record class for index: " + index);
130  0 return CLASS_UNKNOWN;
131    }
132   
 
133  0 toggle @Override
134    public String toString() {
135  0 return this.name() + " index " + this.indexValue();
136    }
137   
138    }