PageRenderTime 25ms CodeModel.GetById 11ms app.highlight 10ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://mobicents.googlecode.com/
Java | 181 lines | 64 code | 19 blank | 98 comment | 9 complexity | 797afadd579dce16f0b0fd0472b5985a MD5 | raw file
  1package javax.megaco.message.descriptor;
  2
  3import java.io.Serializable;
  4
  5
  6import javax.megaco.ParameterNotSetException;
  7
  8/**
  9 * The DigitMapValue object is a class that shall be used to set the digit map
 10 * within the digit map descriptor. The DigitMap value class contains
 11 * information about the dial plan. This may also contains special symbols like
 12 * wildcards and timer values to be used on application of the dial plan. This
 13 * is an independent class derived from java.util.Object and shall not have any
 14 * derived classes.
 15 */
 16public class DigitMapValue implements Serializable {
 17
 18	private Integer timerT, timerL, timerS;
 19	private DigitMapString[] digitMapString = null;
 20
 21	/**
 22	 * Constructs a Digit Map Value Object. This shall contain information about
 23	 * the digit string in the dial plan.
 24	 */
 25	public DigitMapValue() {
 26		super();
 27		// TODO Auto-generated constructor stub
 28	}
 29
 30	/**
 31	 * This method specifies whether the timer T value is present or not.
 32	 * 
 33	 * @return TRUE if the timer T value is present.
 34	 */
 35	public boolean isTimerTPresent() {
 36		return this.timerT != null;
 37	}
 38
 39	/**
 40	 * The method gets the timer T value.This method should be invoked after
 41	 * verifying using method isTimerTPresent() that the timer T value has been
 42	 * set.
 43	 * 
 44	 * @return The integer value for the timer value if it is set.
 45	 * @throws javax.megaco.ParameterNotSetException
 46	 *             - if isTimerTPresent() returns FALSE.
 47	 */
 48	public int getTimerTValue() throws javax.megaco.ParameterNotSetException {
 49		if (!this.isTimerTPresent()) {
 50			throw new ParameterNotSetException("Timer value has not been set.");
 51		}
 52		return this.timerT.intValue();
 53	}
 54
 55	/**
 56	 * The method sets the timer T value.
 57	 * 
 58	 * @param timerT
 59	 *            The integer value for the timer value. This automatically sets
 60	 *            the isTimerTPresent() to TRUE.
 61	 * @throws IllegalArgumentException
 62	 *             - if timer value is not correctly set.
 63	 */
 64	public void setTimerTValue(int timerT) throws IllegalArgumentException {
 65		if (timerT <= 0) {
 66			new IllegalArgumentException("Timer value must not be less or equal to zero");
 67		}
 68		this.timerT = timerT;
 69	}
 70
 71	/**
 72	 * This method specifies whether the timer S value is present or not.
 73	 * 
 74	 * @return TRUE if the timer S value is present.
 75	 */
 76	public boolean isTimerSPresent() {
 77		return this.timerS != null;
 78	}
 79
 80	/**
 81	 * The method gets the timer S value. This method should be invoked after
 82	 * verifying using method isTimerSPresent() that the timer S value has been
 83	 * set.
 84	 * 
 85	 * @return The integer value for the timer value if it is set.
 86	 * @throws javax.megaco.ParameterNotSetException
 87	 *             - if isTimerSPresent() returns FALSE.
 88	 */
 89	public int getTimerSValue() throws javax.megaco.ParameterNotSetException {
 90		if (!this.isTimerSPresent()) {
 91			throw new ParameterNotSetException("Timer value has not been set.");
 92		}
 93		return this.timerS.intValue();
 94	}
 95
 96	/**
 97	 * The method sets the timer S value.
 98	 * 
 99	 * @param timerS
100	 *            The integer value for the timer value. This automatically sets
101	 *            the isTimerSPresent() to TRUE.
102	 * @throws IllegalArgumentException
103	 *             - if timer value is not correctly set.
104	 */
105	public void setTimerSValue(int timerS) throws IllegalArgumentException {
106		if (timerS <= 0) {
107			new IllegalArgumentException("Timer value must not be less or equal to zero");
108		}
109		this.timerS = timerS;
110	}
111
112	/**
113	 * This method specifies whether the timer L value is present or not.
114	 * 
115	 * @return TRUE if the timer L value is present.
116	 */
117	public boolean isTimerLPresent() {
118		return this.timerL != null;
119	}
120
121	/**
122	 * The method gets the timer L value. This method should be invoked after
123	 * verifying using method isTimerLPresent() that the timer L value has been
124	 * set.
125	 * 
126	 * @return The integer value for the timer value if it is set.
127	 * @throws javax.megaco.ParameterNotSetException
128	 *             - if isTimerLPresent() returns FALSE.
129	 */
130	public int getTimerLValue() throws javax.megaco.ParameterNotSetException {
131		if (!this.isTimerLPresent()) {
132			throw new ParameterNotSetException("Timer value has not been set.");
133		}
134		return this.timerL.intValue();
135	}
136
137	/**
138	 * The method sets the timer L value.
139	 * 
140	 * @param timerL
141	 *            The integer value for the timer value. This automatically sets
142	 *            the isTimerLPresent() to TRUE.
143	 * @throws IllegalArgumentException
144	 *             - if timer value is not correctly set.
145	 */
146	public void setTimerLValue(int timerL) throws IllegalArgumentException {
147		if (timerL <= 0) {
148			new IllegalArgumentException("Timer value must not be less or equal to zero");
149		}
150		this.timerL = timerL;
151	}
152
153	/**
154	 * The method is used to get the vector of all dial plans in the digit map.
155	 * 
156	 * @return The vector of all digit strings in a dial plan. If the vector of
157	 *         digit map strings is not set then this method will return NULL.
158	 */
159	public DigitMapString[] getDigitMapStrings() {
160		return this.digitMapString;
161	}
162
163	/**
164	 * The method sets the vector of the object identifier for the digit string.
165	 * Each of the vector element specifies one digit string.
166	 * 
167	 * @param digitStrings
168	 *            The vector of the object identifer of the digit strings.
169	 * @throws IllegalArgumentException
170	 *             - if the digit string is not set properly.
171	 */
172	public void setDigitMapStrings(DigitMapString[] digitStrings) throws IllegalArgumentException {
173		// FIXME: what does mean - not correctly?
174		this.digitMapString = digitStrings;
175	}
176
177	public java.lang.String toString() {
178		return this.getClass().getSimpleName()+" : TimerL = "+this.timerL+" : TimerS = "+this.timerS+" : TimerT = "+this.timerT;
179	}
180
181}