PageRenderTime 16ms CodeModel.GetById 11ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

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

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