PageRenderTime 76ms CodeModel.GetById 69ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://mobicents.googlecode.com/
Java | 103 lines | 39 code | 17 blank | 47 comment | 2 complexity | 23909bad421e056637c9435c6569c694 MD5 | raw file
  1package javax.megaco.message.descriptor;
  2
  3import java.io.Serializable;
  4
  5/**
  6 * Signal Param type class defines all the static constants for the signal param
  7 * type for the megaco package.
  8 */
  9public class SignalParamType implements Serializable {
 10
 11	/**
 12	 * Identifies signal param type to be list. Its value shall be set to 1.
 13	 */
 14	public static final int M_LIST = 1;
 15
 16	/**
 17	 * Identifies signal param type to be request. Its value shall be set to 2.
 18	 */
 19	public static final int M_REQUEST = 2;
 20
 21	/**
 22	 * Identifies a MegacoSignalParamType object that constructs the class with
 23	 * the constant M_LIST. Since it is reference to static final
 24	 * object, it prevents further instantiation of the same object in the
 25	 * system.
 26	 */
 27	public static final SignalParamType LIST = new SignalParamType(M_LIST);
 28
 29	/**
 30	 * Identifies a MegacoSignalParamType object that constructs the class with
 31	 * the constant M_REQUEST. Since it is reference to static
 32	 * final object, it prevents further instantiation of the same object in the
 33	 * system.
 34	 */
 35	public static final SignalParamType REQUEST = new SignalParamType(M_REQUEST);
 36
 37	private int signalParamType = -1;
 38
 39	/**
 40	 * Constructs an class that specifies the signal param type in the signal
 41	 * descriptor.
 42	 * 
 43	 * @param signal_type
 44	 */
 45	private SignalParamType(int type) {
 46		this.signalParamType = type;
 47	}
 48
 49	/**
 50	 * This method returns one of the static field constants defined in this
 51	 * class.
 52	 * 
 53	 * @return Returns an integer value that identifies the signal type to be
 54	 *         one of brief or on-off or other.
 55	 */
 56	public int getsignalParamType() {
 57		return this.signalParamType;
 58	}
 59
 60	/**
 61	 * Returns reference of the SignalParamType object that identifies the
 62	 * signal type as value passed to this method.
 63	 * 
 64	 * @param value
 65	 *            - It is one of the possible values of the static constant that
 66	 *            this class provides.
 67	 * @return Returns reference of the signalParamType object.
 68	 * @throws IllegalArgumentException
 69	 *             - If the value passed to this method is invalid, then this
 70	 *             exception is raised.
 71	 */
 72	public static final SignalParamType getObject(int value) throws IllegalArgumentException {
 73
 74		switch (value) {
 75		case M_LIST:
 76			return LIST;
 77		case M_REQUEST:
 78			return REQUEST;
 79
 80		default:
 81			throw new IllegalArgumentException("Wrong signal param type passed: " + value);
 82		}
 83
 84	}
 85
 86	private Object readResolve() {
 87		return this.getObject(this.signalParamType);
 88	}
 89
 90	@Override
 91	public String toString() {
 92		switch (this.signalParamType) {
 93		case M_LIST:
 94			return "SignalParamType[LIST]";
 95		case M_REQUEST:
 96			return "SignalParamType[REQUEST]";
 97
 98		default:
 99			return "SignalParamType[" + this.signalParamType + "]";
100		}
101	}
102
103}