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