PageRenderTime 29ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/protocols/jain-megaco/megaco-api/src/main/java/javax/megaco/association/AssocState.java

http://mobicents.googlecode.com/
Java | 159 lines | 72 code | 13 blank | 74 comment | 2 complexity | 04cc88b64f21835746e998aa04e4c786 MD5 | raw file
Possible License(s): LGPL-3.0, GPL-3.0, LGPL-2.1, GPL-2.0, CC-BY-SA-3.0, CC0-1.0, Apache-2.0, BSD-3-Clause
  1. package javax.megaco.association;
  2. import java.io.Serializable;
  3. /**
  4. * Constants used in package javax.megaco.association. This forms the class for
  5. * the association state of the Association package. The association here refers
  6. * to the association w.r.t the peer i.e., MG-MGC association. The state here
  7. * refers to the state of the control association between MG-MGC. These states
  8. * would assist the application in making decisions regarding when and what
  9. * commands to initiate towards the peer. For eg. untill the association is in
  10. * state M_REG_COMPL, the application should not send any commands to the stack.
  11. * Similarly, if the association is in M_GRACEFUL_SHUTDOWN_IN_PRGS state and if
  12. * the application is MGC, then it should refrain from establishing new calls,
  13. * therefore it should not send new ADD commands.
  14. *
  15. */
  16. public class AssocState implements Serializable {
  17. /**
  18. * Identifies association is in IDLE state. Its value shall be set to 1.
  19. */
  20. public final static int M_IDLE = 1;
  21. /**
  22. * Identifies association is in Registration state. Its value shall be set
  23. * to 2.
  24. */
  25. public final static int M_REG_IN_PRGS = 2;
  26. /**
  27. * Identifies association is in Registration completed state. Its value
  28. * shall be set to 3.
  29. */
  30. public final static int M_REG_COMPL = 3;
  31. /**
  32. * Identifies association is in Disconnected state. Its value shall be set
  33. * to 4.
  34. */
  35. public final static int M_DISCONNECTED = 4;
  36. /**
  37. * Identifies association is in Handoff state. Its value shall be set to 5.
  38. */
  39. public final static int M_HANDOFF_IN_PRGS = 5;
  40. /**
  41. * Identifies association is in Handoff state. Its value shall be set to 6.
  42. */
  43. public final static int M_FAILOVER_IN_PRGS = 6;
  44. /**
  45. * Identifies association is in Forced shutdown state. Its value shall be
  46. * set to 7.
  47. */
  48. public final static int M_FORCED_SHUTDOWN_IN_PRGS = 7;
  49. /**
  50. * Identifies association is in Registration state. Its value shall be set
  51. * to 8.
  52. */
  53. public final static int M_GRACEFUL_SHUTDOWN_IN_PRGS = 8;
  54. /**
  55. * Identifies a AssocState object that constructs the class with the
  56. * constant M_IDLE.
  57. */
  58. public final static AssocState IDLE = new AssocState(M_IDLE);
  59. /**
  60. * Identifies a AssocState object that constructs the class with the field
  61. * constant M_REG_IN_PRGS.
  62. */
  63. public final static AssocState REG_IN_PRGS = new AssocState(M_REG_IN_PRGS);
  64. /**
  65. * Identifies a AssocState object that constructs the class with the field
  66. * constant M_REG_COMPL.
  67. */
  68. public final static AssocState REG_COMPL = new AssocState(M_REG_COMPL);
  69. /**
  70. * Identifies a AssocState object that constructs the class with the field
  71. * constant M_DISCONNECTED.
  72. */
  73. public final static AssocState DISCONNECTED = new AssocState(M_DISCONNECTED);
  74. /**
  75. * Identifies a AssocState object that constructs the class with the field
  76. * constant M_HANDOFF_IN_PRGS.
  77. */
  78. public final static AssocState HANDOFF_IN_PRGS = new AssocState(M_HANDOFF_IN_PRGS);
  79. /**
  80. * Identifies a AssocState object that constructs the class with the field
  81. * constant M_FAILOVER_IN_PRGS.
  82. */
  83. public final static AssocState FAILOVER_IN_PRGS = new AssocState(M_FAILOVER_IN_PRGS);
  84. /**
  85. * Identifies a AssocState object that constructs the class with the field
  86. * constant M_FORCED_SHUTDOWN_IN_PRGS.
  87. */
  88. public final static AssocState FORCED_SHUTDOWN_IN_PRGS = new AssocState(M_FORCED_SHUTDOWN_IN_PRGS);
  89. /**
  90. * Identifies a AssocState object that constructs the class with the field
  91. * constant M_GRACEFUL_SHUTDOWN_IN_PRGS.
  92. */
  93. public final static AssocState GRACEFUL_SHUTDOWN_IN_PRGS = new AssocState(M_GRACEFUL_SHUTDOWN_IN_PRGS);
  94. private int assocState = -1;
  95. private AssocState(int assocStateIdle) {
  96. this.assocState = assocStateIdle;
  97. }
  98. public int getAssocState() {
  99. return this.assocState;
  100. }
  101. public static final AssocState getObject(int value) {
  102. switch (value) {
  103. case M_IDLE:
  104. return IDLE;
  105. case M_REG_IN_PRGS:
  106. return REG_IN_PRGS;
  107. case M_REG_COMPL:
  108. return REG_COMPL;
  109. case M_DISCONNECTED:
  110. return DISCONNECTED;
  111. case M_HANDOFF_IN_PRGS:
  112. return HANDOFF_IN_PRGS;
  113. case M_FAILOVER_IN_PRGS:
  114. return FAILOVER_IN_PRGS;
  115. case M_FORCED_SHUTDOWN_IN_PRGS:
  116. return FORCED_SHUTDOWN_IN_PRGS;
  117. case M_GRACEFUL_SHUTDOWN_IN_PRGS:
  118. return GRACEFUL_SHUTDOWN_IN_PRGS;
  119. default:
  120. throw new IllegalArgumentException("Wrogn value passed, there is no assoc state with code: " + value);
  121. }
  122. }
  123. @Override
  124. public String toString() {
  125. switch (this.assocState) {
  126. case M_IDLE:
  127. return "AssocState[IDLE]";
  128. case M_REG_IN_PRGS:
  129. return "AssocState[REG_IN_PRGS";
  130. case M_REG_COMPL:
  131. return "AssocState[REG_COMPL";
  132. case M_DISCONNECTED:
  133. return "AssocState[DISCONNECTED";
  134. case M_HANDOFF_IN_PRGS:
  135. return "AssocState[HANDOFF_IN_PRGS";
  136. case M_FAILOVER_IN_PRGS:
  137. return "AssocState[FAILOVER_IN_PRGS";
  138. case M_FORCED_SHUTDOWN_IN_PRGS:
  139. return "AssocState[FORCED_SHUTDOWN_IN_PRGS";
  140. case M_GRACEFUL_SHUTDOWN_IN_PRGS:
  141. return "AssocState[GRACEFUL_SHUTDOWN_IN_PRGS";
  142. default:
  143. return "AssocState[" + this.assocState + "]";
  144. }
  145. }
  146. }