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