PageRenderTime 80ms CodeModel.GetById 51ms RepoModel.GetById 0ms app.codeStats 1ms

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

http://mobicents.googlecode.com/
Java | 506 lines | 163 code | 46 blank | 297 comment | 24 complexity | c903b8bbe9a5fa329f700f1820087d60 MD5 | raw file
Possible License(s): LGPL-3.0, GPL-3.0, LGPL-2.1, GPL-2.0, CC-BY-SA-3.0, CC0-1.0, Apache-2.0, BSD-3-Clause
  1. package javax.megaco.association;
  2. import javax.megaco.AssociationEvent;
  3. import javax.megaco.ParameterNotSetException;
  4. public class AssociationInd extends AssociationEvent {
  5. protected AssocIndReason assocIndReason = null;
  6. protected LocalAddr localAddr = null;
  7. protected SrvChngReason srvChangeReason = null;
  8. protected LocalAddr srvChngAddress = null;
  9. protected LocalAddr handOffMGCId = null;
  10. protected AssocState assocState = null;
  11. protected SrvChngReason srvChngMethod = null;
  12. protected String srvChngMethodExtension = null;
  13. protected RemoteAddr remoteAddr = null;
  14. protected Integer srvChngDelay = null;
  15. protected Integer protocolVersion = null;
  16. protected String srvChngProfile = null;
  17. protected String parameterExtension = null;
  18. /**
  19. * Constructs an Association Indication Event object.
  20. *
  21. * @param source
  22. * - A reference to the object, the "source", that is logically
  23. * deemed to be the object upon which the Event in question
  24. * initially occurred.
  25. * @param assocHandle
  26. * - The association handle to uniquely identify the MG-MGC pair.
  27. * This is allocated by the stack when the Listener registers
  28. * with the provider with a unique MG-MGC identity.
  29. * @param assocIndReason
  30. * - This indicates the reason for the change in the state of the
  31. * association.
  32. * @throws IllegalArgumentException
  33. * This exception is raised if the reference of Association
  34. * Indication Reason passed to this method is NULL.
  35. */
  36. public AssociationInd(Object source, int assocHandle,
  37. AssocIndReason assocIndReason) throws IllegalArgumentException {
  38. super(source, assocHandle);
  39. if (assocIndReason == null) {
  40. throw new IllegalArgumentException("assocIndReason can not be null");
  41. }
  42. this.assocIndReason = assocIndReason;
  43. }
  44. @Override
  45. public int getAssocOperIdentifier() {
  46. return AssocEventType.M_ASSOC_STATE_IND;
  47. }
  48. /**
  49. * Gets the local entity transport address. The local address specifies the
  50. * transport address which the stack would use to send MEGACO messages to
  51. * peer.
  52. *
  53. * @return Returns the local entity transport address. If the local address
  54. * field is not present, then this method would return NULL.
  55. */
  56. public LocalAddr getLocalAddr() {
  57. return localAddr;
  58. }
  59. /**
  60. * This method sets the local entity identity. The localAddr specifies the
  61. * transport address which the stack would use to send transactions to peer.
  62. *
  63. * @param localAddr
  64. * localAddr - The local entity transport address. Since the
  65. * format of the message header Id is same as that of the
  66. * transport address, the value of this may or may not be
  67. * different from the local entity configured in the user Id as
  68. * specified in the addMegacoListener method of MegacoProvider
  69. * interface.
  70. * @throws IllegalArgumentException
  71. * This exception is raised if the local transport address
  72. * specified is invalid.
  73. */
  74. public void setLocalAddr(LocalAddr localAddr)
  75. throws IllegalArgumentException {
  76. this.localAddr = localAddr;
  77. }
  78. /**
  79. * Gets the integer value which identifies the service change reason. This
  80. * parameter is required on if the application is MG. The MG stack would use
  81. * the same ServiceChange Reason in the ServiceChange command request sent
  82. * to peer MGC.
  83. *
  84. * @return Returns the integer value corresponding to the service change
  85. * reason. If the ServiceChangeReason is not set, then this method
  86. * would return value 0. The possible values are field constants
  87. * defined for the class {@link SrvChngReason}.
  88. */
  89. public int getSrvChangeReason() {
  90. return srvChangeReason == null ? 0 : srvChangeReason
  91. .getSrvChngReasonId();
  92. }
  93. /**
  94. * This method sets the service change reason. This parameter is required on
  95. * if the application is MG. The MG stack would use the same ServiceChange
  96. * Reason in the ServiceChange command request sent to peer MGC.
  97. *
  98. * @param reason
  99. * - The object reference to ServiceChange Reason.
  100. * @throws IllegalArgumentException
  101. * This exception is raised if the reference of Service Change
  102. * Reason passed to this method is NULL.
  103. */
  104. public void setSrvChangeReason(SrvChngReason reason)
  105. throws IllegalArgumentException {
  106. if (reason == null) {
  107. throw new IllegalArgumentException("Change reason can not be null");
  108. }
  109. this.srvChangeReason = reason;
  110. }
  111. /**
  112. * Gets the service change address.
  113. *
  114. * @return Returns the service change address. if the service change address
  115. * is not set, then this method would return NULL.
  116. */
  117. public LocalAddr getSrvChngAddress() {
  118. return srvChngAddress;
  119. }
  120. /**
  121. * This method sets the service change address. The local entity specfied
  122. * earlier is the transport address would be used for initial registration
  123. * and then subsequently, the address specified in the serviceChngAddress
  124. * field would be used for the local transport address. If the application
  125. * is MGC, then on receipt of ServiceChange command (on ROOT termination),
  126. * it will reply with ServiceChangeAddress field in
  127. * serviceChangeReplyDescriptor descriptor, with value as set using this
  128. * method. And If the application is MG, then the stack will send the
  129. * ServiceChange command (on ROOT termination) with ServiceChangeAddress
  130. * field in serviceChangeDescriptor descriptor, with value as set using this
  131. * method.
  132. *
  133. * @param srvChngAddress
  134. * The service change address.
  135. * @throws IllegalArgumentException
  136. * This exception is raised if the service change address
  137. * specified is invalid.
  138. */
  139. public void setSrvChngAddress(LocalAddr srvChngAddress)
  140. throws IllegalArgumentException {
  141. // FIXME: IllegalArgumentException
  142. this.srvChngAddress = srvChngAddress;
  143. }
  144. /**
  145. * Gets the identity of the MGC to which the association is to be handoffed.
  146. * This parameter may be set if the application is MGC.
  147. *
  148. * @return Returns the identity of the MGC to which the association is to be
  149. * handoffed. If the HandedOff MGC Id is missing, then method
  150. * returns NULL.
  151. */
  152. public LocalAddr getHandOffMGCId() {
  153. return handOffMGCId;
  154. }
  155. /**
  156. * This method sets the identity of the MGC to which the association is to
  157. * be handoffed. This parameter may be set if the application is MGC. If
  158. * this parameter is set, then on receipt of service change request from MG
  159. * (with ROOT termination), the stack will reply with MgcIdToTry field in
  160. * serviceChangeDescriptor descriptor, with value as set using this method.
  161. *
  162. * @param handOffMGCId
  163. * The identity of the MGC to which the association is to be
  164. * handoffed.
  165. * @throws IllegalArgumentException
  166. * This exception is raised if the HandedOffMGCId specified is
  167. * invalid.
  168. */
  169. public void setHandOffMGCId(LocalAddr handOffMGCId)
  170. throws IllegalArgumentException {
  171. // FIXME: IllegalArgumentException
  172. this.handOffMGCId = handOffMGCId;
  173. }
  174. // FIXME: jdoc say it returns int, all other methods do....
  175. /**
  176. * Gets the object reference of association state.
  177. *
  178. * @return Returns the integer value of association state. The values of the
  179. * association state are defined in AssocState. The association
  180. * state is to be set mandatorily. If the assoc state field is
  181. * missing, then this method would return NULL.
  182. */
  183. public AssocState getAssociationState() {
  184. return this.assocState;
  185. }
  186. /**
  187. * This method sets the association state. The values of the association
  188. * state are defined in AssocState. The association state is to be set
  189. * mandatorily.
  190. *
  191. * @param associationState
  192. * The object reference of association state.
  193. * @throws IllegalArgumentException
  194. * This exception is raised if the reference of Association
  195. * State passed to this method is NULL.
  196. */
  197. public void setAssociationState(AssocState associationState)
  198. throws IllegalArgumentException {
  199. if (associationState == null) {
  200. throw new IllegalArgumentException("Value can not be null");
  201. }
  202. this.assocState = associationState;
  203. }
  204. /**
  205. * Gets the integer value which identifies the service change method. This
  206. * parameter is required on if the application is MG. The MG stack would use
  207. * the same ServiceChange Method in ServiceChange command request sent to
  208. * peer MGC.
  209. *
  210. * @return Returns the integer value corresponding to the service change
  211. * method. If the ServiceChangeMethod is not set, then this method
  212. * would return value 0. The possible values are field constants
  213. * defined for the class SrvChngMethod.
  214. */
  215. public int getSrvChngMethod() {
  216. return srvChngMethod == null ? 0 : srvChngMethod.getSrvChngReasonId();
  217. }
  218. /**
  219. * This method sets the service change method. This parameter is required on
  220. * if the application is MG. The MG stack would use the same ServiceChange
  221. * Method in ServiceChange command request sent to peer MGC.
  222. *
  223. * @param method
  224. * - The object reference to ServiceChange Method.
  225. * @throws IllegalArgumentException
  226. * This exception is raised if the reference of Service Change
  227. * Reason passed to this method is NULL.
  228. */
  229. public void setSrvChngMethod(SrvChngReason method)
  230. throws IllegalArgumentException {
  231. if (method == null) {
  232. throw new IllegalArgumentException("Change method can not be null");
  233. }
  234. this.srvChngMethod = method;
  235. }
  236. /**
  237. * Gets the string value of the extended service change method.
  238. *
  239. *
  240. * @return Returns string value of the extended service change method. This
  241. * is to be set only if the service change method is set to
  242. * {@link javax.megaco.association.SrvChngMethod.M_EXTENSION}.
  243. * @throws javax.megaco.association.MethodExtensionException
  244. * javax.megaco.association.MethodExtensionException - Thrown if
  245. * service change method has not been set to
  246. * {@link javax.megaco.association.SrvChngMethod.M_EXTENSION}
  247. */
  248. public java.lang.String getSrvChngMethodExtension()
  249. throws javax.megaco.association.MethodExtensionException,
  250. IllegalArgumentException {
  251. if (getSrvChngMethod() != SrvChngMethod.M_EXTENSION) {
  252. throw new MethodExtensionException(
  253. "Changed Method is not equal to {@link javax.megaco.association.SrvChngMethod.M_EXTENSION}");
  254. }
  255. return this.srvChngMethodExtension;
  256. }
  257. /**
  258. * This method sets the extended service change method. This needs to be set
  259. * if and only if the service change method is {@link javax.megaco.association.SrvChngMethod.M_EXTENSION}.
  260. *
  261. * @param extMethod
  262. * - The string value of the extended service change method.
  263. * @throws javax.megaco.association.MethodExtensionException
  264. * - Thrown if service change method has not been set to
  265. * {@link javax.megaco.association.SrvChngMethod.M_EXTENSION}.
  266. * @throws IllegalArgumentException
  267. * - Thrown if extension string does not follow the rules of the
  268. * extension parameter, e.g, should start with X+ or X- etc.
  269. */
  270. public void setSrvChngMethodExtension(java.lang.String extMethod)
  271. throws javax.megaco.association.MethodExtensionException,
  272. IllegalArgumentException {
  273. if (getSrvChngMethod() != SrvChngMethod.M_EXTENSION) {
  274. throw new MethodExtensionException(
  275. "Changed Method is not equal to SrvChngMethod.{@link javax.megaco.association.SrvChngMethod.M_EXTENSION}");
  276. }
  277. // FIXME IllegalArgumentException - Thrown if extension
  278. // string does not follow the rules of the extension parameter, e.g,
  279. // should start with X+ or X- etc.
  280. this.srvChngMethodExtension = extMethod;
  281. }
  282. /**
  283. * Gets the List of remote entity transport address for the User Id. The
  284. * remote address specified in the address to which the stack would send
  285. * MEGACO messages. There is one to one correspondence between the list of
  286. * remote address specified here and the list of remote entity Ids in the
  287. * UserId class. The messages comming from a particular remote entity must
  288. * have same message header Id as the corresponding remote entity Id in
  289. * UserId class.
  290. *
  291. * @return Returns the list of remote entity transport address. If the
  292. * remote address parameter is not present, then this method would
  293. * return NULL.
  294. */
  295. public RemoteAddr getRemoteAddr() {
  296. return remoteAddr;
  297. }
  298. /**
  299. * Sets the list of remote entity identities of the user Id. The remote
  300. * address specified in the address to which the stack would send MEGACO
  301. * messages. There is one to one correspondence between the list of remote
  302. * address specified here and the list of remote entity Ids in the UserId
  303. * class. The messages comming from a particular remote entity must have
  304. * same message header Id as the corresponding remote entity Id in UserId
  305. * class.
  306. *
  307. * @param remoteAddr
  308. * -- List of remote entity transport addresses of the MGC/MG.
  309. * @throws IllegalArgumentException
  310. * This exception is raised if the reference of Remote Address
  311. * passed to this method is NULL.
  312. */
  313. public void setRemoteAddr(RemoteAddr remoteAddr)
  314. throws IllegalArgumentException {
  315. this.remoteAddr = remoteAddr;
  316. }
  317. /**
  318. * Gets the integer value of the delay parameter for the service change.
  319. * This is in milliseconds. This method must be invoked after invoking the
  320. * isSrvChngdelayPresent() method. The stack would use the same as the
  321. * ServiceChangeDelay in the ServiceChange command request sent to peer.
  322. *
  323. * @return Returns the integer value of the delay value in milliseconds.
  324. * @throws javax.megaco.ParameterNotSetException
  325. * This exception is raised if the service change delay
  326. * parameter has not been set.
  327. */
  328. public int getSrvChngDelay() throws javax.megaco.ParameterNotSetException {
  329. if (!isSrvChngDelayPresent()) {
  330. throw new ParameterNotSetException();
  331. }
  332. return this.srvChngDelay;
  333. }
  334. /**
  335. * Sets the integer value of the delay parameter for the service change.
  336. * This is in milliseconds. This automatically sets the service change delay
  337. * value to be present. The stack would use the same as the
  338. * ServiceChangeDelay in the ServiceChange command request sent to peer.
  339. *
  340. *
  341. * @param delay
  342. * - The integer value of the delay value in milliseconds.
  343. * @throws IllegalArgumentException
  344. * This exception is raised if the value of service change delay
  345. * passed to this method is less than 0.
  346. */
  347. public void setSrvChngDelay(int delay)
  348. throws IllegalArgumentException {
  349. if (delay < 0) {
  350. throw new IllegalArgumentException(
  351. "Delay can not be less than zero");
  352. }
  353. this.srvChngDelay = delay;
  354. }
  355. /**
  356. * Returns TRUE if the service change delay parameter is present.
  357. *
  358. * @return TRUE if service change delay parameter has been set, else returns
  359. * FALSE.
  360. */
  361. public boolean isSrvChngDelayPresent() {
  362. return this.srvChngDelay != null;
  363. }
  364. /**
  365. * This method sets the protocol version value that is to be used for the
  366. * specified association.
  367. *
  368. * @param version
  369. * The protocol version as an integer value.
  370. * @throws IllegalArgumentException
  371. * This exception is raised if the value of protocol version
  372. * passed to this method is less than 0.
  373. */
  374. public void setProtocolVersion(int version)
  375. throws IllegalArgumentException {
  376. if (version < 0) {
  377. throw new IllegalArgumentException(
  378. "Value can not be less than zero");
  379. }
  380. this.protocolVersion = version;
  381. }
  382. /**
  383. * Identifies whether the protocol version is present.
  384. *
  385. * @return Returns true if the protocol version is present.
  386. */
  387. public boolean isProtocolVersionPresent() {
  388. return this.protocolVersion != null;
  389. }
  390. /**
  391. * Gets the protocol version value received from peer in the service change.
  392. * This is ther protocol version after negotiation.
  393. *
  394. * @return Returns the protocol version parameter as an integer value.
  395. * @throws javax.megaco.ParameterNotSetException
  396. * This exception is raised if the service change delay has not
  397. * been specified.
  398. */
  399. public int getProtocolVersion()
  400. throws javax.megaco.ParameterNotSetException {
  401. if (!isProtocolVersionPresent()) {
  402. throw new ParameterNotSetException();
  403. }
  404. return this.protocolVersion;
  405. }
  406. /**
  407. * Gets the service change profile value to be sent to peer in the service
  408. * change.
  409. *
  410. * @return Returns the service change profile parameter as a string value.
  411. * If service change profile is not set then a NULL value is
  412. * returned.
  413. */
  414. public java.lang.String getSrvChngProfile() {
  415. return this.srvChngProfile;
  416. }
  417. public void setSrvChngProfile(java.lang.String profile)
  418. throws IllegalArgumentException {
  419. if (profile == null)
  420. throw new IllegalArgumentException("Value can not be null");
  421. this.srvChngProfile = profile;
  422. }
  423. /**
  424. * Gets the string value of the extended service change parameter.
  425. *
  426. * @return Returns string value of the extended service change parameter. If
  427. * the service change parameter is not set then this a NULL value is
  428. * returned.
  429. */
  430. public String getParameterExtension() {
  431. return parameterExtension;
  432. }
  433. /**
  434. * This method sets the extended service change parameter.
  435. *
  436. * @param extMethod
  437. * - The string value of the extended service change parameter.
  438. * @throws IllegalArgumentException
  439. * Thrown if extension string does not follow the rules of the
  440. * extension parameter, e.g, should start with X+ or X- etc.
  441. */
  442. public void setParameterExtension(java.lang.String profile)
  443. throws IllegalArgumentException {
  444. if (profile == null)
  445. throw new IllegalArgumentException("Value can not be null");
  446. // FIXME:IllegalArgumentException - Thrown if extension
  447. // string does not follow the rules of the extension parameter, e.g,
  448. // should start with X+ or X- etc.
  449. this.parameterExtension = profile;
  450. }
  451. /**
  452. * This method returns the reference of the AssocIndReason object as set for
  453. * this class in the constructor.
  454. *
  455. * @return Reference of AssocIndReason object.
  456. */
  457. public AssocIndReason getAssocIndReason() {
  458. return this.assocIndReason;
  459. }
  460. }