/protocols/jain-megaco/megaco-api/src/main/java/javax/megaco/association/DeleteAssocReq.java

http://mobicents.googlecode.com/ · Java · 267 lines · 91 code · 25 blank · 151 comment · 13 complexity · 0b29f4879f399831e81e3fd4a38ce01f MD5 · raw file

  1. package javax.megaco.association;
  2. import java.io.Serializable;
  3. import javax.megaco.AssociationEvent;
  4. import javax.megaco.ParameterNotSetException;
  5. /**
  6. * The class extends JAIN MEGACO Association Events. This represents the delete
  7. * association request event. The event causes the stack initiate assoiation
  8. * teardown procedures with the peer. This would case the stack to send a
  9. * ServiceChange command with specified ServiceChangeMethod (e.g. Forced or
  10. * Graceful) and ServiceChangeReason. After completion of the protocol
  11. * procedure, the association is deleted with the peer and can no more be used
  12. * for exchaging commands with the peer.
  13. */
  14. public class DeleteAssocReq extends AssociationEvent implements Serializable {
  15. protected SrvChngReason srvChangeReason = null;
  16. protected SrvChngReason srvChngMethod = null;
  17. protected LocalAddr srvChngAddress = null;
  18. protected LocalAddr handOffMGCId = null;
  19. protected String srvChngMethodExtension = null;
  20. protected int srvChngDelay = -1;
  21. public DeleteAssocReq(Object source, int assocHandle)
  22. throws IllegalArgumentException {
  23. super(source, assocHandle);
  24. // TODO Auto-generated constructor stub
  25. }
  26. @Override
  27. public int getAssocOperIdentifier() {
  28. return AssocEventType.M_DELETE_ASSOC_REQ;
  29. }
  30. /**
  31. * Gets the integer value which identifies the service change reason. The
  32. * stack would use the same ServiceChange Reason in the ServiceChange
  33. * command request sent to peer.
  34. *
  35. * @return Returns the integer value corresponding to the service change
  36. * reason. If the ServiceChangeReason is not set, then this method
  37. * would return value 0. The possible values are field constants
  38. * defined for the class SrvChngReason.
  39. */
  40. public int getSrvChangeReason() {
  41. return srvChangeReason == null ? 0 : srvChangeReason
  42. .getSrvChngReasonId();
  43. }
  44. /**
  45. * This method sets the service change reason. This parameter is required on
  46. * if the application is MG. The MG stack would use the same ServiceChange
  47. * Reason in the ServiceChange command request sent to peer MGC.
  48. *
  49. * @param reason
  50. * - The object reference to ServiceChange Reason.
  51. * @throws IllegalArgumentException
  52. * This exception is raised if the reference of Service Change
  53. * Reason passed to this method is NULL.
  54. */
  55. public void setSrvChangeReason(SrvChngReason reason)
  56. throws IllegalArgumentException {
  57. if (reason == null) {
  58. throw new IllegalArgumentException("Change reason can not be null");
  59. }
  60. this.srvChangeReason = reason;
  61. }
  62. /**
  63. * Gets the integer value which identifies the service change method. This
  64. * parameter is required on if the application is MG. The MG stack would use
  65. * the same ServiceChange Method in ServiceChange command request sent to
  66. * peer MGC.
  67. *
  68. * @return Returns the integer value corresponding to the service change
  69. * method. If the ServiceChangeMethod is not set, then this method
  70. * would return value 0. The possible values are field constants
  71. * defined for the class SrvChngMethod.
  72. */
  73. public int getSrvChngMethod() {
  74. return srvChngMethod == null ? 0 : srvChngMethod.getSrvChngReasonId();
  75. }
  76. /**
  77. * This method sets the service change method. This parameter is required on
  78. * if the application is MG. The MG stack would use the same ServiceChange
  79. * Method in ServiceChange command request sent to peer MGC.
  80. *
  81. * @param method
  82. * - The object reference to ServiceChange Method.
  83. * @throws IllegalArgumentException
  84. * This exception is raised if the reference of Service Change
  85. * Reason passed to this method is NULL.
  86. */
  87. public void setSrvChngMethod(SrvChngReason method)
  88. throws IllegalArgumentException {
  89. if (method == null) {
  90. throw new IllegalArgumentException("Change method can not be null");
  91. }
  92. this.srvChngMethod = method;
  93. }
  94. /**
  95. * Gets the object reference corresponding to the service change address.
  96. * The stack would use the same ServiceChange Address in the ServiceChange
  97. * command request sent to peer.
  98. *
  99. * @return Returns the service change address. If the service change address
  100. * has not been specified for this class, then this method returns
  101. * NULL.
  102. */
  103. public LocalAddr getSrvChngAddress() {
  104. return srvChngAddress;
  105. }
  106. /**
  107. * This method sets the service change address. The stack would use the same
  108. * ServiceChange Address in the ServiceChange command request sent to peer.
  109. *
  110. * @param srvChngAddress
  111. * - The service change address.
  112. * @throws IllegalArgumentException
  113. * This exception is raised if the service change address
  114. * specified is invalid.
  115. */
  116. public void setSrvChngAddress(LocalAddr srvChngAddress)
  117. throws IllegalArgumentException {
  118. // FIXME: IllegalArgumentException
  119. this.srvChngAddress = srvChngAddress;
  120. }
  121. /**
  122. * Gets the identity of the MGC to which the association is to be handoffed.
  123. * The stack would use the same ServiceChangeMGCId in the ServiceChange
  124. * command request sent to peer.
  125. *
  126. * @return Returns the identity of the MGC to which the association is to be
  127. * handoffed. If HandedOffMGCId is not specified for this class,
  128. * then this method returns NULL.
  129. */
  130. public LocalAddr getHandOffMGCId() {
  131. return handOffMGCId;
  132. }
  133. /**
  134. * This method sets the identity of the MGC to which the association is to
  135. * be handoffed. This method is valid only if the application is MGC. The
  136. * stack would use the same ServiceChangeMGCId in the ServiceChange command
  137. * request sent to peer.
  138. *
  139. *
  140. *
  141. * @param handOffMGCId
  142. * The identity of the MGC to which the association is to be
  143. * handoffed.
  144. * @throws IllegalArgumentException
  145. * This exception is raised if the HandedOffMGCId specified is
  146. * invalid.
  147. */
  148. public void setHandOffMGCId(LocalAddr handOffMGCId)
  149. throws IllegalArgumentException {
  150. // FIXME: IllegalArgumentException
  151. this.handOffMGCId = handOffMGCId;
  152. }
  153. /**
  154. * Gets the string value of the extended service change method.
  155. *
  156. *
  157. * @return Returns string value of the extended service change method. This
  158. * is to be set only if the service change method is set to
  159. * {@link javax.megaco.association.SrvChngMethod.M_EXTENSION}.
  160. * @throws javax.megaco.association.MethodExtensionException
  161. * javax.megaco.association.MethodExtensionException - Thrown if
  162. * service change method has not been set to
  163. * {@link javax.megaco.association.SrvChngMethod.M_EXTENSION}
  164. */
  165. public java.lang.String getSrvChngMethodExtension()
  166. throws javax.megaco.association.MethodExtensionException,
  167. IllegalArgumentException {
  168. if (getSrvChngMethod() != SrvChngMethod.M_EXTENSION) {
  169. throw new MethodExtensionException(
  170. "Changed Method is not equal to SrvChngMethod.{@link javax.megaco.association.SrvChngMethod.M_EXTENSION}");
  171. }
  172. return this.srvChngMethodExtension;
  173. }
  174. /**
  175. * This method sets the extended service change method. This needs to be set
  176. * if and only if the service change method is {@link javax.megaco.association.SrvChngMethod.M_EXTENSION}.
  177. *
  178. * @param extMethod
  179. * - The string value of the extended service change method.
  180. * @throws javax.megaco.association.MethodExtensionException
  181. * - Thrown if service change method has not been set to
  182. * {@link javax.megaco.association.SrvChngMethod.M_EXTENSION}.
  183. * @throws IllegalArgumentException
  184. * - Thrown if extension string does not follow the rules of the
  185. * extension parameter, e.g, should start with X+ or X- etc.
  186. */
  187. public void setSrvChngMethod(java.lang.String extMethod)
  188. throws javax.megaco.association.MethodExtensionException,
  189. IllegalArgumentException {
  190. if (getSrvChngMethod() != SrvChngMethod.M_EXTENSION) {
  191. throw new MethodExtensionException(
  192. "Changed Method is not equal to SrvChngMethod.{@link javax.megaco.association.SrvChngMethod.M_EXTENSION}");
  193. }
  194. // FIXME IllegalArgumentException - Thrown if extension
  195. // string does not follow the rules of the extension parameter, e.g,
  196. // should start with X+ or X- etc.
  197. this.srvChngMethodExtension = extMethod;
  198. }
  199. /**
  200. * Gets the integer value of the delay parameter for the service change.
  201. * This is in milliseconds. This method must be invoked after invoking the
  202. * isSrvChngdelayPresent() method. The stack would use the same as the
  203. * ServiceChangeDelay in the ServiceChange command request sent to peer.
  204. *
  205. * @return Returns the integer value of the delay value in milliseconds.
  206. * @throws javax.megaco.ParameterNotSetException
  207. * This exception is raised if the service change delay
  208. * parameter has not been set.
  209. */
  210. public int getSrvChngDelay() throws javax.megaco.ParameterNotSetException {
  211. if (this.srvChngDelay == -1) {
  212. throw new ParameterNotSetException();
  213. }
  214. return this.srvChngDelay;
  215. }
  216. /**
  217. * Sets the integer value of the delay parameter for the service change.
  218. * This is in milliseconds. This automatically sets the service change delay
  219. * value to be present. The stack would use the same as the
  220. * ServiceChangeDelay in the ServiceChange command request sent to peer.
  221. *
  222. *
  223. * @param delay - The integer value of the delay value in milliseconds.
  224. * @throws IllegalArgumentException This exception is raised if the value of service change delay passed to this method is less than 0.
  225. */
  226. public void setSrvChngDelay(int delay)
  227. throws IllegalArgumentException {
  228. if(delay<0)
  229. {
  230. throw new IllegalArgumentException("Delay can not be less than zero");
  231. }
  232. this.srvChngDelay=delay;
  233. }
  234. /**
  235. * Returns TRUE if the service change delay parameter is present.
  236. * @return TRUE if service change delay parameter has been set, else returns FALSE.
  237. */
  238. public boolean isSrvChngDelayPresent()
  239. {
  240. return this.srvChngDelay!=-1;
  241. }
  242. }