/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

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