KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > sync4j > framework > core > AlertCode


1 /**
2  * Copyright (C) 2003-2005 Funambol
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  */

18
19
20 package sync4j.framework.core;
21
22
23 /**
24  * This class represents the possible alerts code.
25  *
26  * @author Stefano Fornari
27  *
28  * @version $Id: AlertCode.java,v 1.4 2005/03/02 20:57:37 harrie Exp $
29  *
30  */

31 public final class AlertCode {
32   public final static int DISPLAY = 100;
33   public final static int TWO_WAY = 200;
34   public final static int SLOW = 201;
35   public final static int ONE_WAY_FROM_CLIENT = 202;
36   public final static int REFRESH_FROM_CLIENT = 203;
37   public final static int ONE_WAY_FROM_SERVER = 204;
38   public final static int REFRESH_FROM_SERVER = 205;
39   public final static int TWO_WAY_BY_SERVER = 206;
40   public final static int ONE_WAY_FROM_CLIENT_BY_SERVER = 207;
41   public final static int REFRESH_FROM_CLIENT_BY_SERVER = 208;
42   public final static int ONE_WAY_FROM_SERVER_BY_SERVER = 209;
43   public final static int REFRESH_FROM_SERVER_BY_SERVER = 210;
44   public final static int RESULT_ALERT = 221;
45   public final static int NEXT_MESSAGE = 222;
46   public final static int NO_END_OF_DATA = 223;
47
48   private AlertCode() {}
49   
50   /**
51    * Determines if the given code is an initialization code, such as one of:
52    * <ul>
53    * <li> TWO_WAY
54    * <li> SLOW
55    * <li> ONE_WAY_FROM_CLIENT
56    * <li> REFRESH_FROM_CLIENT
57    * <li> ONE_WAY_FROM_SERVER
58    * <li> REFRESH_FROM_SERVER
59    * <li> TWO_WAY_BY_SERVER
60    * <li> ONE_WAY_FROM_CLIENT_BY_SERVE
61    * <li> REFRESH_FROM_CLIENT_BY_SERVER
62    * <li> ONE_WAY_FROM_SERVER_BY_SERVER
63    * <li> REFRESH_FROM_SERVER_BY_SERVER
64    * </ul>
65    *
66    * @param code the code to be checked
67    *
68    * @return true if the code is an initialization code, false otherwise
69    */

70   static public boolean isInitializationCode(int code) {
71       return ( (code == TWO_WAY )
72              || (code == SLOW )
73              || (code == ONE_WAY_FROM_CLIENT )
74              || (code == REFRESH_FROM_CLIENT )
75              || (code == ONE_WAY_FROM_SERVER )
76              || (code == REFRESH_FROM_SERVER )
77              || (code == TWO_WAY_BY_SERVER )
78              || (code == ONE_WAY_FROM_CLIENT_BY_SERVER)
79              || (code == REFRESH_FROM_CLIENT_BY_SERVER)
80              || (code == ONE_WAY_FROM_SERVER_BY_SERVER)
81              || (code == REFRESH_FROM_SERVER_BY_SERVER)
82              );
83   }
84   
85   /**
86    * Determines if the given code represents a client only action, such as is
87    * one of:
88    * <ul>
89    * <li>ONE_WAY_FROM_CLIENT</li>
90    * <li>REFRESH_FROM_CLIENT</li>
91    * </ul>
92    *
93    * @param code the code to be checked
94    *
95    * @return true if the code represents a client only action, false otherwise
96    */

97   static public boolean isClientOnlyCode(int code) {
98       return ( (code == ONE_WAY_FROM_CLIENT)
99              || (code == REFRESH_FROM_CLIENT)
100              );
101   }
102
103 }
104
Popular Tags