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

http://mobicents.googlecode.com/ · Java · 333 lines · 124 code · 46 blank · 163 comment · 8 complexity · b0b3eace75dec63e11dc14335cce5952 MD5 · raw file

  1. package javax.megaco.message.descriptor;
  2. import java.io.Serializable;
  3. import java.util.Collections;
  4. import java.util.HashSet;
  5. import java.util.Set;
  6. import javax.megaco.message.Descriptor;
  7. import javax.megaco.message.DescriptorType;
  8. /**
  9. * The class extends JAIN MEGACO Descriptor. This class describes the audit
  10. * value response descriptor. It specifies the tokens and descriptors for audit
  11. * value response.
  12. */
  13. public class AuditValRespDescriptor extends Descriptor implements Serializable {
  14. private boolean obsEventToken;
  15. private boolean eventsToken;
  16. private boolean statsToken;
  17. private boolean eventBuffToken;
  18. private boolean signalToken;
  19. private boolean mediaToken;
  20. private boolean modemTokenPresent;
  21. private boolean muxToken;
  22. private boolean digitMapToken;
  23. private boolean packagesToken;
  24. private Descriptor[] descriptors;
  25. /**
  26. * * <br>
  27. * 1. Media Descriptor<br>
  28. * 2. Modem Descriptor<br>
  29. * 3. Mux Descriptor<br>
  30. * 4. Events Descriptor<br>
  31. * 5. Signal Descriptor<br>
  32. * 6. Digit Map Descriptor<br>
  33. * 7. Observed Events Descriptor<br>
  34. * 8. Event Buffer Descriptor<br>
  35. * 9. Statistics Descriptor<br>
  36. * 10. Package Descriptor<br>
  37. * 11. Error Descriptor<br>
  38. **/
  39. private static final Set<Integer> allowedDescritpors;
  40. static {
  41. Set<Integer> tmps = new HashSet<Integer>();
  42. tmps.add(DescriptorType.M_MEDIA_DESC);
  43. tmps.add(DescriptorType.M_MODEM_DESC);
  44. tmps.add(DescriptorType.M_MUX_DESC);
  45. tmps.add(DescriptorType.M_EVENT_DESC);
  46. tmps.add(DescriptorType.M_SIGNAL_DESC);
  47. tmps.add(DescriptorType.M_DIGIT_MAP_DESC);
  48. tmps.add(DescriptorType.M_OBSERVED_EVENT_DESC);
  49. tmps.add(DescriptorType.M_EVENT_BUF_DESC);
  50. tmps.add(DescriptorType.M_STATISTICS_DESC);
  51. tmps.add(DescriptorType.M_PACKAGE_DESC);
  52. tmps.add(DescriptorType.M_ERROR_DESC);
  53. allowedDescritpors = Collections.unmodifiableSet(tmps);
  54. }
  55. /**
  56. * Constructs a Audit Value Response Descriptor. It specifies the tokens for
  57. * which the audit value is required.
  58. */
  59. public AuditValRespDescriptor() {
  60. super.descriptorId = DescriptorType.M_AUDIT_VAL_REPLY_DESC;
  61. }
  62. /**
  63. * This method cannot be overridden by the derived class. This method
  64. * returns that the descriptor identifier is of type audit value response
  65. * descriptor. This method overrides the corresponding method of the base
  66. * class Descriptor.
  67. *
  68. * @return Returns an integer value that identifies this object of the type
  69. * of audit value response descriptor. It returns that it is audit
  70. * value response Descriptor i.e., M_AUDIT_VAL_REPLY_DESC.
  71. */
  72. public int getDescriptorId() {
  73. return super.descriptorId;
  74. }
  75. /**
  76. * Gets the Descriptor information for all the descriptor in this audit
  77. * response parameter.
  78. *
  79. * @return The vector of the reference to the object identifier of type
  80. * descriptor information.
  81. */
  82. public Descriptor[] getDescriptor() {
  83. return this.descriptors;
  84. }
  85. /**
  86. * Sets the vector of Descriptor Information for this audit response
  87. * parameter. Only valid descriptors are <br>
  88. * <br>
  89. * 1. Media Descriptor<br>
  90. * 2. Modem Descriptor<br>
  91. * 3. Mux Descriptor<br>
  92. * 4. Events Descriptor<br>
  93. * 5. Signal Descriptor<br>
  94. * 6. Digit Map Descriptor<br>
  95. * 7. Observed Events Descriptor<br>
  96. * 8. Event Buffer Descriptor<br>
  97. * 9. Statistics Descriptor<br>
  98. * 10. Package Descriptor<br>
  99. * 11. Error Descriptor<br>
  100. *
  101. *
  102. * @param descriptor
  103. * The vector of reference to the object identifier of type
  104. * descriptor information.
  105. * @throws IllegalArgumentException
  106. * if the descriptor passed to this method is invalid.
  107. */
  108. public void setDescriptor(Descriptor[] descriptors) throws IllegalArgumentException {
  109. if (descriptors == null) {
  110. throw new IllegalArgumentException("Descriptor[] must not be null.");
  111. }
  112. if (descriptors.length == 0) {
  113. throw new IllegalArgumentException("Descriptor[] must not be empty.");
  114. }
  115. int count = 0;
  116. for (Descriptor d : descriptors) {
  117. if (d == null) {
  118. throw new IllegalArgumentException("Descriptor[" + count + "] is null!");
  119. }
  120. if (!allowedDescritpors.contains(d.getDescriptorId())) {
  121. throw new IllegalArgumentException("Descriptor[" + count + "] is is of wrong type, its not allowed: " + d.toString());
  122. }
  123. count++;
  124. }
  125. this.descriptors = descriptors;
  126. }
  127. /**
  128. * This method cannot be overridden by the derived class. This method
  129. * indicates if the mux token is present or not.
  130. *
  131. * @return Returns TRUE if the Mux token is present.
  132. */
  133. public final boolean isMuxTokenPresent() {
  134. return this.muxToken;
  135. }
  136. /**
  137. * This method cannot be overridden by the derived class. This method sets a
  138. * flag to indicate that the mux token is present.
  139. */
  140. public final void setMuxToken() {
  141. this.muxToken = true;
  142. }
  143. /**
  144. * This method cannot be overridden by the derived class. This method
  145. * indicates if the Modem token is present or not.
  146. *
  147. * @return Returns TRUE if the Modem token is present.
  148. */
  149. public final boolean isModemTokenPresent() {
  150. return this.modemTokenPresent;
  151. }
  152. /**
  153. * This method cannot be overridden by the derived class. This method sets a
  154. * flag to indicate that the Modem token is present.
  155. */
  156. public final void setModemToken() {
  157. this.modemTokenPresent = true;
  158. }
  159. /**
  160. * This method cannot be overridden by the derived class. This method
  161. * indicates if the Media token is present or not.
  162. *
  163. * @return Returns TRUE if the Media token is present.
  164. */
  165. public final boolean isMediaTokenPresent() {
  166. return this.mediaToken;
  167. }
  168. /**
  169. * This method cannot be overridden by the derived class. This method sets a
  170. * flag to indicate that the Media token is present.
  171. */
  172. public final void setMediaToken() {
  173. this.mediaToken = true;
  174. }
  175. /**
  176. * This method cannot be overridden by the derived class. This method
  177. * indicates if the Signal token is present or not.
  178. *
  179. * @return Returns TRUE if the Signal token is present.
  180. */
  181. public final boolean isSignalTokenPresent() {
  182. return this.signalToken;
  183. }
  184. /**
  185. * This method cannot be overridden by the derived class. This method sets a
  186. * flag to indicate that the Signal token is present.
  187. */
  188. public final void setSignalToken() {
  189. this.signalToken = true;
  190. }
  191. /**
  192. * This method cannot be overridden by the derived class. This method
  193. * indicates if the Event Buffer token is present or not.
  194. *
  195. * @return Returns TRUE if the Event Buffer token is present.
  196. */
  197. public final boolean isEventBuffTokenPresent() {
  198. return this.eventBuffToken;
  199. }
  200. /**
  201. * This method cannot be overridden by the derived class. This method sets a
  202. * flag to indicate that the Event Buffer token is present.
  203. */
  204. public final void setEventBuffToken() {
  205. this.eventBuffToken = true;
  206. }
  207. /**
  208. * This method cannot be overridden by the derived class. This method
  209. * indicates if the Statistics token is present or not.
  210. *
  211. * @return Returns TRUE if the Statistics token is present.
  212. */
  213. public final boolean isStatsTokenPresent() {
  214. return this.statsToken;
  215. }
  216. /**
  217. * This method cannot be overridden by the derived class. This method sets a
  218. * flag to indicate that the Statistics token is present.
  219. */
  220. public final void setStatsToken() {
  221. this.statsToken = true;
  222. }
  223. /**
  224. * This method cannot be overridden by the derived class. This method
  225. * indicates if the Events token is present or not.
  226. *
  227. * @return Returns TRUE if the Events token is present.
  228. */
  229. public final boolean isEventsTokenPresent() {
  230. return this.eventsToken;
  231. }
  232. /**
  233. * This method cannot be overridden by the derived class. This method sets a
  234. * flag to indicate that the Events token is present.
  235. */
  236. public final void setEventsToken() {
  237. this.eventsToken = true;
  238. }
  239. /**
  240. * This method cannot be overridden by the derived class. This method
  241. * indicates if the Observed Event token is present or not.
  242. *
  243. * @return Returns TRUE if the Observed Event token is present.
  244. */
  245. public final boolean isObsEventTokenPresent() {
  246. return this.obsEventToken;
  247. }
  248. /**
  249. * This method cannot be overridden by the derived class. This method sets a
  250. * flag to indicate that the Observed Event token is present.
  251. */
  252. public final void setObsEventToken() {
  253. this.obsEventToken = true;
  254. }
  255. /**
  256. * This method cannot be overridden by the derived class. This method
  257. * indicates if the digit map token is present or not.
  258. *
  259. * @returnReturns TRUE if the digit map token is present.
  260. */
  261. public final boolean isDigitMapTokenPresent() {
  262. return this.digitMapToken;
  263. }
  264. /**
  265. * This method cannot be overridden by the derived class. This method sets a
  266. * flag to indicate that the digit map token is present.
  267. */
  268. public final void setDigitMapToken() {
  269. this.digitMapToken = true;
  270. }
  271. /**
  272. * This method cannot be overridden by the derived class. This method
  273. * indicates if the Packages token is present or not.
  274. *
  275. * @return Returns TRUE if the Packages token is present.
  276. */
  277. public final boolean isPackagesTokenPresent() {
  278. return this.packagesToken;
  279. }
  280. /**
  281. * This method cannot be overridden by the derived class. This method sets a
  282. * flag to indicate that the Packages token is present.
  283. */
  284. public final void setPackagesToken() {
  285. this.packagesToken = true;
  286. }
  287. }