PageRenderTime 22ms CodeModel.GetById 18ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://mobicents.googlecode.com/
Java | 98 lines | 32 code | 15 blank | 51 comment | 3 complexity | e316838e9fc7506795ab267afafb76b1 MD5 | raw file
 1package javax.megaco.message.descriptor;
 2
 3
 4import javax.megaco.ParameterNotSetException;
 5import javax.megaco.message.Descriptor;
 6import javax.megaco.message.DescriptorType;
 7
 8/**
 9 * The class extends JAIN MEGACO Descriptor. This class describes the Event
10 * descriptor of the MEGACO protocol.
11 * 
12 * 
13 */
14public class EventDescriptor extends Descriptor {
15
16	private int requestId;
17	private RequestedEventParam[] requestedEventParam = null;
18
19	/**
20	 * Constructs a Event Descriptor with specific request identifier.
21	 * 
22	 * @param requestId
23	 *            requestId - An integer value specifying the request
24	 *            identifier, which uniquely identifies the event.
25	 * @throws IllegalArgumentException
26	 *             : This exception is raised if the value of request identifier
27	 *             passed to this method is less than 0.
28	 */
29	public EventDescriptor(int requestId) throws IllegalArgumentException {
30		if (requestId < 0) {
31			IllegalArgumentException invalidArgumentException = new IllegalArgumentException("requestId cannot be less than 0 for EventDescriptor");
32
33			// TODO set ExceptionInfoCode ?
34			throw invalidArgumentException;
35		}
36		this.requestId = requestId;
37		super.descriptorId = DescriptorType.M_EVENT_DESC;
38	}
39
40	/**
41	 * This method cannot be overridden by the derived class. This method
42	 * returns that the descriptor identifier is of type descriptor Event. This
43	 * method overrides the corresponding method of the base class Descriptor.
44	 */
45	@Override
46	public final int getDescriptorId() {
47		return super.descriptorId;
48	}
49
50	/**
51	 * This method cannot be overridden by the derived class. This method
52	 * returns an integer value identifying the RequestID field of the event
53	 * descriptor.
54	 * 
55	 * @return Returns an integer value that identifies request identifier which
56	 *         uniquely identifies the event descriptor.
57	 */
58	public final int getRequestId() {
59		return this.requestId;
60	}
61
62	/**
63	 * This method sets the Requested Event Params field of the event
64	 * descriptor.
65	 * 
66	 * @param requestedParam
67	 *            - Sets the requested params. There can be multiple requested
68	 *            parameters set, but atleaset one should be present.
69	 * @throws IllegalArgumentException
70	 *             : This exception is raised if the reference of request event
71	 *             params as passed to this method is NULL.
72	 */
73	public final void setRequestedEventParam(RequestedEventParam[] requestedParam) throws IllegalArgumentException {
74
75		// FIXME: add zero length check?
76		if (requestedParam == null) {
77
78			throw new IllegalArgumentException();
79		}
80
81		this.requestedEventParam = requestedParam;
82	}
83
84	/**
85	 * This method gets the Request Events Params field of the event descriptor.
86	 * This method returns vector of objects of type RequsetedEventParams.
87	 * 
88	 * @return Returns the vector of the request event params. If requested
89	 *         event parameter has not been set for the event descriptor, then
90	 *         this method would return NULL.
91
92	 */
93	public final RequestedEventParam[] getRequestedEventParam() {
94
95		return this.requestedEventParam;
96	}
97
98}