PageRenderTime 43ms CodeModel.GetById 37ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/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
23package org.mobicents.protocols.smpp.message;
24
25/**
26 * Message state enumeration.
27 * @version $Id: MessageState.java 452 2009-01-15 16:56:36Z orank $
28 * @since 0.4.0
29 */
30public class MessageState {
31    public static final MessageState SCHEDULED = new MessageState(0, false);
32    public static final MessageState EN_ROUTE = new MessageState(1, false);
33    public static final MessageState DELIVERED = new MessageState(2, true);
34    public static final MessageState EXPIRED = new MessageState(3, true);
35    public static final MessageState DELETED = new MessageState(4, true);
36    public static final MessageState UNDELIVERABLE = new MessageState(5, true);
37    public static final MessageState ACCEPTED = new MessageState(6, true);
38    public static final MessageState UNKNOWN = new MessageState(7, false);
39    public static final MessageState REJECTED = new MessageState(8, true);
40    public static final MessageState SKIPPED = new MessageState(9, true);
41    
42    private static final MessageState[] LOOKUP_TABLE = new MessageState[] {
43        SCHEDULED,
44        EN_ROUTE,
45        DELIVERED,
46        EXPIRED,
47        DELETED,
48        UNDELIVERABLE,
49        ACCEPTED,
50        UNKNOWN,
51        REJECTED,
52        SKIPPED,
53    };
54    
55    private final int value;
56    private final boolean isFinal;
57    
58    protected MessageState(int value, boolean isFinal) {
59        this.value = value;
60        this.isFinal = isFinal;
61    }
62
63    public int getValue() {
64        return value;
65    }
66    
67    public boolean isFinal() {
68        return isFinal;
69    }
70    
71    public static MessageState getMessageState(int value) {
72        try {
73            return LOOKUP_TABLE[value];
74        } catch (ArrayIndexOutOfBoundsException x) {
75            return null;
76        }
77    }
78    
79    @Override
80    public String toString() {
81        return Integer.toString(value);
82    }
83}