001 /**
002 * Copyright 2007 Mike Kroutikov.
003 *
004 * This program is free software; you can redistribute it and/or modify
005 * it under the terms of the Lesser GNU General Public License as
006 * published by the Free Software Foundation; either version 3 of
007 * the License, or (at your option) any later version.
008 *
009 * This program is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
012 * Lesser GNU General Public License for more details.
013 *
014 * You should have received a copy of the Lesser GNU General Public License
015 * along with this program. If not, see <http://www.gnu.org/licenses/>.
016 */
017
018 package org.otfeed.protocol;
019
020 import java.util.HashMap;
021 import java.util.Map;
022
023 /**
024 * Enumerates command types (request and response types).
025 */
026 public enum CommandEnum {
027
028 LOGIN (1),
029 LOGOUT (2),
030
031 REQUEST_TICK_STREAM (3),
032 REQUEST_TICK_STREAM_EX (15),
033 CANCEL_TICK_STREAM (4),
034
035 REQUEST_HIST_DATA (5),
036 REQUEST_HIST_TICKS (17),
037 CANCEL_HIST_DATA (6),
038
039 REQUEST_LIST_EXCHANGES (7),
040 REQUEST_LIST_SYMBOLS (8),
041
042 HEARTBEAT (9),
043
044 REQUEST_EQUITY_INIT (10),
045 REQUEST_OPTION_CHAIN (11),
046 REQUEST_OPTION_CHAIN_EX (16),
047 CANCEL_OPTION_CHAIN (12),
048
049 REQUEST_BOOK_STREAM (13),
050 REQUEST_BOOK_STREAM_EX (21),
051 CANCEL_BOOK_STREAM (14),
052
053 REQUEST_SPLITS (18),
054 REQUEST_DIVIDENDS (19),
055
056 REQUEST_HIST_BOOKS (20),
057
058 REQUEST_OPTION_CHAIN_U (22),
059 REQUEST_OPTION_INIT (23),
060 REQUEST_LIST_SYMBOLS_EX (24),
061
062 REQUEST_TICK_SNAPSHOT (25),
063 REQUEST_OPTION_CHAIN_SNAPSHOT (26);
064
065 public final int code;
066 private CommandEnum(int code) {
067 this.code = code;
068 }
069
070 public static final Map<Integer,CommandEnum> decoder
071 = new HashMap<Integer,CommandEnum>();
072 static {
073 CommandEnum []v = values();
074 for(int i = 0; i < v.length; i++) {
075 if(decoder.put(v[i].code, v[i]) != null) {
076 throw new AssertionError("duplicate code for " + v[i]);
077 }
078 }
079 }
080 }