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

http://mobicents.googlecode.com/ · Java · 103 lines · 39 code · 17 blank · 47 comment · 2 complexity · 23909bad421e056637c9435c6569c694 MD5 · raw file

  1. package javax.megaco.message.descriptor;
  2. import java.io.Serializable;
  3. /**
  4. * Signal Param type class defines all the static constants for the signal param
  5. * type for the megaco package.
  6. */
  7. public class SignalParamType implements Serializable {
  8. /**
  9. * Identifies signal param type to be list. Its value shall be set to 1.
  10. */
  11. public static final int M_LIST = 1;
  12. /**
  13. * Identifies signal param type to be request. Its value shall be set to 2.
  14. */
  15. public static final int M_REQUEST = 2;
  16. /**
  17. * Identifies a MegacoSignalParamType object that constructs the class with
  18. * the constant M_LIST. Since it is reference to static final
  19. * object, it prevents further instantiation of the same object in the
  20. * system.
  21. */
  22. public static final SignalParamType LIST = new SignalParamType(M_LIST);
  23. /**
  24. * Identifies a MegacoSignalParamType object that constructs the class with
  25. * the constant M_REQUEST. Since it is reference to static
  26. * final object, it prevents further instantiation of the same object in the
  27. * system.
  28. */
  29. public static final SignalParamType REQUEST = new SignalParamType(M_REQUEST);
  30. private int signalParamType = -1;
  31. /**
  32. * Constructs an class that specifies the signal param type in the signal
  33. * descriptor.
  34. *
  35. * @param signal_type
  36. */
  37. private SignalParamType(int type) {
  38. this.signalParamType = type;
  39. }
  40. /**
  41. * This method returns one of the static field constants defined in this
  42. * class.
  43. *
  44. * @return Returns an integer value that identifies the signal type to be
  45. * one of brief or on-off or other.
  46. */
  47. public int getsignalParamType() {
  48. return this.signalParamType;
  49. }
  50. /**
  51. * Returns reference of the SignalParamType object that identifies the
  52. * signal type as value passed to this method.
  53. *
  54. * @param value
  55. * - It is one of the possible values of the static constant that
  56. * this class provides.
  57. * @return Returns reference of the signalParamType object.
  58. * @throws IllegalArgumentException
  59. * - If the value passed to this method is invalid, then this
  60. * exception is raised.
  61. */
  62. public static final SignalParamType getObject(int value) throws IllegalArgumentException {
  63. switch (value) {
  64. case M_LIST:
  65. return LIST;
  66. case M_REQUEST:
  67. return REQUEST;
  68. default:
  69. throw new IllegalArgumentException("Wrong signal param type passed: " + value);
  70. }
  71. }
  72. private Object readResolve() {
  73. return this.getObject(this.signalParamType);
  74. }
  75. @Override
  76. public String toString() {
  77. switch (this.signalParamType) {
  78. case M_LIST:
  79. return "SignalParamType[LIST]";
  80. case M_REQUEST:
  81. return "SignalParamType[REQUEST]";
  82. default:
  83. return "SignalParamType[" + this.signalParamType + "]";
  84. }
  85. }
  86. }