/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

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