PageRenderTime 59ms CodeModel.GetById 25ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://mobicents.googlecode.com/
Java | 184 lines | 63 code | 23 blank | 98 comment | 12 complexity | 7456ed7670e35647f3cd400d723f13a3 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.message.descriptor;
  2. import java.io.Serializable;
  3. import javax.megaco.message.Descriptor;
  4. import javax.megaco.message.DescriptorType;
  5. import javax.megaco.pkg.PkgItemStr;
  6. import javax.megaco.pkg.PkgPrptyItem;
  7. /**
  8. * The class extends JAIN MEGACO Descriptor. This class describes the
  9. * termination state descriptor. It specifies the service state, event buffer
  10. * control and the package property values. Atleaset one of the above needs to
  11. * be specified for the termination state descriptor.
  12. */
  13. public class TermStateDescriptor extends Descriptor implements Serializable {
  14. private ServiceState serviceState = null;
  15. private EventBufferCtrl evtBufferControl = null;
  16. private PkgPrptyItem[] pkgPrptyItems = null;
  17. private PkgItemStr[] prptyParamStr;
  18. /**
  19. * Constructs a TermState Descriptor which may contain atleast one of
  20. * service state, reserve value, reserve group and property param.
  21. */
  22. public TermStateDescriptor() {
  23. super();
  24. super.descriptorId = DescriptorType.M_TERMINATION_STATE_DESC;
  25. }
  26. @Override
  27. public int getDescriptorId() {
  28. return super.descriptorId;
  29. }
  30. /**
  31. * This method gets the service state for the termination state descriptor.
  32. * This shall specify one of out of service or in service or test. When
  33. * service state is not present, then this shall return value null.
  34. *
  35. * @return Returns the object reference of type service state. If the
  36. * service state is not set then this shall return value null.
  37. */
  38. public final int getServiceState() {
  39. return this.serviceState.getServiceState();
  40. }
  41. /**
  42. * This method sets the service state with one of out of service or in
  43. * service or test. When service state is not to be sent then this method
  44. * would not be invoked.
  45. *
  46. * @param serviceState
  47. * - Sets the object reference of the derived object of
  48. * ServiceState to specify one of out of service or in service or
  49. * test.
  50. * @throws IllegalArgumentException
  51. * : This exception is raised if the reference of Service State
  52. * passed to this method is NULL.
  53. */
  54. public final void setServiceState(ServiceState serviceState)
  55. throws IllegalArgumentException {
  56. if (serviceState == null) {
  57. throw new IllegalArgumentException("ServiceState must not be null.");
  58. }
  59. this.serviceState = serviceState;
  60. }
  61. /**
  62. * This method gets the event buffer control for the termination state
  63. * descriptor. This shall specify one of off or lock step. When event buffer
  64. * control is not present, then this shall return value null.
  65. *
  66. * @return Returns the object reference of type event buffer control. If the
  67. * event buffer control is not set then this shall return value nul.
  68. */
  69. public final EventBufferCtrl getEvtBufferControl() {
  70. return this.evtBufferControl;
  71. }
  72. /**
  73. * This method sets the event buffer control with one of off or lock step.
  74. * When event buffer control is not to be sent then this method would not be
  75. * invoked.
  76. *
  77. * @param eventBufferControl
  78. * - Sets the object reference of the derived object of
  79. * EventBufferCtrl to specify one of off or lock step.
  80. * @throws IllegalArgumentException
  81. * : This exception is raised if the reference of Event Buffer
  82. * Control passed to this method is NULL.
  83. */
  84. public final void setEvtBufferControl(EventBufferCtrl eventBufferControl) throws IllegalArgumentException {
  85. if (eventBufferControl == null) {
  86. throw new IllegalArgumentException("EventBufferCtrl must not be null.");
  87. }
  88. this.evtBufferControl = eventBufferControl;
  89. }
  90. /**
  91. * The method is used to get the vector of property param within the
  92. * termination state descriptor. If this is not set then this method shall
  93. * return a NULL value.
  94. *
  95. * @return Returns the vector of object reference of type PkgPrptyItem. If
  96. * the package property item is not set then this shall return a
  97. * NULL value.
  98. */
  99. public final PkgPrptyItem[] getMegacoPkgPrptyItem() {
  100. return this.pkgPrptyItems;
  101. }
  102. /**
  103. * Sets the vector of type PkgPrptyItem in a termination state descriptor.
  104. * If Megaco package property is not to be sent, then this method would not
  105. * be called.
  106. *
  107. * @param prptyParam
  108. * - The Megaco Property parameter specifying the property for
  109. * the termination in the command.
  110. * @throws IllegalArgumentException
  111. * - if the parameters set for the property parameter are such
  112. * that the TermState Descriptor cannot be encoded.
  113. */
  114. public final void setMegacoPkgPrptyItem(PkgPrptyItem[] prptyParam) throws IllegalArgumentException {
  115. // FIXME: add error checks
  116. if (prptyParam == null) {
  117. throw new IllegalArgumentException("PkgPrptyItem[] must not be null.");
  118. }
  119. if (prptyParam.length == 0) {
  120. throw new IllegalArgumentException("PkgPrptyItem[] must not be empty.");
  121. }
  122. this.pkgPrptyItems = prptyParam;
  123. }
  124. /**
  125. * The method is used to get the vector of property param within the
  126. * termination state descriptor. The property param returned in this case
  127. * have package name, item name and associated parameters specified in the
  128. * string format. If this is not set then this method shall return a NULL
  129. * value.
  130. *
  131. * @return Returns the vector of object reference of type PkgPrptyItem. If
  132. * the package property item is not set then this shall return a
  133. * NULL value.
  134. */
  135. public final PkgItemStr[] getMegacoPkgItemStr() {
  136. return this.prptyParamStr;
  137. }
  138. /**
  139. * Sets the vector of type PkgItemStr in a termination state descriptor. If
  140. * Megaco package property is not to be sent, then this method would not be
  141. * called. This method would invoked for the packages which have not been
  142. * defined in javax.megaco.pkg package.
  143. *
  144. * @param prptyParam
  145. * - The Megaco Property parameter specifying the property for
  146. * the termination in the command.
  147. * @throws IllegalArgumentException
  148. * : This exception is raised if the reference of Package Item
  149. * string passed to this method is NULL.
  150. */
  151. public final void setMegacoPkgItemStr(PkgItemStr[] prptyParamStr) throws IllegalArgumentException {
  152. // FIXME: add error checks
  153. if (prptyParamStr == null) {
  154. throw new IllegalArgumentException("PkgItemStr[] must not be null.");
  155. }
  156. if (prptyParamStr.length == 0) {
  157. throw new IllegalArgumentException("PkgItemStr[] must not be empty.");
  158. }
  159. this.prptyParamStr = prptyParamStr;
  160. }
  161. }