PageRenderTime 22ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

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

http://mobicents.googlecode.com/
Java | 134 lines | 45 code | 16 blank | 73 comment | 5 complexity | 367b6c39b161cde95ad2360356e791b2 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;
  2. import java.io.Serializable;
  3. import javax.megaco.ExceptionInfoCode;
  4. import javax.megaco.ParameterNotSetException;
  5. import javax.megaco.message.descriptor.TopologyDescriptor;
  6. /**
  7. * The Context Parameter object is a class that shall be used to set the context
  8. * level parameters i.e., topology descriptor, priority, and whether emergency
  9. * is active or not. This is an independent class derived from java.util.Object
  10. * and shall not have any derived classes
  11. *
  12. *
  13. */
  14. public class ContextParam implements Serializable {
  15. private boolean isEMPresent;
  16. private TopologyDescriptor[] topologyDescriptors = null;
  17. private boolean isPriorityPresent;
  18. private int priority;
  19. /**
  20. * Constructs a class that shall specify the context level parameters.
  21. */
  22. public ContextParam() {
  23. }
  24. /**
  25. * The method can be used to check if emergency is present as a part of the
  26. * context level parameters. By default, if the setEM() method has not been
  27. * invoked, then this method should return FALSE to indicate that Emeregency
  28. * is not present.
  29. *
  30. * @return Returns true if Emergency is present.
  31. */
  32. public boolean isEMPresent() {
  33. return this.isEMPresent;
  34. }
  35. /**
  36. * Gets the object refernces of all the topology descriptors specified for
  37. * this context.
  38. *
  39. * @return The vector of the reference to the object identifier of type
  40. * topology descriptor information.
  41. */
  42. public TopologyDescriptor[] getTopologyDescriptor() {
  43. return this.topologyDescriptors;
  44. }
  45. /**
  46. * The method can be used to check if the prority value is specified for
  47. * this context.
  48. *
  49. * @return Returns true if priority is present. The function is called prior
  50. * to getPriority function to check if priroty is present.
  51. */
  52. public boolean isPriorityPresent() {
  53. return this.isPriorityPresent;
  54. }
  55. /**
  56. * The method can be used to get the prority value specified for this
  57. * context. Before invoking this method, isPriorityPresent method must be
  58. * invoked to verify the presence of priority field in the class object.
  59. *
  60. * @return Returns the priority value specified for this context.
  61. * @throws javax.megaco.ParameterNotSetException
  62. * : This exception is raised if the priority is not set and the
  63. * get method is invoked.
  64. */
  65. public int getPriority() throws javax.megaco.ParameterNotSetException {
  66. if (!this.isPriorityPresent) {
  67. throw new ParameterNotSetException("Priority not set for ContextParam");
  68. }
  69. return this.priority;
  70. }
  71. /**
  72. * The method can be used to set if the EM is present as a part of the
  73. * context level parameters.
  74. *
  75. * @param isEMPresent
  76. * - The boolean value to indicate if the emergency is present as
  77. * a part of the context level parameters.
  78. */
  79. public void setEM(boolean isEMPresent) {
  80. this.isEMPresent = isEMPresent;
  81. }
  82. /**
  83. * The method can be used to set the priority value for this context.
  84. *
  85. * @param priority
  86. * priority - Integer value of the priority that shall be set.
  87. * The only valid values specified by the protocol for this
  88. * parameters is between 0 to 15.
  89. * @throws IllegalArgumentException
  90. * : The valid values of priority ranges between 0 to 15. If any
  91. * value other than this is set then the exception is raised.
  92. */
  93. public void setPriority(int priority) throws IllegalArgumentException {
  94. if (priority < 0 || priority > 15) {
  95. IllegalArgumentException invalidArgumentException = new IllegalArgumentException("The priority for Contextparam should be between 0 and 15. The value passed is = " + priority);
  96. // invalidArgumentException.setInfoCode(ExceptionInfoCode.INV_PRIORITY_VAL);
  97. throw invalidArgumentException;
  98. }
  99. this.priority = priority;
  100. }
  101. /**
  102. * Sets the vector of Topology Descriptor Information for this command.
  103. *
  104. * @param topologyDescriptor
  105. * The vector of reference to the object identifier of type
  106. * topology descriptor information
  107. * @throws IllegalArgumentException
  108. * : This exception is raised if the reference of Topology
  109. * Descriptor passed to this method is NULL.
  110. */
  111. public void setTopologyDescriptor(TopologyDescriptor topologyDescriptor[]) throws IllegalArgumentException {
  112. if (topologyDescriptor == null) {
  113. IllegalArgumentException invalidArgumentException = new IllegalArgumentException("The TopologyDescriptor[] cannot be null for ContextParam");
  114. throw invalidArgumentException;
  115. }
  116. this.topologyDescriptors = topologyDescriptor;
  117. }
  118. }