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

http://mobicents.googlecode.com/ · Java · 117 lines · 43 code · 16 blank · 58 comment · 10 complexity · 4de3968af48133ad323b04ae55bede0c MD5 · raw file

  1. package javax.megaco.message.descriptor;
  2. import java.io.Serializable;
  3. import javax.megaco.MethodInvocationException;
  4. import javax.megaco.message.Descriptor;
  5. import javax.megaco.message.DescriptorType;
  6. import javax.megaco.message.Termination;
  7. /**
  8. * The class extends JAIN MEGACO Descriptor. This class describes the Context
  9. * termination audit descriptor.
  10. */
  11. public class CntxtTermAudDescriptor extends Descriptor implements Serializable {
  12. private ErrorDescriptor errorDescriptor;
  13. private Termination[] terminationList;
  14. /**
  15. * Constructs an Context Termination Descriptor object. This extends the
  16. * Descriptor class.
  17. */
  18. public CntxtTermAudDescriptor() {
  19. super.descriptorId = DescriptorType.M_CTX_TERM_AUDIT_DESC;
  20. }
  21. /**
  22. * This method returns that the descriptor identifier is of type descriptor
  23. * Context Termination Audit. This method overrides the corresponding method
  24. * of the base class Descriptor.
  25. *
  26. * @return Returns an integer value that identifies this object as the type
  27. * of Context Termination Audit descriptor. It returns the value
  28. * M_CTX_TERM_AUDIT_DESC for a Context Termination Audit Descriptor.
  29. */
  30. public int getDescriptorId() {
  31. return super.descriptorId;
  32. }
  33. /**
  34. * This method returns that the descriptor info of type Error descriptor.
  35. *
  36. * @return Returns an descriptor info that identifies this object as the
  37. * type of Error descriptor. It returns that it is Error Descriptor
  38. * i.e., M_ERROR_DESC. If the descriptor is absent in the command,
  39. * then method would return NULL.
  40. */
  41. public ErrorDescriptor getErrorDescriptor() {
  42. return this.errorDescriptor;
  43. }
  44. /**
  45. * This method is used to get the list of the termination Ids.
  46. *
  47. * @return The function returns vector of the Termination. If the descriptor
  48. * is absent in the command, then method would return NULL.
  49. */
  50. public Termination[] getTerminationIdList() {
  51. return this.terminationList;
  52. }
  53. /**
  54. * This method sets the Megaco Error descriptor.
  55. *
  56. * @param errorDescriptor
  57. * - Megaco Error descriptor to be set for this command.
  58. * @throws IllegalArgumentException
  59. * - Thrown if an invalid descriptor is set.
  60. * @throws IllegalStateException
  61. * - Thrown if the Termination Id list has already been
  62. * specified for this command. The object of this class can have
  63. * either error descriptor or termination Id list associated
  64. * with it and not both.
  65. */
  66. public void setErrorDescriptor(ErrorDescriptor errorDescriptor) throws IllegalArgumentException, IllegalStateException {
  67. if (errorDescriptor == null) {
  68. throw new IllegalArgumentException("ErrorDescriptor must not be null.");
  69. }
  70. if (this.terminationList != null) {
  71. throw new IllegalStateException("ErrorDescriptor must not be set when Termination[] is present");
  72. }
  73. this.errorDescriptor = errorDescriptor;
  74. }
  75. /**
  76. * The method is used to set the Megaco Termination Id List.
  77. *
  78. * @param termIdList
  79. * - Vector of Megaco terminationId descriptor to be set for this
  80. * command.
  81. * @throws IllegalArgumentException
  82. * - Thrown if an invalid descriptor is set.
  83. * @throws IllegalStateException
  84. * - Thrown if the error descriptor has already been specified
  85. * for this command. The object of this class can have either
  86. * error descriptor or termination Id list associated with it
  87. * and not both.
  88. */
  89. public void setTerminationId(Termination[] termIdList) throws IllegalArgumentException, IllegalStateException {
  90. if (termIdList == null) {
  91. throw new IllegalArgumentException("Termination[] must not be null.");
  92. }
  93. if (termIdList.length == 0) {
  94. throw new IllegalArgumentException("Termination[] must not be empty.");
  95. }
  96. if (this.errorDescriptor != null) {
  97. throw new IllegalStateException("Termination[] must not be set when ErrorDescriptor is present");
  98. }
  99. this.terminationList = termIdList;
  100. }
  101. }