PageRenderTime 20ms CodeModel.GetById 11ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

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

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