KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > sync4j > syncclient > sps > Record


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 package sync4j.syncclient.sps;
20
21 /**
22  * This class implements record definition Record contain those fields:
23  *
24  * <pre>
25  *
26  *
27  * key - record key
28  * state - record state ('N' new, 'U' update, 'D' deleted)
29  * content - record the blackberry contactuid
30  *
31  *
32  * </pre>
33  *
34  * @author Fabio Maggi @ Funambol
35  * @version $Id: Record.java,v 1.3 2005/01/19 10:58:32 fabius Exp $
36  *
37  */

38 public final class Record {
39
40     //----------------------------------------------------------------------------
41
// Private data
42

43     private static final String JavaDoc FIELD_SEPARATOR = "|";
44
45     private String JavaDoc key = null;
46
47     private char state = ' ';
48
49     private String JavaDoc uid = null;
50
51     //----------------------------------------------------------------------------
52
// Constructors
53

54     public Record(String JavaDoc allRecord) {
55
56         this.key = allRecord.substring(0, allRecord.indexOf(FIELD_SEPARATOR));
57         this.state = allRecord.substring(allRecord.indexOf(FIELD_SEPARATOR) + 1).charAt(0);
58         String JavaDoc tmp = allRecord.substring(allRecord.indexOf(FIELD_SEPARATOR) + 1);
59         this.uid = tmp.substring(tmp.indexOf(FIELD_SEPARATOR) + 1);
60
61     }
62
63     public Record(String JavaDoc key, char state, String JavaDoc uid) {
64         this.key = key;
65         this.state = state;
66         this.uid = uid;
67     }
68     
69     public Record(String JavaDoc key, char state) {
70         this.key = key;
71         this.state = state;
72     }
73
74      
75     public Record() {
76
77     }
78
79     /**
80      * obtains key associated with this record object.
81      * @param void
82      * @return String: key associated with this record object
83      */

84     public String JavaDoc getKey() {
85         return this.key;
86     }
87
88     /**
89      * Sets the value of key associated with this record object.
90      * @param String : key value to be set
91      * @return void.
92      */

93     public void setKey(String JavaDoc key) {
94         this.key = key;
95     }
96
97     /**
98      * obtains "state" associated with this record object.
99      * @param void
100      * @return Char: returns 'N'/'U'/'D'/'' if the record is New'N'/Udated'U'/Deleted'D'.
101      */

102     public char getState() {
103         return this.state;
104     }
105
106     /**
107      * Sets the value of "state" associated with this record object.
108      * @param char : 'N'/'U'/'D'/'' if the record is New'N'/Udated'U'/Deleted'D'.
109      * @return void.
110      */

111     public void setState(char state) {
112         this.state = state;
113     }
114
115     /**
116      * obtains the UID associated with this record object.
117      * @param void
118      * @return String: returns the UID of this record object
119      */

120     public String JavaDoc getUid() {
121         return this.uid;
122     }
123
124     /**
125      * Sets the value of "contactUID" associated with this record object.
126      * @param String : it is the UID associated with the blackberry contact object.
127      * @return void.
128      */

129     public void setUid(String JavaDoc uid) {
130         this.uid = uid;
131     }
132
133     /**
134      * Gives the string representation of this record
135      * @param void
136      * @return String.
137      */

138     public String JavaDoc toString() {
139         return this.key + FIELD_SEPARATOR + String.valueOf(this.state) + FIELD_SEPARATOR + this.uid;
140     }
141
142 }
Popular Tags