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

http://mobicents.googlecode.com/ · Java · 104 lines · 38 code · 12 blank · 54 comment · 12 complexity · 1c345fdd46879c6d847b8ffe7dd4c77a MD5 · raw file

  1. package javax.megaco.association;
  2. import javax.megaco.AssociationEvent;
  3. import javax.megaco.ErrorCode;
  4. import javax.megaco.MethodInvocationException;
  5. import javax.megaco.ReturnStatus;
  6. public class DeleteAssocResp extends AssociationEvent {
  7. protected ReturnStatus eventStatus = null;
  8. protected ErrorCode errorCode = null;
  9. public DeleteAssocResp(Object source, int assocHandle) throws IllegalArgumentException {
  10. super(source, assocHandle);
  11. }
  12. @Override
  13. public final int getAssocOperIdentifier() {
  14. return AssocEventType.M_DELETE_ASSOC_RESP;
  15. }
  16. /**
  17. * This method returns whether the execution of create association request
  18. * was success or not.
  19. *
  20. * @return Returns an integer value that identifies whether the delete
  21. * association event issued earlier could be performed successfuly
  22. * or not. The values are field constants defined in class
  23. * ReturnStatus. If the returnStatus is not set, then this method
  24. * would return value null.
  25. */
  26. public final ReturnStatus getEventStatus() {
  27. // return eventStatus == null ? 0 : eventStatus.getReturnStatus();
  28. return eventStatus;
  29. }
  30. /**
  31. * This method sets the status of whether the execution of the create
  32. * association request was success or not.
  33. *
  34. * @param returnStatus
  35. * - The return status of the processing of the create
  36. * association event. The static object corresponding to the
  37. * return status which are one of the derived classes of the
  38. * ReturnStatus shall be set.
  39. * @throws IllegalArgumentException
  40. * This exception is raised if the reference of Return Status
  41. * passed to this method is NULL.
  42. */
  43. public final void setEventStatus(ReturnStatus returnStatus) throws IllegalArgumentException {
  44. if (returnStatus == null)
  45. throw new IllegalArgumentException("Event status can not be null.");
  46. this.eventStatus = returnStatus;
  47. }
  48. /**
  49. * This method returns the error code qualifying why the create association
  50. * event could not be processed successfuly.
  51. *
  52. * @return Returns an integer value that identifies the error code
  53. * specifying why the execution of the create association event
  54. * could not be successful. The possible values are field constants
  55. * defined for the class ErrorCode. If the error code is not set,
  56. * then this method would return value 0.
  57. *
  58. * @throws IllegalStateException
  59. * - This exception would be raised if the return status is set
  60. * to M_SUCCESS, the error code is not set and hence should not
  61. * invoke this method.
  62. */
  63. public final ErrorCode getErrorCode() throws IllegalStateException {
  64. if (getEventStatus() == null || getEventStatus().getReturnStatus() == ReturnStatus.M_SUCCESS) {
  65. throw new IllegalStateException("Event status is success or not set, error code is not premited.");
  66. }
  67. // return errorCode == null ? 0 : errorCode.getErrorCode();
  68. return errorCode;
  69. }
  70. /**
  71. * This method sets the error code specifying why the delete association
  72. * event could not be executed successfuly.
  73. *
  74. * @param errorCode
  75. * - The error code correspondingto why the delete association
  76. * event could not be executed successfuly.
  77. * @throws IllegalArgumentException
  78. * This exception would be raised in following conditions <br>
  79. * 1. If the return status is not set to M_FAILURE, the error
  80. * code should not be set. <br>
  81. * 2. If the error code is not valid for the DeleteAssocReq
  82. * class.
  83. */
  84. public final void setErrorCode(ErrorCode errorCode) throws IllegalArgumentException {
  85. if (errorCode == null)
  86. throw new IllegalArgumentException("Error code can not be null.");
  87. if (getEventStatus() == null || getEventStatus().getReturnStatus() != ReturnStatus.M_FAILURE) {
  88. throw new IllegalArgumentException("Event status is not failure or nto set, error code is not premited.");
  89. }
  90. this.errorCode = errorCode;
  91. }
  92. }