PageRenderTime 25ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

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

http://mobicents.googlecode.com/
Java | 134 lines | 41 code | 18 blank | 75 comment | 3 complexity | f444fbe40d3f026b3afd036e1b565237 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.ParameterNotSetException;
  4. import javax.megaco.pkg.PkgEventItem;
  5. import javax.megaco.pkg.PkgItemStr;
  6. /**
  7. * The EventBufParam object is a class that shall be used to set the stream id,
  8. * event id, package id and parameter name and value for an event id. The class
  9. * optionally provides interface to specify the package name, item name and the
  10. * associated parameters in the string format. This is an independent class
  11. * derived from java.util.Object and shall not have any derived classes.
  12. */
  13. public class EventBufParam implements Serializable {
  14. private PkgItemStr eventItemStr;
  15. private PkgEventItem eventItem;
  16. private Integer streamId;
  17. /**
  18. * Constructs Event buffer parameter object with the PkgEventItem object.
  19. * This is to be set within an event buffer descriptor.
  20. *
  21. * @param eventItem
  22. * @throws IllegalArgumentException
  23. * - Thrown if an invalid eventItem object reference is set.
  24. */
  25. public EventBufParam(PkgEventItem eventItem) throws IllegalArgumentException {
  26. this.eventItem = eventItem;
  27. }
  28. /**
  29. *
  30. * Constructs Event buffer parameter object with the PkgItemStr object. This
  31. * method would be used if the package parameters are to be conveyed in the
  32. * string format. This is to be set within an event buffer descriptor.
  33. *
  34. * @param eventItemStr
  35. * @throws IllegalArgumentException
  36. * - Thrown if an invalid eventItemStr object reference is set.
  37. */
  38. public EventBufParam(PkgItemStr eventItemStr) throws IllegalArgumentException {
  39. this.eventItemStr = eventItemStr;
  40. }
  41. /**
  42. * The method can be used to get the pkdgName as set in the event buffer
  43. * descriptor. This method gives the package information, the attached event
  44. * information and the parameter name and value for the event id.
  45. *
  46. * @return The object reference for the megaco package, which has the object
  47. * reference for megaco package event and which in turn has the
  48. * reference for the parameter info. If the parameter has not been
  49. * set, then this method shall return NULL.
  50. */
  51. public PkgEventItem getMegacoPkgEvtItem() {
  52. return this.eventItem;
  53. }
  54. /**
  55. * The method can be used to get the pkdgName as set in the event buffer
  56. * descriptor. This method gives the package information, the attached event
  57. * information and the parameter name and value. As comapres to the
  58. * getMegacoPkgEvtItem() method, this method returnes the package parameters
  59. * in the string format.
  60. *
  61. * @return The object reference for the megaco package item. This class
  62. * holds information about package name, item name and the
  63. * parameters in the string format. If the parameter has not been
  64. * set, then this method shall return NULL.
  65. */
  66. public PkgItemStr getMegacoPkgItemStr() {
  67. return this.eventItemStr;
  68. }
  69. /**
  70. * The method can be used to get stream id in the event buffer descriptor.
  71. *
  72. * @return streamId - The integer value of the stream id shall be returned.
  73. * This shall be returned only if the streamId is present in the
  74. * event parameter of the event buffer descriptor.
  75. * @throws javax.megaco.ParameterNotSetException
  76. * - Thrown if streamId has not been set. Thus this method
  77. * should be called only after verifying that the streamId is
  78. * set using isStreamIdPresen
  79. */
  80. public int getStreamId() throws javax.megaco.ParameterNotSetException {
  81. if (!isStreamIdPresent()) {
  82. throw new ParameterNotSetException("StreamId must be present");
  83. }
  84. return this.streamId.intValue();
  85. }
  86. /**
  87. * The method can be used to set stream id in the event buffer descriptor.
  88. * This automatically sets the value of stream id present in the event
  89. * parameter object to true.
  90. *
  91. * @param streamId
  92. * - The integer value of the stream id shall be set.
  93. * @throws IllegalArgumentException
  94. * - Thrown if streamId is set with an invalid value.
  95. */
  96. public void setStreamId(int streamId) throws IllegalArgumentException {
  97. if (streamId <= 0) {
  98. throw new IllegalArgumentException("StreamId must be greater than zero.");
  99. }
  100. this.streamId = new Integer(streamId);
  101. }
  102. /**
  103. * The method can be used to find if the stream id is present in the current
  104. * object.
  105. *
  106. * @return Returns true if the stream id is present. This needs to be
  107. * checked before getting the stream id from this object.
  108. */
  109. public boolean isStreamIdPresent() {
  110. return this.streamId != null;
  111. }
  112. public java.lang.String toString()
  113. {
  114. return super.toString();
  115. }
  116. }