/protocols/smpp/src/main/java/org/mobicents/protocols/smpp/message/MessageState.java

http://mobicents.googlecode.com/ · Java · 83 lines · 48 code · 9 blank · 26 comment · 0 complexity · 260063d303a605289d96f9c3510d897d MD5 · raw file

  1. /*
  2. * JBoss, Home of Professional Open Source
  3. * Copyright 2011, Red Hat, Inc. and individual contributors
  4. * by the @authors tag. See the copyright.txt in the distribution for a
  5. * full listing of individual contributors.
  6. *
  7. * This is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU Lesser General Public License as
  9. * published by the Free Software Foundation; either version 2.1 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This software is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this software; if not, write to the Free
  19. * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  20. * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  21. */
  22. package org.mobicents.protocols.smpp.message;
  23. /**
  24. * Message state enumeration.
  25. * @version $Id: MessageState.java 452 2009-01-15 16:56:36Z orank $
  26. * @since 0.4.0
  27. */
  28. public class MessageState {
  29. public static final MessageState SCHEDULED = new MessageState(0, false);
  30. public static final MessageState EN_ROUTE = new MessageState(1, false);
  31. public static final MessageState DELIVERED = new MessageState(2, true);
  32. public static final MessageState EXPIRED = new MessageState(3, true);
  33. public static final MessageState DELETED = new MessageState(4, true);
  34. public static final MessageState UNDELIVERABLE = new MessageState(5, true);
  35. public static final MessageState ACCEPTED = new MessageState(6, true);
  36. public static final MessageState UNKNOWN = new MessageState(7, false);
  37. public static final MessageState REJECTED = new MessageState(8, true);
  38. public static final MessageState SKIPPED = new MessageState(9, true);
  39. private static final MessageState[] LOOKUP_TABLE = new MessageState[] {
  40. SCHEDULED,
  41. EN_ROUTE,
  42. DELIVERED,
  43. EXPIRED,
  44. DELETED,
  45. UNDELIVERABLE,
  46. ACCEPTED,
  47. UNKNOWN,
  48. REJECTED,
  49. SKIPPED,
  50. };
  51. private final int value;
  52. private final boolean isFinal;
  53. protected MessageState(int value, boolean isFinal) {
  54. this.value = value;
  55. this.isFinal = isFinal;
  56. }
  57. public int getValue() {
  58. return value;
  59. }
  60. public boolean isFinal() {
  61. return isFinal;
  62. }
  63. public static MessageState getMessageState(int value) {
  64. try {
  65. return LOOKUP_TABLE[value];
  66. } catch (ArrayIndexOutOfBoundsException x) {
  67. return null;
  68. }
  69. }
  70. @Override
  71. public String toString() {
  72. return Integer.toString(value);
  73. }
  74. }