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