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

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