/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

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