Clover Coverage Report - JmDNS 3.4.1
Coverage timestamp: Thu Aug 25 2011 13:06:33 CEST
../../../../img/srcFileCovDistChart6.png 31% of files have more coverage
57   215   35   5.18
0   102   0.61   5.5
11     3.18  
2    
 
  DNSState       Line # 12 57 0% 35 29 57.4% 0.5735294
  DNSState.StateClass       Line # 63 0 - 0 0 - -1.0
 
  (21)
 
1    // Copyright 2003-2005 Arthur van Hoff, Rick Blair
2    // Licensed under Apache License version 2.0
3    // Original license LGPL
4   
5    package javax.jmdns.impl.constants;
6   
7    /**
8    * DNSState defines the possible states for services registered with JmDNS.
9    *
10    * @author Werner Randelshofer, Rick Blair, Pierre Frisch
11    */
 
12    public enum DNSState {
13   
14    /**
15    *
16    */
17    PROBING_1("probing 1", StateClass.probing),
18    /**
19    *
20    */
21    PROBING_2("probing 2", StateClass.probing),
22    /**
23    *
24    */
25    PROBING_3("probing 3", StateClass.probing),
26    /**
27    *
28    */
29    ANNOUNCING_1("announcing 1", StateClass.announcing),
30    /**
31    *
32    */
33    ANNOUNCING_2("announcing 2", StateClass.announcing),
34    /**
35    *
36    */
37    ANNOUNCED("announced", StateClass.announced),
38    /**
39    *
40    */
41    CANCELING_1("canceling 1", StateClass.canceling),
42    /**
43    *
44    */
45    CANCELING_2("canceling 2", StateClass.canceling),
46    /**
47    *
48    */
49    CANCELING_3("canceling 3", StateClass.canceling),
50    /**
51    *
52    */
53    CANCELED("canceled", StateClass.canceled),
54    /**
55    *
56    */
57    CLOSING("closing", StateClass.closing),
58    /**
59    *
60    */
61    CLOSED("closed", StateClass.closed);
62   
 
63    private enum StateClass {
64    probing, announcing, announced, canceling, canceled, closing, closed
65    }
66   
67    // private static Logger logger = Logger.getLogger(DNSState.class.getName());
68   
69    private final String _name;
70   
71    private final StateClass _state;
72   
 
73  12 toggle private DNSState(String name, StateClass state) {
74  12 _name = name;
75  12 _state = state;
76    }
77   
 
78  310 toggle @Override
79    public final String toString() {
80  310 return _name;
81    }
82   
83    /**
84    * Returns the next advanced state.<br/>
85    * In general, this advances one step in the following sequence: PROBING_1, PROBING_2, PROBING_3, ANNOUNCING_1, ANNOUNCING_2, ANNOUNCED.<br/>
86    * or CANCELING_1, CANCELING_2, CANCELING_3, CANCELED Does not advance for ANNOUNCED and CANCELED state.
87    *
88    * @return next state
89    */
 
90  635 toggle public final DNSState advance() {
91  635 switch (this) {
92  94 case PROBING_1:
93  94 return PROBING_2;
94  94 case PROBING_2:
95  94 return PROBING_3;
96  94 case PROBING_3:
97  94 return ANNOUNCING_1;
98  102 case ANNOUNCING_1:
99  102 return ANNOUNCING_2;
100  102 case ANNOUNCING_2:
101  102 return ANNOUNCED;
102  0 case ANNOUNCED:
103  0 return ANNOUNCED;
104  40 case CANCELING_1:
105  40 return CANCELING_2;
106  40 case CANCELING_2:
107  40 return CANCELING_3;
108  40 case CANCELING_3:
109  40 return CANCELED;
110  0 case CANCELED:
111  0 return CANCELED;
112  29 case CLOSING:
113  29 return CLOSED;
114  0 case CLOSED:
115  0 return CLOSED;
116  0 default:
117    // This is just to keep the compiler happy as we have covered all cases before.
118  0 return this;
119    }
120    }
121   
122    /**
123    * Returns to the next reverted state. All states except CANCELED revert to PROBING_1. Status CANCELED does not revert.
124    *
125    * @return reverted state
126    */
 
127  0 toggle public final DNSState revert() {
128  0 switch (this) {
129  0 case PROBING_1:
130  0 case PROBING_2:
131  0 case PROBING_3:
132  0 case ANNOUNCING_1:
133  0 case ANNOUNCING_2:
134  0 case ANNOUNCED:
135  0 return PROBING_1;
136  0 case CANCELING_1:
137  0 case CANCELING_2:
138  0 case CANCELING_3:
139  0 return CANCELING_1;
140  0 case CANCELED:
141  0 return CANCELED;
142  0 case CLOSING:
143  0 return CLOSING;
144  0 case CLOSED:
145  0 return CLOSED;
146  0 default:
147    // This is just to keep the compiler happy as we have covered all cases before.
148  0 return this;
149    }
150    }
151   
152    /**
153    * Returns true, if this is a probing state.
154    *
155    * @return <code>true</code> if probing state, <code>false</code> otherwise
156    */
 
157  141 toggle public final boolean isProbing() {
158  141 return _state == StateClass.probing;
159    }
160   
161    /**
162    * Returns true, if this is an announcing state.
163    *
164    * @return <code>true</code> if announcing state, <code>false</code> otherwise
165    */
 
166  162 toggle public final boolean isAnnouncing() {
167  162 return _state == StateClass.announcing;
168    }
169   
170    /**
171    * Returns true, if this is an announced state.
172    *
173    * @return <code>true</code> if announced state, <code>false</code> otherwise
174    */
 
175  1191 toggle public final boolean isAnnounced() {
176  1192 return _state == StateClass.announced;
177    }
178   
179    /**
180    * Returns true, if this is a canceling state.
181    *
182    * @return <code>true</code> if canceling state, <code>false</code> otherwise
183    */
 
184  2524 toggle public final boolean isCanceling() {
185  2541 return _state == StateClass.canceling;
186    }
187   
188    /**
189    * Returns true, if this is a canceled state.
190    *
191    * @return <code>true</code> if canceled state, <code>false</code> otherwise
192    */
 
193  3036 toggle public final boolean isCanceled() {
194  3050 return _state == StateClass.canceled;
195    }
196   
197    /**
198    * Returns true, if this is a closing state.
199    *
200    * @return <code>true</code> if closing state, <code>false</code> otherwise
201    */
 
202  794 toggle public final boolean isClosing() {
203  811 return _state == StateClass.closing;
204    }
205   
206    /**
207    * Returns true, if this is a closing state.
208    *
209    * @return <code>true</code> if closed state, <code>false</code> otherwise
210    */
 
211  739 toggle public final boolean isClosed() {
212  759 return _state == StateClass.closed;
213    }
214   
215    }