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

http://mobicents.googlecode.com/ · Java · 147 lines · 53 code · 22 blank · 72 comment · 13 complexity · a7cea7d95208975eeef42ca1b9e2d812 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 mux
  9. * descriptor.
  10. */
  11. public class MuxDescriptor extends Descriptor implements Serializable {
  12. private MuxType muxType;
  13. private Termination[] termList;
  14. private String extMux;
  15. /**
  16. * Constructs a Mux Descriptor with the mux type and the termination id
  17. * list.
  18. *
  19. * @param muxType
  20. * - This specifies an object identifier of the mux type to be
  21. * specified for the mux descriptor.
  22. * @param termList
  23. * - This specifies list of termination ids for the specified mux
  24. * type.
  25. * @throws IllegalArgumentException
  26. * : This exception is raised if the reference of MuxType or
  27. * Termination Id list passed to this method is NULL.
  28. */
  29. public MuxDescriptor(MuxType muxType, Termination[] termList) throws IllegalArgumentException {
  30. super.descriptorId = DescriptorType.M_MUX_DESC;
  31. if (muxType == null) {
  32. throw new IllegalArgumentException("MuxType must not be null");
  33. }
  34. if (termList == null) {
  35. throw new IllegalArgumentException("Termination[] must not be null");
  36. }
  37. if (termList.length == 0) {
  38. throw new IllegalArgumentException("Termination[] lmust not be empty");
  39. }
  40. this.muxType = muxType;
  41. this.termList = termList;
  42. }
  43. /**
  44. * This method cannot be overridden by the derived class. This method
  45. * returns that the descriptor identifier is of type Mux descriptor. This
  46. * method overrides the corresponding method of the base class Descriptor.
  47. *
  48. * @return Returns an integer value that identifies this object as the type
  49. * of Mux descriptor. It returns that it is Mux Descriptor i.e.,
  50. * M_MUX_DESC.
  51. */
  52. public int getDescriptorId() {
  53. return super.descriptorId;
  54. }
  55. /**
  56. * This method cannot be overridden by the derived class. This method
  57. * returns the identity of the mux type. The constants for the mux type are
  58. * defined in MuxType.
  59. *
  60. * @return Returns value that identifies Mux type. It returns one of the
  61. * values defined in, MuxType.
  62. */
  63. public final MuxType getMuxType() {
  64. return this.muxType;
  65. }
  66. /**
  67. * This method returns the extension string of the mux type. The extension
  68. * string should be prefixed with "X-" or "X+". The extension characters
  69. * following the prefix should be at most of 6 characters. The extension
  70. * string would be set only when the mux type specifies MUX_TYPE_EXTENSION.
  71. *
  72. * @return Gets the string for the extension of the mux type. The extension
  73. * string would be set only when the mux type specifies
  74. * {@link MuxType.EXT}.
  75. * @throws IllegalStateException
  76. * if the method has been called when the mux type denotes
  77. * anything other than {@link MuxType.EXT}.
  78. */
  79. public java.lang.String getExtensionString() throws IllegalStateException {
  80. if (this.muxType.getMuxType() != muxType.M_EXT) {
  81. throw new IllegalStateException("MuxType must be: EXT");
  82. }
  83. return this.extMux;
  84. }
  85. /**
  86. * Sets the string for the extension of the mux type. Should be set only
  87. * when the mux type specifies MUX_TYPE_EXT.
  88. *
  89. * @param extMux
  90. * - Sets the string for the extension of the mux type. The
  91. * extension string should be prefixed with "X-" or "X+". The
  92. * extension characters following the prefix should be at most of
  93. * 6 characters. The extension string would be set only when the
  94. * mux type specifies {@link MuxType.EXT}.
  95. * @throws IllegalArgumentException
  96. * if the extension string is not in proper format. It should be
  97. * prefixed with either "X+" or "X-" followed by at most 6
  98. * characters.
  99. * @throws IllegalStateException
  100. * if the method has been called when the mux type denotes
  101. * anything other than {@link MuxType.EXT}.
  102. */
  103. public void setExtensionString(java.lang.String extMux) throws IllegalArgumentException, IllegalStateException {
  104. if (this.muxType.getMuxType() != muxType.M_EXT) {
  105. throw new IllegalStateException("MuxType must be: EXT");
  106. }
  107. if (extMux == null) {
  108. new IllegalArgumentException("ExtMux must not be null");
  109. }
  110. DescriptorUtils.checkMethodExtensionRules(extMux);
  111. if (extMux.length() > 8) {
  112. throw new IllegalArgumentException("ExtMux must not be longer than 8 characters.");
  113. }
  114. this.extMux = extMux;
  115. }
  116. /**
  117. * Gets the list of termination ids for which the mux type is specified.
  118. *
  119. * @return Returns the list of termination ids for which the muxt type is
  120. * specified.
  121. */
  122. public final Termination[] getTerminationIdList() {
  123. return this.termList;
  124. }
  125. }