Mercurial > hg > RemoteEditor > REPSessionManager
diff rep/REP.java @ 271:5b7abc22e61a
enum
author | kono |
---|---|
date | Thu, 11 Sep 2008 17:23:27 +0900 |
parents | d557252092e3 |
children | 0585fd2410b8 |
line wrap: on
line diff
--- a/rep/REP.java Thu Sep 11 15:08:06 2008 +0900 +++ b/rep/REP.java Thu Sep 11 17:23:27 2008 +0900 @@ -1,56 +1,82 @@ package rep; -public class REP { - public static final int REPCMD_OPEN = 1; - public static final int REPCMD_OPEN_ACK = 2; - public static final int REPCMD_READ = 3; - public static final int REPCMD_READ_ACK = 4; - public static final int REPCMD_INSERT = 6; - public static final int REPCMD_INSERT_ACK = 7; - public static final int REPCMD_DELETE = 9; - public static final int REPCMD_DELETE_ACK = 10; - public static final int REPCMD_CLOSE = 11; - public static final int REPCMD_CLOSE_2 = 12; - public static final int REPCMD_REPLACE = 13; - public static final int REPCMD_REPLACE_ACK = 14; - public static final int REPCMD_NOP = 15; - public static final int SMCMD_JOIN = 41; - public static final int SMCMD_JOIN_ACK = 42; - public static final int SMCMD_GET = 43; - public static final int SMCMD_GET_ACK = 44; - public static final int SMCMD_PUT = 45; - public static final int SMCMD_PUT_ACK = 46; - public static final int SMCMD_SELECT = 47; - public static final int SMCMD_SELECT_ACK = 48; - public static final int SMCMD_REGISTER = 49; - public static final int SMCMD_REGISTER_ACK = 50; - public static final int SMCMD_DEREGISTER = 51; - public static final int SMCMD_DEREGISTER_ACK= 52; - public static final int SMCMD_QUIT = 53; - public static final int SMCMD_QUIT_ACK = 54; - public static final int SMCMD_SESSION = 60; - public static final int SMCMD_SESSION_ACK = 61; - public static final int SMCMD_SM_JOIN = 62; - public static final int SMCMD_SM_JOIN_ACK = 63; - public static final int SMCMD_UPDATE = 65; - public static final int SMCMD_UPDATE_ACK = 66; - public static final int SMCMD_GET_UNDO = 71; - public static final int SMCMD_GET_UNDO_ACK = 72; +public enum REP { + REPCMD_OPEN ( 1), + REPCMD_OPEN_ACK ( 2), + REPCMD_READ ( 3), + REPCMD_READ_ACK ( 4), + REPCMD_INSERT ( 6), + REPCMD_INSERT_ACK ( 7), + REPCMD_DELETE ( 9), + REPCMD_DELETE_ACK ( 10), + REPCMD_CLOSE ( 11), + REPCMD_CLOSE_2 ( 12), + REPCMD_REPLACE ( 13), + REPCMD_REPLACE_ACK ( 14), + REPCMD_NOP ( 15), + SMCMD_JOIN ( 41), + SMCMD_JOIN_ACK ( 42), + SMCMD_GET ( 43), + SMCMD_GET_ACK ( 44), + SMCMD_PUT ( 45), + SMCMD_PUT_ACK ( 46), + SMCMD_SELECT ( 47), + SMCMD_SELECT_ACK ( 48), + SMCMD_REGISTER ( 49), + SMCMD_REGISTER_ACK ( 50), + SMCMD_DEREGISTER ( 51), + SMCMD_DEREGISTER_ACK( 52), + SMCMD_QUIT ( 53), + SMCMD_QUIT_ACK ( 54), + SMCMD_SESSION ( 60), + SMCMD_SESSION_ACK ( 61), + SMCMD_SM_JOIN ( 62), + SMCMD_SM_JOIN_ACK ( 63), + SMCMD_UPDATE ( 65), + SMCMD_UPDATE_ACK ( 66), + SMCMD_GET_UNDO ( 71), + SMCMD_GET_UNDO_ACK ( 72), - public static final int SMCMD_UNDO_REPLACE = 73; - public static final int SMCMD_START_MERGE = 75; - public static final int SMCMD_START_MERGE_ACK = 76; - public static final int SMCMD_END_MERGE = 77; - public static final int SMCMD_QUIT_2 = 78; + SMCMD_UNDO_REPLACE ( 73), + SMCMD_START_MERGE ( 75), + SMCMD_START_MERGE_ACK ( 76), + SMCMD_END_MERGE ( 77), + SMCMD_QUIT_2 ( 78), - public static final int MERGE_EID = -2; - public static final int SMCMD_CH_MASTER = 79; - public static final int SMCMD_UPDATE_UP = 80; - public static final int SMCMD_UPDATE_DOWN = 81; + MERGE_EID ( -2), + SMCMD_CH_MASTER ( 79), + SMCMD_UPDATE_UP ( 80), + SMCMD_UPDATE_DOWN ( 81), + + SMCMD_SYNC ( 82), + SMCMD_SYNC_ACK ( 83); + + public final int id; + + REP(int id) { + this.id = id; + } + + static int max = 0; + static int min = 100; - public static final int SMCMD_SYNC = 82; - public static final int SMCMD_SYNC_ACK = 83; - + static REP rep[] ; + static { + // Certainly this is ridiculous... + for (REP r : REP.values()) { + if (max<r.id) max = r.id; + if (min>r.id) min = r.id; + } + rep = new REP[max-min+1]; + for (REP r : REP.values()) { + rep[r.id-min] = r; + } + } + + public static REP newREP(int id) { + // return new REP(id); this does not work... + return rep[id-min]; + } }