PageRenderTime 24ms CodeModel.GetById 12ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://mobicents.googlecode.com/
Java | 169 lines | 62 code | 31 blank | 76 comment | 2 complexity | e6ea624fa64caa97dd4bf386109f05ea MD5 | raw file
  1package javax.megaco.message.descriptor;
  2
  3import java.io.Serializable;
  4
  5/**
  6 * Mux type constants used in package javax.megaco.message.descriptor. This
  7 * defines the mux type for the megaco package.
  8 */
  9public class MuxType implements Serializable {
 10
 11	/**
 12	 * Identifies mux type to be h221. Its value shall be set to 0.
 13	 */
 14	public static final int M_H221 = 0;
 15
 16	/**
 17	 * Identifies mux type to be h223. Its value shall be set to 1.
 18	 */
 19	public static final int M_H223 = 1;
 20
 21	/**
 22	 * Identifies mux type to be "h226". Its value shall be set to 2.
 23	 */
 24	public static final int M_H226 = 2;
 25
 26	/**
 27	 * Identifies mux type to be "v76". Its value shall be set to 3.
 28	 */
 29	public static final int M_V76 = 3;
 30
 31	/**
 32	 * Identifies mux type to be "extension". Its value shall be set to 4.
 33	 */
 34	public static final int M_EXT = 4;
 35
 36	/**
 37	 * Identifies a Mux Type object that constructs the class with the constant
 38	 * M_H221. Since it is reference to static final object, it
 39	 * prevents further instantiation of the same object in the system.
 40	 */
 41	public static final MuxType H221
 42
 43	= new MuxType(M_H221);
 44
 45	/**
 46	 * Identifies a Mux Type object that constructs the class with the constant
 47	 * M_H223. Since it is reference to static final object, it
 48	 * prevents further instantiation of the same object in the system.
 49	 */
 50	public static final MuxType H223
 51
 52	= new MuxType(M_H223);
 53
 54	/**
 55	 * Identifies a Mux Type object that constructs the class with the constant
 56	 * M_H226. Since it is reference to static final object, it
 57	 * prevents further instantiation of the same object in the system.
 58	 */
 59	public static final MuxType H226
 60
 61	= new MuxType(M_H226);
 62
 63	/**
 64	 * Identifies a Mux Type object that constructs the class with the constant
 65	 * M_V76. Since it is reference to static final object, it prevents
 66	 * further instantiation of the same object in the system.
 67	 */
 68	public static final MuxType V76
 69
 70	= new MuxType(M_V76);
 71
 72	/**
 73	 * Identifies a Mux Type object that constructs the class with the constant
 74	 * M_EXT. Since it is reference to static final object, it prevents
 75	 * further instantiation of the same object in the system.
 76	 */
 77	public static final MuxType EXT
 78
 79	= new MuxType(M_EXT);
 80
 81	private int muxType = -1;
 82
 83	/**
 84	 * Constructs an class that specifies the mux type in the Mux descriptor.
 85	 * 
 86	 * @param mux_type
 87	 */
 88	private MuxType(int mux_type) {
 89		this.muxType = mux_type;
 90	}
 91
 92	/**
 93	 * This method returns one of the static field constants defined in this
 94	 * class.
 95	 * 
 96	 * @return Returns an integer value that identifies the mux type to be one
 97	 *         of h221 or h223 or h226 or v26 or extension.
 98	 */
 99	public int getMuxType() {
100		return this.muxType;
101	}
102
103	/**
104	 * Returns reference of the MuxType object that identifies the mux type as
105	 * value passed to this method.
106	 * 
107	 * @param value
108	 *            - It is one of the possible values of the static constant that
109	 *            this class provides.
110	 * @return Returns reference of the MuxType object.
111	 * @throws IllegalArgumentException
112	 *             - If the value passed to this method is invalid, then this
113	 *             exception is raised.
114	 */
115	public static final MuxType getObject(int value) throws IllegalArgumentException {
116
117		switch (value) {
118
119		case M_EXT:
120			return EXT;
121		case M_H221:
122			return H221;
123		case M_H223:
124			return H223;
125		case M_H226:
126			return H226;
127		case M_V76:
128			return V76;
129
130		default:
131			throw new IllegalArgumentException("Wrong mux type passed: " + value);
132
133		}
134	}
135
136	/**
137	 * This method must be implemented to perform instance substitution during
138	 * serialization. This method is required for reference comparison. This
139	 * method if not implimented will simply fail each time we compare an
140	 * Enumeration value against a de-serialized Enumeration instance.
141	 * 
142	 * @return
143	 */
144	private Object readResolve() {
145		return getObject(this.muxType);
146	}
147
148	@Override
149	public String toString() {
150		switch (this.muxType) {
151
152		case M_EXT:
153			return "MuxType[EXT]";
154		case M_H221:
155			return "MuxType[H221]";
156		case M_H223:
157			return "MuxType[H223]";
158		case M_H226:
159			return "MuxType[H226]";
160		case M_V76:
161			return "MuxType[V76]";
162
163		default:
164			return "MuxType[" + this.muxType + "]";
165
166		}
167	}
168
169}