/protocols/jain-megaco/megaco-api/src/main/java/javax/megaco/message/descriptor/EventParam.java
Java | 221 lines | 67 code | 22 blank | 132 comment | 9 complexity | 186ce1c33c70efb8dc9e98c5d117f186 MD5 | raw file
1package javax.megaco.message.descriptor; 2 3 4import javax.megaco.MethodInvocationException; 5 6/** 7 * The EventParam object is a class that shall be used to set the signal 8 * descriptor, digitMap descriptor, stream id, whether keep alive is active or 9 * not, package name, event id and the associated parameter names and values. 10 * The class optionally provides interface to specify the package name, item 11 * name and the associated parameters in the string format. This is an 12 * independent class derived from java.util.Object and shall not have any 13 * derived classes. 14 */ 15public class EventParam { 16 17 private SignalDescriptor signalDescriptor = null; 18 private Integer streamId = null; 19 private Boolean keepActive = new Boolean(false); 20 private DigitMapDescriptor digitMapDescriptor = new DigitMapDescriptor(); 21 22 /** 23 * Constructs an object of type event parameter which shall be used within 24 * the event descriptor. 25 */ 26 public EventParam() { 27 super(); 28 // TODO Auto-generated constructor stub 29 } 30 31 /** 32 * The method can be used to get the signal descriptor. 33 * 34 * @return signalDesc - The reference to the object corresponding to the 35 * signal descriptor. This shall be returned only if the signal 36 * descriptor is present in the event parameter of the event 37 * descriptor. 38 */ 39 public SignalDescriptor getSignalDescriptor() { 40 return this.signalDescriptor; 41 } 42 43 /** 44 * The method can be used to get the embedded digit map name in the event 45 * descriptor. Only one of digit map name or digit map value shall be set. 46 * 47 * @return The reference to the embedded digitMap name. If this value is not 48 * set, then this method would return NULL. 49 */ 50 public java.lang.String getDigitMapName() { 51 return this.digitMapDescriptor.getDigitMapName(); 52 } 53 54 /** 55 * The method can be used to get the embedded digit map value in the event 56 * descriptor. Only one of digit map name or digit map value shall be set. 57 * 58 * @return The reference to the embedded digitMap value. If this value is 59 * not set, then this method would return NULL. 60 */ 61 public DigitMapValue getDigitMapValue() { 62 return this.digitMapDescriptor.getDigitMapValue(); 63 } 64 65 /** 66 * The method can be used to get the embedded digit map value in the event 67 * descriptor. Only one of digit map name or digit map value shall be set. 68 * 69 * @return The reference to the embedded digitMap value. If this value is 70 * not set, then this method would return NULL. 71 */ 72 public java.lang.String getDigitMapValueStr() { 73 return this.digitMapDescriptor.getDigitMapValueStr(); 74 } 75 76 /** 77 * The method can be used to get stream id in the event descriptor. 78 * 79 * @return streamId - The integer value of the stream id shall be returned. 80 * This shall be returned only if the streamId is present in the 81 * event parameter of the event descriptor. 82 * @throws IllegalStateException 83 * - Thrown if streamId has not been set. Thus this method 84 * should be called only after verifying that the streamId is 85 * set using isStreamIdPresent() 86 */ 87 public int getStreamId() throws IllegalStateException { 88 if (streamId == null) { 89 throw new IllegalStateException("StreamId must be set."); 90 } 91 92 return this.streamId.intValue(); 93 } 94 95 /** 96 * The method can be used to set the signal descriptor within the event 97 * descriptor. 98 * 99 * @param signalDesc 100 * - The reference to the object corresponding to the signal 101 * descriptor. 102 * @throws IllegalArgumentException 103 * - Thrown if parameters set in the signal descriptor are such 104 * that the object cannot be set for the event descriptor. 105 */ 106 public void setSignalDescriptor(SignalDescriptor signalDesc) throws IllegalArgumentException { 107 // FIXME: add checks 108 this.signalDescriptor = signalDesc; 109 110 } 111 112 /** 113 * The method can be used to set the digit map name. Only one of digit map 114 * name or digit map value shall be set. This automatically sets the value 115 * of digitMap descriptor present in the event parameter object to true. If 116 * digitmap value is already set, then this method would raise an exception. 117 * 118 * @param digitMapName 119 * - The reference to the object corresponding to the digitMap 120 * name. 121 * @throws IllegalArgumentException 122 * - Thrown if digit Map value has already been set. The 123 * protocol allows only either of them but not both. 124 */ 125 public void setDigitMapName(java.lang.String digitMapName) throws IllegalArgumentException { 126 if (this.digitMapDescriptor.getDigitMapValue() != null) { 127 throw new IllegalArgumentException("Digit map value must not be present when name is set."); 128 } 129 this.digitMapDescriptor.setDigitMapName(digitMapName); 130 } 131 132 /** 133 * The method can be used to set the digit map value. Only one of digit map 134 * name or digit map value shall be set. This automatically sets the value 135 * of digitMap descriptor present in the event parameter object to true. If 136 * digitmap name is already set, then this method would raise an exception. 137 * 138 * @param digitMapValue 139 * - The reference to the object corresponding to the digitMap 140 * value. 141 * @throws IllegalArgumentException 142 * - Thrown if digit Map name has already been set. The protocol 143 * allows only either of them but not both. 144 */ 145 public void setDigitMapValue(DigitMapValue digitMapValue) throws IllegalArgumentException { 146 if (this.digitMapDescriptor.getDigitMapName() != null) { 147 throw new IllegalArgumentException("Digit map name must not be present when value is set."); 148 } 149 this.digitMapDescriptor.setDigitMapValue(digitMapValue); 150 } 151 152 /** 153 * The method can be used to set the digit map value. Only one of digit map 154 * name or digit map value shall be set. This automatically sets the value 155 * of digitMap descriptor present in the event parameter object to true. If 156 * digitmap name is already set, then this method would raise an exception. 157 * 158 * @param digitMapValue 159 * - The reference to the object corresponding to the digitMap 160 * value. 161 * @throws IllegalArgumentException 162 * - Thrown if digit Map name has already been set. The protocol 163 * allows only either of them but not both. 164 */ 165 public void setDigitMapValueStr(java.lang.String digitMapValue) throws IllegalArgumentException { 166 if (this.digitMapDescriptor.getDigitMapName() != null) { 167 throw new IllegalArgumentException("Digit map name must not be present when digit map string is set."); 168 } 169 this.digitMapDescriptor.setDigitMapValueStr(digitMapValue); 170 } 171 172 /** 173 * The method can be used to set stream id in the event descriptor. This 174 * automatically sets the value of stream id present in the event parameter 175 * object to true. 176 * 177 * @param streamId 178 * - The integer value of the stream id shall be set. 179 * @throws IllegalArgumentException 180 * - Thrown if streamId is set with an invalid value. 181 */ 182 public void setStreamId(int streamId) throws IllegalArgumentException { 183 // FIXME: what invalid value? 184 this.streamId = new Integer(streamId); 185 } 186 187 /** 188 * The method can be used to find if the stream id is present in the current 189 * object. 190 * 191 * @return Returns true if the stream id is present. This needs to be 192 * checked before getting the stream id from this object. 193 */ 194 public boolean isStreamIdPresent() { 195 return this.streamId != null; 196 } 197 198 /** 199 * The method can be used to set Keep Active flag in the event descriptor. 200 */ 201 public void setKeepActive() { 202 this.keepActive = new Boolean(true); 203 } 204 205 /** 206 * The method can be used to find if the Keep Active is present in the 207 * current object. 208 * 209 * @return Returns true if the Keep Active is present. 210 */ 211 public boolean isKeepActivePresent() { 212 return this.keepActive.booleanValue(); 213 } 214 215 @Override 216 public java.lang.String toString() { 217 return this.getClass().getSimpleName() + " : StreamId = " + this.streamId + " : KeepActive = " + this.keepActive + " : SignalDesc[ " + this.signalDescriptor + " ] : DigitMapDescriptor[ " 218 + this.digitMapDescriptor + " ]"; 219 } 220 221}