PageRenderTime 34ms CodeModel.GetById 25ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 1ms

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

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