PageRenderTime 24ms CodeModel.GetById 18ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/protocols/jain-megaco/megaco-api/src/main/java/javax/megaco/pkg/PkgItemType.java

http://mobicents.googlecode.com/
Java | 116 lines | 71 code | 15 blank | 30 comment | 2 complexity | 31eb35ef029461ab3afd366ba7b3dce1 MD5 | raw file
  1package javax.megaco.pkg;
  2
  3import java.io.Serializable;
  4
  5/**
  6 * Constants used in package javax.megaco.pkg for defining item types.
  7 * 
  8 * 
  9 */
 10public final class PkgItemType implements Serializable {
 11
 12	public static final int M_ALL = 1;
 13	public static final int M_EVENT = 2;
 14	public static final int M_SIGNAL = 3;
 15	public static final int M_STATISTICS = 4;
 16	public static final int M_PROPERTY = 5;
 17
 18	/**
 19	 * Identifies a package item type object that constructs the class with the
 20	 * constant M_ALL. Since it is reference to static final object, it prevents
 21	 * further instantiation of the same object in the system.
 22	 */
 23	public static final PkgItemType ALL = new PkgItemType(M_ALL);
 24
 25	/**
 26	 * Identifies a package item type object that constructs the class with the
 27	 * constant M_EVENT. Since it is reference to static final object, it
 28	 * prevents further instantiation of the same object in the system.
 29	 */
 30	public static final PkgItemType EVENT = new PkgItemType(M_EVENT);
 31
 32	/**
 33	 * Identifies a package item type object that constructs the class with the
 34	 * constant M_SIGNAL. Since it is reference to static final object, it
 35	 * prevents further instantiation of the same object in the system.
 36	 */
 37	public static final PkgItemType SIGNAL = new PkgItemType(M_SIGNAL);
 38
 39	/**
 40	 * Identifies a package item type object that constructs the class with the
 41	 * constant M_STATISTICS. Since it is reference to static final object, it
 42	 * prevents further instantiation of the same object in the system.
 43	 */
 44	public static final PkgItemType STATISTICS = new PkgItemType(M_STATISTICS);
 45
 46	/**
 47	 * Identifies a package item type object that constructs the class with the
 48	 * constant M_PROPERTY. Since it is reference to static final object, it
 49	 * prevents further instantiation of the same object in the system.
 50	 */
 51	public static final PkgItemType PROPERTY = new PkgItemType(M_PROPERTY);
 52
 53	private int type;
 54
 55	private PkgItemType(int type) {
 56		this.type = type;
 57	}
 58
 59	public int getPkgItemType() {
 60		return this.type;
 61	}
 62
 63	public static final PkgItemType getObject(int value) throws IllegalArgumentException {
 64		PkgItemType p = null;
 65		switch (value) {
 66		case M_ALL:
 67			p = ALL;
 68			break;
 69		case M_EVENT:
 70			p = EVENT;
 71			break;
 72		case M_SIGNAL:
 73			p = SIGNAL;
 74			break;
 75		case M_STATISTICS:
 76			p = STATISTICS;
 77			break;
 78		case M_PROPERTY:
 79			p = PROPERTY;
 80			break;
 81		default:
 82			throw new IllegalArgumentException("There is no PkgItemType for passed value = " + value);
 83		}
 84		return p;
 85	}
 86
 87	private Object readResolve() {
 88		return this.getObject(this.type);
 89	}
 90
 91	@Override
 92	public String toString() {
 93		String p = null;
 94		switch (this.type) {
 95		case M_ALL:
 96			p = "PkgItemType[ALL]";
 97			break;
 98		case M_EVENT:
 99			p = "PkgItemType[EVENT]";
100			break;
101		case M_SIGNAL:
102			p = "PkgItemType[SIGNAL]";
103			break;
104		case M_STATISTICS:
105			p = "PkgItemType[STATISTICS]";
106			break;
107		case M_PROPERTY:
108			p = "PkgItemType[PROPERTY]";
109			break;
110		default:
111			p = "PkgItemType[" + this.type + "]";
112		}
113		return p;
114	}
115
116}