PageRenderTime 58ms CodeModel.GetById 53ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/protocols/jain-megaco/megaco-api/src/main/java/javax/megaco/message/descriptor/CntxtTermAudDescriptor.java

http://mobicents.googlecode.com/
Java | 117 lines | 43 code | 16 blank | 58 comment | 10 complexity | 4de3968af48133ad323b04ae55bede0c MD5 | raw file
  1package javax.megaco.message.descriptor;
  2
  3import java.io.Serializable;
  4
  5
  6import javax.megaco.MethodInvocationException;
  7import javax.megaco.message.Descriptor;
  8import javax.megaco.message.DescriptorType;
  9import javax.megaco.message.Termination;
 10
 11/**
 12 * The class extends JAIN MEGACO Descriptor. This class describes the Context
 13 * termination audit descriptor.
 14 */
 15public class CntxtTermAudDescriptor extends Descriptor implements Serializable {
 16
 17	private ErrorDescriptor errorDescriptor;
 18	private Termination[] terminationList;
 19
 20	/**
 21	 * Constructs an Context Termination Descriptor object. This extends the
 22	 * Descriptor class.
 23	 */
 24	public CntxtTermAudDescriptor() {
 25		super.descriptorId = DescriptorType.M_CTX_TERM_AUDIT_DESC;
 26	}
 27
 28	/**
 29	 * This method returns that the descriptor identifier is of type descriptor
 30	 * Context Termination Audit. This method overrides the corresponding method
 31	 * of the base class Descriptor.
 32	 * 
 33	 * @return Returns an integer value that identifies this object as the type
 34	 *         of Context Termination Audit descriptor. It returns the value
 35	 *         M_CTX_TERM_AUDIT_DESC for a Context Termination Audit Descriptor.
 36	 */
 37	public int getDescriptorId() {
 38		return super.descriptorId;
 39	}
 40
 41	/**
 42	 * This method returns that the descriptor info of type Error descriptor.
 43	 * 
 44	 * @return Returns an descriptor info that identifies this object as the
 45	 *         type of Error descriptor. It returns that it is Error Descriptor
 46	 *         i.e., M_ERROR_DESC. If the descriptor is absent in the command,
 47	 *         then method would return NULL.
 48	 */
 49	public ErrorDescriptor getErrorDescriptor() {
 50		return this.errorDescriptor;
 51	}
 52
 53	/**
 54	 * This method is used to get the list of the termination Ids.
 55	 * 
 56	 * @return The function returns vector of the Termination. If the descriptor
 57	 *         is absent in the command, then method would return NULL.
 58	 */
 59	public Termination[] getTerminationIdList() {
 60		return this.terminationList;
 61	}
 62
 63	/**
 64	 * This method sets the Megaco Error descriptor.
 65	 * 
 66	 * @param errorDescriptor
 67	 *            - Megaco Error descriptor to be set for this command.
 68	 * @throws IllegalArgumentException
 69	 *             - Thrown if an invalid descriptor is set.
 70	 * @throws IllegalStateException
 71	 *             - Thrown if the Termination Id list has already been
 72	 *             specified for this command. The object of this class can have
 73	 *             either error descriptor or termination Id list associated
 74	 *             with it and not both.
 75	 */
 76	public void setErrorDescriptor(ErrorDescriptor errorDescriptor) throws IllegalArgumentException, IllegalStateException {
 77		if (errorDescriptor == null) {
 78			throw new IllegalArgumentException("ErrorDescriptor must not be null.");
 79		}
 80
 81		if (this.terminationList != null) {
 82			throw new IllegalStateException("ErrorDescriptor must not be set when Termination[] is present");
 83		}
 84
 85		this.errorDescriptor = errorDescriptor;
 86	}
 87
 88	/**
 89	 * The method is used to set the Megaco Termination Id List.
 90	 * 
 91	 * @param termIdList
 92	 *            - Vector of Megaco terminationId descriptor to be set for this
 93	 *            command.
 94	 * @throws IllegalArgumentException
 95	 *             - Thrown if an invalid descriptor is set.
 96	 * @throws IllegalStateException
 97	 *             - Thrown if the error descriptor has already been specified
 98	 *             for this command. The object of this class can have either
 99	 *             error descriptor or termination Id list associated with it
100	 *             and not both.
101	 */
102	public void setTerminationId(Termination[] termIdList) throws IllegalArgumentException, IllegalStateException {
103		if (termIdList == null) {
104			throw new IllegalArgumentException("Termination[] must not be null.");
105		}
106
107		if (termIdList.length == 0) {
108			throw new IllegalArgumentException("Termination[] must not be empty.");
109		}
110
111		if (this.errorDescriptor != null) {
112			throw new IllegalStateException("Termination[] must not be set when ErrorDescriptor is present");
113		}
114
115		this.terminationList = termIdList;
116	}
117}