KickJava   Java API By Example, From Geeks To Geeks.

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


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 corresponds to <SyncType> tag in SyncML devinfo DTD
25  *
26  * @author Stefano Fornari @ Funambol
27  *
28  * @version $Id: SyncType.java,v 1.4 2005/06/07 16:51:07 luigiafassina Exp $
29  */

30 public final class SyncType
31 implements java.io.Serializable JavaDoc {
32     // --------------------------------------------------------------- Constants
33

34     public static final SyncType TWO_WAY = new SyncType(1);
35     public static final SyncType SLOW = new SyncType(2);
36     public static final SyncType ONE_WAY_FROM_CLIENT = new SyncType(3);
37     public static final SyncType REFRESH_FROM_CLIENT = new SyncType(4);
38     public static final SyncType ONE_WAY_FROM_SERVER = new SyncType(5);
39     public static final SyncType REFRESH_FROM_SERVER = new SyncType(6);
40     public static final SyncType SERVER_ALERTED = new SyncType(7);
41     
42     public static final SyncType[] ALL_SYNC_TYPES = new SyncType[] {
43         TWO_WAY, SLOW, ONE_WAY_FROM_CLIENT, REFRESH_FROM_CLIENT,
44         ONE_WAY_FROM_SERVER, REFRESH_FROM_SERVER, SERVER_ALERTED
45     };
46     
47     // ------------------------------------------------------------ Private data
48
private int syncType;
49     
50     // ------------------------------------------------------------ Constructors
51
/**
52      * In order to expose the server configuration like WS this constructor
53      * must be public
54      */

55     public SyncType() {}
56
57     /**
58      * Creates a new SyncType object with syncType value
59      *
60      * @param syncType the value of SyncType - NOT NULL
61      *
62      */

63     public SyncType(final int syncType) {
64         setType(syncType);
65     }
66     
67     // ---------------------------------------------------------- Public methods
68

69     /**
70      * Gets the synchronization type
71      *
72      * @return syncType the synchronization type
73      */

74     public int getType() {
75         return syncType;
76     }
77     
78     /**
79      * Sets the synchronization type
80      *
81      * @param syncType the synchronization type
82      */

83     public void setType(int syncType) {
84         this.syncType = syncType;
85     }
86
87     /**
88      * Gets the instance of synchronization type
89      *
90      * @return syncType the synchronization type
91      */

92     public static final SyncType getInstance(final int syncType) {
93         if ((syncType < 0) || (syncType >= ALL_SYNC_TYPES.length)) {
94             throw new IllegalArgumentException JavaDoc("unknown syncType: " + syncType);
95         }
96         return ALL_SYNC_TYPES[syncType-1];
97     }
98 }
Popular Tags