PageRenderTime 28ms CodeModel.GetById 10ms app.highlight 12ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://mobicents.googlecode.com/
Java | 134 lines | 45 code | 16 blank | 73 comment | 5 complexity | 367b6c39b161cde95ad2360356e791b2 MD5 | raw file
  1package javax.megaco.message;
  2
  3import java.io.Serializable;
  4
  5import javax.megaco.ExceptionInfoCode;
  6
  7import javax.megaco.ParameterNotSetException;
  8import javax.megaco.message.descriptor.TopologyDescriptor;
  9
 10/**
 11 * The Context Parameter object is a class that shall be used to set the context
 12 * level parameters i.e., topology descriptor, priority, and whether emergency
 13 * is active or not. This is an independent class derived from java.util.Object
 14 * and shall not have any derived classes
 15 * 
 16 * 
 17 */
 18public class ContextParam implements Serializable {
 19	private boolean isEMPresent;
 20	private TopologyDescriptor[] topologyDescriptors = null;
 21	private boolean isPriorityPresent;
 22	private int priority;
 23
 24	/**
 25	 * Constructs a class that shall specify the context level parameters.
 26	 */
 27	public ContextParam() {
 28
 29	}
 30
 31	/**
 32	 * The method can be used to check if emergency is present as a part of the
 33	 * context level parameters. By default, if the setEM() method has not been
 34	 * invoked, then this method should return FALSE to indicate that Emeregency
 35	 * is not present.
 36	 * 
 37	 * @return Returns true if Emergency is present.
 38	 */
 39	public boolean isEMPresent() {
 40		return this.isEMPresent;
 41	}
 42
 43	/**
 44	 * Gets the object refernces of all the topology descriptors specified for
 45	 * this context.
 46	 * 
 47	 * @return The vector of the reference to the object identifier of type
 48	 *         topology descriptor information.
 49	 */
 50	public TopologyDescriptor[] getTopologyDescriptor() {
 51		return this.topologyDescriptors;
 52
 53	}
 54
 55	/**
 56	 * The method can be used to check if the prority value is specified for
 57	 * this context.
 58	 * 
 59	 * @return Returns true if priority is present. The function is called prior
 60	 *         to getPriority function to check if priroty is present.
 61	 */
 62	public boolean isPriorityPresent() {
 63		return this.isPriorityPresent;
 64	}
 65
 66	/**
 67	 * The method can be used to get the prority value specified for this
 68	 * context. Before invoking this method, isPriorityPresent method must be
 69	 * invoked to verify the presence of priority field in the class object.
 70	 * 
 71	 * @return Returns the priority value specified for this context.
 72	 * @throws javax.megaco.ParameterNotSetException
 73	 *             : This exception is raised if the priority is not set and the
 74	 *             get method is invoked.
 75	 */
 76	public int getPriority() throws javax.megaco.ParameterNotSetException {
 77		if (!this.isPriorityPresent) {
 78			throw new ParameterNotSetException("Priority not set for ContextParam");
 79		}
 80		return this.priority;
 81	}
 82
 83	/**
 84	 * The method can be used to set if the EM is present as a part of the
 85	 * context level parameters.
 86	 * 
 87	 * @param isEMPresent
 88	 *            - The boolean value to indicate if the emergency is present as
 89	 *            a part of the context level parameters.
 90	 */
 91	public void setEM(boolean isEMPresent) {
 92		this.isEMPresent = isEMPresent;
 93	}
 94
 95	/**
 96	 * The method can be used to set the priority value for this context.
 97	 * 
 98	 * @param priority
 99	 *            priority - Integer value of the priority that shall be set.
100	 *            The only valid values specified by the protocol for this
101	 *            parameters is between 0 to 15.
102	 * @throws IllegalArgumentException
103	 *             : The valid values of priority ranges between 0 to 15. If any
104	 *             value other than this is set then the exception is raised.
105	 */
106	public void setPriority(int priority) throws IllegalArgumentException {
107		if (priority < 0 || priority > 15) {
108			IllegalArgumentException invalidArgumentException = new IllegalArgumentException("The priority for Contextparam should be between 0 and 15. The value passed is = " + priority);
109
110			// invalidArgumentException.setInfoCode(ExceptionInfoCode.INV_PRIORITY_VAL);
111			throw invalidArgumentException;
112		}
113		this.priority = priority;
114	}
115
116	/**
117	 * Sets the vector of Topology Descriptor Information for this command.
118	 * 
119	 * @param topologyDescriptor
120	 *            The vector of reference to the object identifier of type
121	 *            topology descriptor information
122	 * @throws IllegalArgumentException
123	 *             : This exception is raised if the reference of Topology
124	 *             Descriptor passed to this method is NULL.
125	 */
126	public void setTopologyDescriptor(TopologyDescriptor topologyDescriptor[]) throws IllegalArgumentException {
127		if (topologyDescriptor == null) {
128			IllegalArgumentException invalidArgumentException = new IllegalArgumentException("The TopologyDescriptor[] cannot be null for ContextParam");
129			throw invalidArgumentException;
130		}
131		this.topologyDescriptors = topologyDescriptor;
132	}
133
134}