PageRenderTime 28ms CodeModel.GetById 11ms app.highlight 13ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://mobicents.googlecode.com/
Java | 123 lines | 96 code | 27 blank | 0 comment | 2 complexity | 3f063afb8b33ca7d1c6ed2dca73aa272 MD5 | raw file
  1package javax.megaco.message;
  2
  3import java.io.Serializable;
  4
  5public class CmdResponseType implements Serializable {
  6
  7	public static final int M_ADD_RESP = 1;
  8	public static final int M_MODIFY_RESP = 2;
  9	public static final int M_MOVE_RESP = 3;
 10	public static final int M_SERVICE_CHANGE_RESP = 4;
 11	public static final int M_NOTIFY_RESP = 5;
 12	public static final int M_AUDIT_VAL_RESP = 6;
 13	public static final int M_AUDIT_CAP_RESP = 7;
 14	public static final int M_SUBTRACT_RESP = 8;
 15
 16	public static final CmdResponseType ADD_RESP = new CmdResponseType(M_ADD_RESP);
 17	public static final CmdResponseType MODIFY_RESP = new CmdResponseType(M_MODIFY_RESP);
 18	public static final CmdResponseType MOVE_RESP = new CmdResponseType(M_MOVE_RESP);
 19	public static final CmdResponseType SERVICE_CHANGE_RESP = new CmdResponseType(M_SERVICE_CHANGE_RESP);
 20	public static final CmdResponseType NOTIFY_RESP = new CmdResponseType(M_NOTIFY_RESP);
 21	public static final CmdResponseType AUDIT_VAL_RESP = new CmdResponseType(M_AUDIT_VAL_RESP);
 22	public static final CmdResponseType AUDIT_CAP_RESP = new CmdResponseType(M_AUDIT_CAP_RESP);
 23	public static final CmdResponseType SUBTRACT_RESP = new CmdResponseType(M_SUBTRACT_RESP);
 24
 25	private int cmd_type;
 26
 27	private CmdResponseType(int cmd_type) {
 28		this.cmd_type = cmd_type;
 29	}
 30
 31	public int getResponseType() {
 32		return this.cmd_type;
 33	}
 34
 35	public static final CmdResponseType getObject(int value) throws IllegalArgumentException {
 36		CmdResponseType c = null;
 37		switch (value) {
 38		case M_ADD_RESP:
 39			c = ADD_RESP;
 40			break;
 41
 42		case M_MODIFY_RESP:
 43			c = MODIFY_RESP;
 44			break;
 45
 46		case M_MOVE_RESP:
 47			c = MOVE_RESP;
 48			break;
 49
 50		case M_SERVICE_CHANGE_RESP:
 51			c = SERVICE_CHANGE_RESP;
 52			break;
 53
 54		case M_NOTIFY_RESP:
 55			c = NOTIFY_RESP;
 56			break;
 57
 58		case M_AUDIT_VAL_RESP:
 59			c = AUDIT_VAL_RESP;
 60			break;
 61
 62		case M_AUDIT_CAP_RESP:
 63			c = AUDIT_CAP_RESP;
 64			break;
 65
 66		case M_SUBTRACT_RESP:
 67			c = SUBTRACT_RESP;
 68			break;
 69
 70		default:
 71			IllegalArgumentException illegalArgumentException = new IllegalArgumentException("No CmdResponseType found for value = " + value);
 72			throw illegalArgumentException;
 73		}
 74		return c;
 75	}
 76
 77	private Object readResolve() {
 78		return this.getObject(this.cmd_type);
 79	}
 80
 81	@Override
 82	public String toString() {
 83		String c = null;
 84		switch (this.cmd_type) {
 85		case M_ADD_RESP:
 86			c = "CmdResponseType[ADD_RESP]";
 87			break;
 88
 89		case M_MODIFY_RESP:
 90			c = "CmdResponseType[MODIFY_RESP]";
 91			break;
 92
 93		case M_MOVE_RESP:
 94			c = "CmdResponseType[MOVE_RESP]";
 95			break;
 96
 97		case M_SERVICE_CHANGE_RESP:
 98			c = "CmdResponseType[SERVICE_CHANGE_RESP]";
 99			break;
100
101		case M_NOTIFY_RESP:
102			c = "CmdResponseType[NOTIFY_RESP]";
103			break;
104
105		case M_AUDIT_VAL_RESP:
106			c = "CmdResponseType[AUDIT_VAL_RESP]";
107			break;
108
109		case M_AUDIT_CAP_RESP:
110			c = "CmdResponseType[AUDIT_CAP_RESP]";
111			break;
112
113		case M_SUBTRACT_RESP:
114			c = "CmdResponseType[SUBTRACT_RESP]";
115			break;
116
117		default:
118			c = "CmdResponseType[" + this.cmd_type + "]";
119		}
120		return c;
121	}
122
123}