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

http://mobicents.googlecode.com/ · Java · 169 lines · 62 code · 31 blank · 76 comment · 2 complexity · e6ea624fa64caa97dd4bf386109f05ea MD5 · raw file

  1. package javax.megaco.message.descriptor;
  2. import java.io.Serializable;
  3. /**
  4. * Mux type constants used in package javax.megaco.message.descriptor. This
  5. * defines the mux type for the megaco package.
  6. */
  7. public class MuxType implements Serializable {
  8. /**
  9. * Identifies mux type to be h221. Its value shall be set to 0.
  10. */
  11. public static final int M_H221 = 0;
  12. /**
  13. * Identifies mux type to be h223. Its value shall be set to 1.
  14. */
  15. public static final int M_H223 = 1;
  16. /**
  17. * Identifies mux type to be "h226". Its value shall be set to 2.
  18. */
  19. public static final int M_H226 = 2;
  20. /**
  21. * Identifies mux type to be "v76". Its value shall be set to 3.
  22. */
  23. public static final int M_V76 = 3;
  24. /**
  25. * Identifies mux type to be "extension". Its value shall be set to 4.
  26. */
  27. public static final int M_EXT = 4;
  28. /**
  29. * Identifies a Mux Type object that constructs the class with the constant
  30. * M_H221. Since it is reference to static final object, it
  31. * prevents further instantiation of the same object in the system.
  32. */
  33. public static final MuxType H221
  34. = new MuxType(M_H221);
  35. /**
  36. * Identifies a Mux Type object that constructs the class with the constant
  37. * M_H223. Since it is reference to static final object, it
  38. * prevents further instantiation of the same object in the system.
  39. */
  40. public static final MuxType H223
  41. = new MuxType(M_H223);
  42. /**
  43. * Identifies a Mux Type object that constructs the class with the constant
  44. * M_H226. Since it is reference to static final object, it
  45. * prevents further instantiation of the same object in the system.
  46. */
  47. public static final MuxType H226
  48. = new MuxType(M_H226);
  49. /**
  50. * Identifies a Mux Type object that constructs the class with the constant
  51. * M_V76. Since it is reference to static final object, it prevents
  52. * further instantiation of the same object in the system.
  53. */
  54. public static final MuxType V76
  55. = new MuxType(M_V76);
  56. /**
  57. * Identifies a Mux Type object that constructs the class with the constant
  58. * M_EXT. Since it is reference to static final object, it prevents
  59. * further instantiation of the same object in the system.
  60. */
  61. public static final MuxType EXT
  62. = new MuxType(M_EXT);
  63. private int muxType = -1;
  64. /**
  65. * Constructs an class that specifies the mux type in the Mux descriptor.
  66. *
  67. * @param mux_type
  68. */
  69. private MuxType(int mux_type) {
  70. this.muxType = mux_type;
  71. }
  72. /**
  73. * This method returns one of the static field constants defined in this
  74. * class.
  75. *
  76. * @return Returns an integer value that identifies the mux type to be one
  77. * of h221 or h223 or h226 or v26 or extension.
  78. */
  79. public int getMuxType() {
  80. return this.muxType;
  81. }
  82. /**
  83. * Returns reference of the MuxType object that identifies the mux type as
  84. * value passed to this method.
  85. *
  86. * @param value
  87. * - It is one of the possible values of the static constant that
  88. * this class provides.
  89. * @return Returns reference of the MuxType object.
  90. * @throws IllegalArgumentException
  91. * - If the value passed to this method is invalid, then this
  92. * exception is raised.
  93. */
  94. public static final MuxType getObject(int value) throws IllegalArgumentException {
  95. switch (value) {
  96. case M_EXT:
  97. return EXT;
  98. case M_H221:
  99. return H221;
  100. case M_H223:
  101. return H223;
  102. case M_H226:
  103. return H226;
  104. case M_V76:
  105. return V76;
  106. default:
  107. throw new IllegalArgumentException("Wrong mux type passed: " + value);
  108. }
  109. }
  110. /**
  111. * This method must be implemented to perform instance substitution during
  112. * serialization. This method is required for reference comparison. This
  113. * method if not implimented will simply fail each time we compare an
  114. * Enumeration value against a de-serialized Enumeration instance.
  115. *
  116. * @return
  117. */
  118. private Object readResolve() {
  119. return getObject(this.muxType);
  120. }
  121. @Override
  122. public String toString() {
  123. switch (this.muxType) {
  124. case M_EXT:
  125. return "MuxType[EXT]";
  126. case M_H221:
  127. return "MuxType[H221]";
  128. case M_H223:
  129. return "MuxType[H223]";
  130. case M_H226:
  131. return "MuxType[H226]";
  132. case M_V76:
  133. return "MuxType[V76]";
  134. default:
  135. return "MuxType[" + this.muxType + "]";
  136. }
  137. }
  138. }