PageRenderTime 33ms CodeModel.GetById 16ms app.highlight 13ms RepoModel.GetById 2ms app.codeStats 0ms

/protocols/jain-megaco/megaco-api/src/main/java/javax/megaco/message/descriptor/AuditValRespDescriptor.java

http://mobicents.googlecode.com/
Java | 333 lines | 124 code | 46 blank | 163 comment | 8 complexity | b0b3eace75dec63e11dc14335cce5952 MD5 | raw file
  1package javax.megaco.message.descriptor;
  2
  3import java.io.Serializable;
  4import java.util.Collections;
  5import java.util.HashSet;
  6import java.util.Set;
  7
  8
  9import javax.megaco.message.Descriptor;
 10import javax.megaco.message.DescriptorType;
 11
 12/**
 13 * The class extends JAIN MEGACO Descriptor. This class describes the audit
 14 * value response descriptor. It specifies the tokens and descriptors for audit
 15 * value response.
 16 */
 17public class AuditValRespDescriptor extends Descriptor implements Serializable {
 18
 19	private boolean obsEventToken;
 20	private boolean eventsToken;
 21	private boolean statsToken;
 22	private boolean eventBuffToken;
 23	private boolean signalToken;
 24	private boolean mediaToken;
 25	private boolean modemTokenPresent;
 26	private boolean muxToken;
 27	private boolean digitMapToken;
 28	private boolean packagesToken;
 29	
 30	private Descriptor[] descriptors;
 31
 32	/**
 33	 * * <br>
 34	 * 1. Media Descriptor<br>
 35	 * 2. Modem Descriptor<br>
 36	 * 3. Mux Descriptor<br>
 37	 * 4. Events Descriptor<br>
 38	 * 5. Signal Descriptor<br>
 39	 * 6. Digit Map Descriptor<br>
 40	 * 7. Observed Events Descriptor<br>
 41	 * 8. Event Buffer Descriptor<br>
 42	 * 9. Statistics Descriptor<br>
 43	 * 10. Package Descriptor<br>
 44	 * 11. Error Descriptor<br>
 45	 **/
 46	private static final Set<Integer> allowedDescritpors;
 47	static {
 48
 49		Set<Integer> tmps = new HashSet<Integer>();
 50		tmps.add(DescriptorType.M_MEDIA_DESC);
 51		tmps.add(DescriptorType.M_MODEM_DESC);
 52		tmps.add(DescriptorType.M_MUX_DESC);
 53		tmps.add(DescriptorType.M_EVENT_DESC);
 54		tmps.add(DescriptorType.M_SIGNAL_DESC);
 55		tmps.add(DescriptorType.M_DIGIT_MAP_DESC);
 56		tmps.add(DescriptorType.M_OBSERVED_EVENT_DESC);
 57		tmps.add(DescriptorType.M_EVENT_BUF_DESC);
 58		tmps.add(DescriptorType.M_STATISTICS_DESC);
 59		tmps.add(DescriptorType.M_PACKAGE_DESC);
 60		tmps.add(DescriptorType.M_ERROR_DESC);
 61
 62		allowedDescritpors = Collections.unmodifiableSet(tmps);
 63	}
 64
 65	/**
 66	 * Constructs a Audit Value Response Descriptor. It specifies the tokens for
 67	 * which the audit value is required.
 68	 */
 69	public AuditValRespDescriptor() {
 70		super.descriptorId = DescriptorType.M_AUDIT_VAL_REPLY_DESC;
 71	}
 72
 73	/**
 74	 * This method cannot be overridden by the derived class. This method
 75	 * returns that the descriptor identifier is of type audit value response
 76	 * descriptor. This method overrides the corresponding method of the base
 77	 * class Descriptor.
 78	 * 
 79	 * @return Returns an integer value that identifies this object of the type
 80	 *         of audit value response descriptor. It returns that it is audit
 81	 *         value response Descriptor i.e., M_AUDIT_VAL_REPLY_DESC.
 82	 */
 83	public int getDescriptorId() {
 84		return super.descriptorId;
 85	}
 86
 87	/**
 88	 * Gets the Descriptor information for all the descriptor in this audit
 89	 * response parameter.
 90	 * 
 91	 * @return The vector of the reference to the object identifier of type
 92	 *         descriptor information.
 93	 */
 94	public Descriptor[] getDescriptor() {
 95		return this.descriptors;
 96	}
 97
 98	/**
 99	 * Sets the vector of Descriptor Information for this audit response
100	 * parameter. Only valid descriptors are <br>
101	 * <br>
102	 * 1. Media Descriptor<br>
103	 * 2. Modem Descriptor<br>
104	 * 3. Mux Descriptor<br>
105	 * 4. Events Descriptor<br>
106	 * 5. Signal Descriptor<br>
107	 * 6. Digit Map Descriptor<br>
108	 * 7. Observed Events Descriptor<br>
109	 * 8. Event Buffer Descriptor<br>
110	 * 9. Statistics Descriptor<br>
111	 * 10. Package Descriptor<br>
112	 * 11. Error Descriptor<br>
113	 * 
114	 * 
115	 * @param descriptor
116	 *            The vector of reference to the object identifier of type
117	 *            descriptor information.
118	 * @throws IllegalArgumentException
119	 *             if the descriptor passed to this method is invalid.
120	 */
121	public void setDescriptor(Descriptor[] descriptors) throws IllegalArgumentException {
122		if (descriptors == null) {
123			throw new IllegalArgumentException("Descriptor[] must not be null.");
124		}
125
126		if (descriptors.length == 0) {
127			throw new IllegalArgumentException("Descriptor[] must not be empty.");
128		}
129		int count = 0;
130		for (Descriptor d : descriptors) {
131			if (d == null) {
132				throw new IllegalArgumentException("Descriptor[" + count + "] is null!");
133			}
134			if (!allowedDescritpors.contains(d.getDescriptorId())) {
135				throw new IllegalArgumentException("Descriptor[" + count + "] is is of wrong type, its not allowed: " + d.toString());
136			}
137
138			count++;
139		}
140		this.descriptors = descriptors;
141
142	}
143	
144	
145	
146	
147	
148	/**
149	 * This method cannot be overridden by the derived class. This method
150	 * indicates if the mux token is present or not.
151	 * 
152	 * @return Returns TRUE if the Mux token is present.
153	 */
154	public final boolean isMuxTokenPresent() {
155		return this.muxToken;
156	}
157
158	/**
159	 * This method cannot be overridden by the derived class. This method sets a
160	 * flag to indicate that the mux token is present.
161	 */
162	public final void setMuxToken() {
163		this.muxToken = true;
164	}
165
166	/**
167	 * This method cannot be overridden by the derived class. This method
168	 * indicates if the Modem token is present or not.
169	 * 
170	 * @return Returns TRUE if the Modem token is present.
171	 */
172	public final boolean isModemTokenPresent() {
173		return this.modemTokenPresent;
174	}
175
176	/**
177	 * This method cannot be overridden by the derived class. This method sets a
178	 * flag to indicate that the Modem token is present.
179	 */
180	public final void setModemToken() {
181		this.modemTokenPresent = true;
182	}
183
184	/**
185	 * This method cannot be overridden by the derived class. This method
186	 * indicates if the Media token is present or not.
187	 * 
188	 * @return Returns TRUE if the Media token is present.
189	 */
190	public final boolean isMediaTokenPresent() {
191		return this.mediaToken;
192	}
193
194	/**
195	 * This method cannot be overridden by the derived class. This method sets a
196	 * flag to indicate that the Media token is present.
197	 */
198	public final void setMediaToken() {
199		this.mediaToken = true;
200	}
201	
202	
203	
204	/**
205	 * This method cannot be overridden by the derived class. This method
206	 * indicates if the Signal token is present or not.
207	 * 
208	 * @return Returns TRUE if the Signal token is present.
209	 */
210	public final boolean isSignalTokenPresent() {
211		return this.signalToken;
212	}
213
214	/**
215	 * This method cannot be overridden by the derived class. This method sets a
216	 * flag to indicate that the Signal token is present.
217	 */
218	public final void setSignalToken() {
219		this.signalToken = true;
220	}
221
222	/**
223	 * This method cannot be overridden by the derived class. This method
224	 * indicates if the Event Buffer token is present or not.
225	 * 
226	 * @return Returns TRUE if the Event Buffer token is present.
227	 */
228	public final boolean isEventBuffTokenPresent() {
229		return this.eventBuffToken;
230	}
231
232	/**
233	 * This method cannot be overridden by the derived class. This method sets a
234	 * flag to indicate that the Event Buffer token is present.
235	 */
236	public final void setEventBuffToken() {
237		this.eventBuffToken = true;
238	}
239	
240	
241	
242    /**
243	 * This method cannot be overridden by the derived class. This method
244	 * indicates if the Statistics token is present or not.
245	 * 
246	 * @return Returns TRUE if the Statistics token is present.
247	 */
248	public final boolean isStatsTokenPresent() {
249		return this.statsToken;
250	}
251
252	/**
253	 * This method cannot be overridden by the derived class. This method sets a
254	 * flag to indicate that the Statistics token is present.
255	 */
256	public final void setStatsToken() {
257		this.statsToken = true;
258	}
259
260	/**
261	 * This method cannot be overridden by the derived class. This method
262	 * indicates if the Events token is present or not.
263	 * 
264	 * @return Returns TRUE if the Events token is present.
265	 */
266	public final boolean isEventsTokenPresent() {
267
268		return this.eventsToken;
269	}
270
271	/**
272	 * This method cannot be overridden by the derived class. This method sets a
273	 * flag to indicate that the Events token is present.
274	 */
275	public final void setEventsToken() {
276		this.eventsToken = true;
277	}
278
279	/**
280	 * This method cannot be overridden by the derived class. This method
281	 * indicates if the Observed Event token is present or not.
282	 * 
283	 * @return Returns TRUE if the Observed Event token is present.
284	 */
285	public final boolean isObsEventTokenPresent() {
286		return this.obsEventToken;
287	}
288
289	/**
290	 * This method cannot be overridden by the derived class. This method sets a
291	 * flag to indicate that the Observed Event token is present.
292	 */
293	public final void setObsEventToken() {
294		this.obsEventToken = true;
295	}
296	
297	
298	/**
299	 * This method cannot be overridden by the derived class. This method
300	 * indicates if the digit map token is present or not.
301	 * 
302	 * @returnReturns TRUE if the digit map token is present.
303	 */
304	public final boolean isDigitMapTokenPresent() {
305		return this.digitMapToken;
306	}
307
308	/**
309	 * This method cannot be overridden by the derived class. This method sets a
310	 * flag to indicate that the digit map token is present.
311	 */
312	public final void setDigitMapToken() {
313		this.digitMapToken = true;
314	}
315
316	/**
317	 * This method cannot be overridden by the derived class. This method
318	 * indicates if the Packages token is present or not.
319	 * 
320	 * @return Returns TRUE if the Packages token is present.
321	 */
322	public final boolean isPackagesTokenPresent() {
323		return this.packagesToken;
324	}
325
326	/**
327	 * This method cannot be overridden by the derived class. This method sets a
328	 * flag to indicate that the Packages token is present.
329	 */
330	public final void setPackagesToken() {
331		this.packagesToken = true;
332	}
333}