/protocols/jain-megaco/megaco-api/src/main/java/javax/megaco/ReturnStatus.java

http://mobicents.googlecode.com/ · Java · 66 lines · 46 code · 20 blank · 0 comment · 2 complexity · 16cdbe4a2ddb46e33a59822fc593f5c9 MD5 · raw file

  1. package javax.megaco;
  2. public class ReturnStatus {
  3. public static final int M_SUCCESS = 1;
  4. public static final int M_FAILURE = 2;
  5. public static final ReturnStatus SUCCESS = new ReturnStatus(M_SUCCESS);
  6. public static final ReturnStatus FAILURE = new ReturnStatus(M_FAILURE);
  7. private int return_status;
  8. private ReturnStatus(int return_status) {
  9. this.return_status = return_status;
  10. }
  11. public int getReturnStatus() {
  12. return this.return_status;
  13. }
  14. public static final ReturnStatus getObject(int value) throws IllegalArgumentException {
  15. ReturnStatus r = null;
  16. switch (value) {
  17. case M_SUCCESS:
  18. r = SUCCESS;
  19. break;
  20. case M_FAILURE:
  21. r = FAILURE;
  22. break;
  23. default:
  24. throw new IllegalArgumentException("No ReturnStatus for value " + value);
  25. }
  26. return r;
  27. }
  28. private Object readResolve() {
  29. return this.getObject(this.return_status);
  30. }
  31. @Override
  32. public String toString() {
  33. String r = null;
  34. switch (this.return_status) {
  35. case M_SUCCESS:
  36. r = "ReturnStatus[SUCCESS]";
  37. break;
  38. case M_FAILURE:
  39. r = "ReturnStatus[FAILURE]";
  40. break;
  41. default:
  42. r = "ReturnStatus[" + this.return_status + "]";
  43. }
  44. return r;
  45. }
  46. }