PageRenderTime 67ms CodeModel.GetById 54ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://mobicents.googlecode.com/
Java | 330 lines | 102 code | 49 blank | 179 comment | 19 complexity | 21ad34c5476fa79b3da92d0ca9e2e842 MD5 | raw file
  1package javax.megaco.message.descriptor;
  2
  3import java.io.Serializable;
  4
  5
  6import javax.megaco.ParameterNotSetException;
  7import javax.megaco.association.LocalAddr;
  8import javax.megaco.association.SrvChngMethod;
  9import javax.megaco.association.SrvChngReason;
 10import javax.megaco.message.Descriptor;
 11import javax.megaco.message.DescriptorType;
 12
 13/**
 14 * The class extends JAIN MEGACO Descriptor. This class represents the service
 15 * change response descriptor of the MEGACO protocol. This descriptor describes
 16 * the service change address, mgcId, profile and version in the service change
 17 * response descriptor.
 18 */
 19public class SrvChngRespDescriptor extends Descriptor implements Serializable {
 20
 21	private LocalAddr srvChngAddress;
 22	private LocalAddr handOffMGCId;
 23	private String srvChngProfile;
 24	private String timeValue;
 25	private String dateValue;
 26	private Integer protocolVersion;
 27
 28	
 29	//FIXME: this is not present:
 30	private SrvChngMethod srvChngMethod;
 31	/**
 32	 * Constructs a SrvChng Response Descriptor which would conatin atleast one
 33	 * of service change address, mgcid, profile and version in service change
 34	 * resonse descriptor.
 35	 */
 36	public SrvChngRespDescriptor() {
 37		super.descriptorId = DescriptorType.M_SERVICE_CHANGE_RESP_DESC;
 38	}
 39	
 40	/**
 41	 * Constructs a SrvChng Response Descriptor which would conatin atleast one
 42	 * of service change address, mgcid, profile and version in service change
 43	 * resonse descriptor.
 44	 * @param  srvChngReason - sets srvc chng reason.
 45	 */
 46	public SrvChngRespDescriptor(SrvChngMethod srvChngMethod) {
 47		super.descriptorId = DescriptorType.M_SERVICE_CHANGE_RESP_DESC;
 48		this.srvChngMethod = srvChngMethod;
 49	}
 50
 51	/**
 52	 * This method cannot be overridden by the derived class. This method
 53	 * returns that the descriptor identifier is of type descriptor
 54	 * SrvChngResponse. This method overrides the corresponding method of the
 55	 * base class Descriptor.
 56	 * 
 57	 * @return Returns an integer value that identifies this service change
 58	 *         object as the type of service change descriptor. It returns that
 59	 *         it is SrvChng response Descriptor i.e.,
 60	 *         M_SERVICE_CHANGE_RESP_DESC.
 61	 */
 62	public int getDescriptorId() {
 63		return super.descriptorId;
 64	}
 65
 66	
 67	/**
 68	 * Gets the service change address. If the service change command has been
 69	 * received from peer, then it refers to the the new transport address the
 70	 * peer intends to use subsequently.
 71	 * 
 72	 * @return Returns the service change address. If the service change address
 73	 *         is missing, then the method would return NULL.
 74	 */
 75	public LocalAddr getSrvChngAddress() {
 76		return this.srvChngAddress;
 77	}
 78
 79	/**
 80	 * This method sets the service change address. This is not a mandatory
 81	 * parameter.
 82	 * 
 83	 * @param LocalAddr
 84	 *            The object reference of service change address.
 85	 * @throws IllegalArgumentException
 86	 *             - Thrown if a parameter in service change address is set such
 87	 *             that it is invalid.
 88	 */
 89	public void setSrvChngAddress(LocalAddr localAddr) throws IllegalArgumentException {
 90
 91		// FIXME: not present in jdoc
 92		if (localAddr == null) {
 93			throw new IllegalArgumentException("LocalAddr must not be null.");
 94		}
 95		// FIXME: add error checks?
 96
 97		this.srvChngAddress = localAddr;
 98
 99	}
100	
101	/**
102	 * Gets the identity of the MGC to which the association is to be handoffed.
103	 * As specified in the protocol, in case of failure of MGC, it would handoff
104	 * the control of the MG to the new MGC. This is conveyed using service
105	 * change command on ROOT termination, with service change method set to
106	 * M_HANDOFF and transport parameters of the new MGC
107	 * specified in the mgcidToTry field of the service change descriptor. This
108	 * mgcidToTry field of the service change descriptor is represented using
109	 * HandedOffMGCId field on this class.
110	 * 
111	 * @return Returns the identity of the MGC to which the association is to be
112	 *         handoffed.
113	 */
114	public LocalAddr getHandOffMGCId() {
115		return this.handOffMGCId;
116	}
117
118	/**
119	 * This method sets the identity of the MGC to which the association is to
120	 * be handoffed.
121	 * 
122	 * As specified in the protocol, in case of failure of MGC, it would handoff
123	 * the control of the MG to the new MGC. This is conveyed using service
124	 * change command on ROOT termination, with service change method set to
125	 * M_HANDOFF and transport parameters of the new MGC
126	 * specified in the mgcidToTry field of the service change descriptor. This
127	 * mgcidToTry field of the service change descriptor is represented using
128	 * HandedOffMGCId field on this class.
129	 * 
130	 * @param mgcidToTry
131	 *            The identity of the MGC to which the association is to be
132	 *            handoffed.
133	 * @throws IllegalArgumentException
134	 *             - Thrown if a parameter in mgc Id is set such that it is
135	 *             invalid.
136	 */
137	public void setHandOffMGCId(LocalAddr mgcidToTry) throws IllegalArgumentException {
138
139		// FIXME: not present in jdoc
140		if (mgcidToTry == null) {
141			throw new IllegalArgumentException("LocalAddr must not be null.");
142		}
143
144		if (srvChngMethod == null || srvChngMethod.getSrvChngMethodId() != srvChngMethod.M_HANDOFF) {
145			throw new IllegalArgumentException("SrvChngMethodId must be set to: SVC_CHNG_METHOD_HANDOFF.");
146		}
147
148		// FIXME: add error checks?
149		this.handOffMGCId = mgcidToTry;
150
151	}
152	
153	
154	/**
155	 * Gets the service change profile value received from peer in the service
156	 * change.
157	 * 
158	 * @return Returns the service change profile parameter as a string value.
159	 *         If the service change profile is not set then it returns a NULL
160	 *         value.
161	 */
162	public java.lang.String getSrvChngProfile() {
163		return this.srvChngProfile;
164	}
165
166	/**
167	 * This method sets the service change profile value.
168	 * 
169	 * @param profile
170	 *            The service change profile as a string value.
171	 * @throws IllegalArgumentException
172	 *             - Thrown if service change profile parameter has invalid
173	 *             format.
174	 */
175	public void setSrvChngProfile(java.lang.String profile) throws IllegalArgumentException {
176		if (profile == null) {
177			throw new IllegalArgumentException("profile must not be null.");
178		}
179
180		DescriptorUtils.checkSrvcChngProfileRules(profile);
181
182		this.srvChngProfile = profile;
183	}
184	
185	/**
186	 * Gets the protocol version value received from peer in the service change.
187	 * This is ther protocol version after negotiation.
188	 * 
189	 * @return Returns the protocol version parameter as an integer value.
190	 * @throws javax.megaco.ParameterNotSetException
191	 *             - Thrown if protocol version has not been set.
192	 */
193	public int getProtocolVersion() throws javax.megaco.ParameterNotSetException {
194		if (!isProtocolVersionPresent()) {
195			throw new ParameterNotSetException("Protocol Version has not been set.");
196		}
197
198		return this.protocolVersion.intValue();
199	}
200
201	/**
202	 * This method sets the protocol version value.
203	 * 
204	 * @param version
205	 *            The protocol version as an integer value.
206	 * @throws IllegalArgumentException
207	 *             - Thrown if service change version parameter is less than or
208	 *             equal to 0.
209	 */
210	public void setProtocolVersion(int version) throws IllegalArgumentException {
211
212		if (version <= 0) {
213			throw new IllegalArgumentException("Protocol Version must be greater than zero.");
214		}
215
216		this.protocolVersion = new Integer(version);
217
218	}
219
220	/**
221	 * Identifies whether the protocol version is present.
222	 * 
223	 * @return Returns true if the protocol version is present.
224	 */
225	public boolean isProtocolVersionPresent() {
226		return this.protocolVersion != null;
227	}
228	
229	
230	
231	/**
232	 * Gets the string value of the date value of timestamp in service change
233	 * descriptor.
234	 * 
235	 * @return Returns string value of the date value of timestamp in service
236	 *         change. If the date value of timestamp in service change is not
237	 *         set then a NULL value is returned.
238	 */
239	public java.lang.String getDateValue() {
240		return this.dateValue;
241	}
242
243	/**
244	 * This method sets the date value of timestamp in service change
245	 * descriptor.
246	 * 
247	 * @param dateValue
248	 *            The string value of the date value of timestamp in service
249	 *            change descriptor.
250	 * @throws IllegalArgumentException
251	 *             - Thrown if date value of timestamp in service change
252	 *             descriptor is not of 8 digit length.
253	 */
254	public void setDateValue(java.lang.String dateValue) throws IllegalArgumentException {
255
256		if (dateValue == null) {
257			new IllegalArgumentException("DateValue must nto be null.");
258		}
259
260		DescriptorUtils.checkTimeStampRules(dateValue);
261		this.dateValue = dateValue;
262	}
263
264	/**
265	 * Gets the string value of the time value of timestamp in service change
266	 * descriptor.
267	 * 
268	 * @return Returns string value of the time value of timestamp in service
269	 *         change descriptor. If the time value of timestamp in service
270	 *         change descriptor is not set then a NULL value is returned.
271	 */
272	public java.lang.String getTimeValue() {
273		return this.timeValue;
274	}
275
276	/**
277	 * This method sets the time value of timestamp in service change
278	 * descriptor.
279	 * 
280	 * @param timeValue
281	 *            The string value of the time value of timestamp in service
282	 *            change descriptor.
283	 * @throws IllegalArgumentException
284	 *             - Thrown if time value of timestamp in service change
285	 *             descriptor is not of 8 digit length.
286	 */
287	public void setTimeValue(java.lang.String timeValue) throws IllegalArgumentException {
288
289		if (timeValue == null) {
290			new IllegalArgumentException("TimeValue must nto be null.");
291		}
292
293		DescriptorUtils.checkTimeStampRules(timeValue);
294		this.timeValue = timeValue;
295	}
296	
297	
298	/**
299	 * Gets the integer value which identifies the service change method.
300	 * 
301	 * @return Returns the integer value of service change method. The values of
302	 *         the service change method are defined in SrvChngMethod. The
303	 *         service change method is to be mandatorily set. If Service Change
304	 *         method is not set then this method would return null.
305	 */
306	public SrvChngMethod getSrvChngMethod() {
307		return this.srvChngMethod;
308	}
309
310	/**
311	 * This method sets the service change method. The values of the service
312	 * change method are defined in SrvChngMethod. The service change method is
313	 * to be mandatorily set.
314	 * 
315	 * @param method
316	 *            The object reference of service change method.
317	 * @throws IllegalArgumentException
318	 *             : This exception is raised if the reference of Service Change
319	 *             Method passed to this method is NULL.
320	 */
321	public void setSrvChngMethod(SrvChngMethod method) throws IllegalArgumentException {
322		if (method == null) {
323			throw new IllegalArgumentException("SrvChngMethod must not be null.");
324		}
325
326		this.srvChngMethod = method;
327	}
328	
329	
330}