KickJava   Java API By Example, From Geeks To Geeks.

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


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 import sync4j.framework.core.*;
23
24 /**
25  * Corresponds to the <SyncHdr> element in the SyncML represent DTD
26  *
27  * @author Stefano Fornari @ Funambol
28  *
29  * @see SyncBody
30  *
31  * @version $Id: SyncHdr.java,v 1.4 2005/03/02 20:57:37 harrie Exp $
32  */

33 public class SyncHdr
34 implements java.io.Serializable JavaDoc {
35     
36     // --------------------------------------------------------------- Constants
37
public static final String JavaDoc COMMAND_NAME = "SyncHdr";
38
39     // ------------------------------------------------------------ Private data
40

41     private VerDTD verDTD ;
42     private VerProto verProto ;
43     private SessionID sessionID;
44     private String JavaDoc msgID ;
45     private Target target ;
46     private Source source ;
47     private String JavaDoc respURI ;
48     private Boolean JavaDoc noResp ;
49     private Cred cred ;
50     private Meta meta ;
51
52     // ------------------------------------------------------------ Constructors
53

54     /** For serialization purposes */
55     protected SyncHdr(){}
56
57     /**
58      * Creates a nee SyncHdr object
59      *
60      * @param verDTD SyncML DTD version - NOT NULL
61      * @param verProto SyncML protocol version - NOT NULL
62      * @param sessionID sync session identifier - NOT NULL
63      * @param msgID message ID - NOT NULL
64      * @param target target URI - NOT NULL
65      * @param source source URI - NOT NULL
66      * @param respURI may be null.
67      * @param noResp true if no response is required
68      * @param cred credentials. May be null.
69      * @param meta may be null.
70      *
71      */

72     public SyncHdr(final VerDTD verDTD,
73                    final VerProto verProto,
74                    final SessionID sessionID,
75                    final String JavaDoc msgID,
76                    final Target target,
77                    final Source source,
78                    final String JavaDoc respURI,
79                    final boolean noResp,
80                    final Cred cred,
81                    final Meta meta) {
82
83         setMsgID(msgID);
84         setVerDTD(verDTD);
85         setVerProto(verProto);
86         setSessionID(sessionID);
87         setTarget(target);
88         setSource(source);
89
90         this.noResp = (noResp) ? new Boolean JavaDoc(noResp) : null;
91         this.respURI = respURI;
92
93         this.cred = cred;
94         this.meta = meta;
95     }
96
97     // ---------------------------------------------------------- Public methods
98

99     /**
100      * Gets the DTD version
101      *
102      * @return verDTD the DTD version
103      */

104     public VerDTD getVerDTD() {
105         return verDTD;
106     }
107
108     /**
109      * Sets the DTD version
110      *
111      * @param verDTD the DTD version
112      *
113      */

114     public void setVerDTD(VerDTD verDTD) {
115         if (verDTD == null) {
116             throw new IllegalArgumentException JavaDoc("verDTD cannot be null");
117         }
118         this.verDTD = verDTD;
119     }
120
121     /**
122      * Gets the protocol version
123      *
124      * @return verProto the protocol version
125      */

126     public VerProto getVerProto() {
127         return verProto;
128     }
129
130     /**
131      * Sets the protocol version
132      *
133      * @param verProto the protocol version
134      */

135     public void setVerProto(VerProto verProto) {
136         if (verProto == null) {
137             throw new IllegalArgumentException JavaDoc("verProto cannot be null");
138         }
139         this.verProto = verProto;
140     }
141
142     /**
143      * Gets the session identifier
144      *
145      * @return sessionID the session identifier
146      */

147     public SessionID getSessionID() {
148         return sessionID;
149     }
150
151     /**
152      * Sets the session identifier
153      *
154      * @param sessionID the session identifier
155      *
156      */

157     public void setSessionID(SessionID sessionID) {
158         if (sessionID == null) {
159             throw new IllegalArgumentException JavaDoc("sessionID cannot be null");
160         }
161         this.sessionID = sessionID;
162     }
163
164     /**
165      * Gets the message identifier
166      *
167      * @return msgID the message identifier
168      */

169     public String JavaDoc getMsgID() {
170         return msgID;
171     }
172
173     /**
174      * Sets the message identifier
175      *
176      * @param msgID the message identifier
177      */

178     public void setMsgID(String JavaDoc msgID) {
179         if (msgID == null || msgID.length() == 0) {
180             throw new IllegalArgumentException JavaDoc(
181                                           "msgID cannot be null or empty");
182         }
183         this.msgID = msgID;
184     }
185
186     /**
187      * Gets the Target object
188      *
189      * @return target the Target object
190      */

191     public Target getTarget() {
192         return target;
193     }
194
195     /**
196      * Sets the Target object
197      *
198      * @param target the Target object
199      */

200     public void setTarget(Target target) {
201         if (target == null) {
202             throw new IllegalArgumentException JavaDoc("target cannot be null");
203         }
204         this.target = target;
205     }
206
207     /**
208      * Gets the Source object
209      *
210      * @return source the Source object
211      */

212     public Source getSource() {
213         return source;
214     }
215
216     /**
217      * Sets the Source object
218      *
219      * @param source the Source object
220      */

221     public void setSource(Source source) {
222         if (source == null) {
223             throw new IllegalArgumentException JavaDoc("source cannot be null");
224         }
225         this.source = source;
226     }
227
228     /**
229      * Gets the response URI
230      *
231      * @return respURI the response URI
232      */

233     public String JavaDoc getRespURI() {
234         return respURI;
235     }
236
237     /**
238      * Sets the response URI.
239      *
240      * @param uri the new response URI; NOT NULL
241      */

242     public void setRespURI(String JavaDoc uri) {
243         this.respURI = uri;
244     }
245
246     /**
247      * Gets noResp property
248      *
249      * @return true if the command doesn't require a response, false otherwise
250      */

251     public boolean isNoResp() {
252         return (noResp != null);
253     }
254
255     /**
256      * Gets the Boolean value of noResp
257      *
258      * @return true if the command doesn't require a response, null otherwise
259      */

260     public Boolean JavaDoc getNoResp() {
261         if (!noResp.booleanValue()) {
262             return null;
263         }
264         return noResp;
265     }
266
267     /**
268      * Sets the noResponse property
269      *
270      * @param noResp the noResponse property
271      */

272     public void setNoResp(Boolean JavaDoc noResp) {
273         this.noResp = (noResp.booleanValue()) ? noResp : null;
274     }
275
276     /**
277      * Gets the Credential property
278      *
279      * @return cred the Credential property
280      */

281     public Cred getCred() {
282         return cred;
283     }
284
285     /**
286      * Sets the Credential property
287      *
288      * @param cred the Credential property
289      */

290     public void setCred(Cred cred) {
291         this.cred = cred;
292     }
293
294     /**
295      * Gets the Meta property
296      *
297      * @return meta the Meta property
298      */

299     public Meta getMeta() {
300         return meta;
301     }
302
303     /**
304      * Sets the Meta property
305      *
306      * @param meta the Meta property
307      */

308     public void setMeta(Meta meta) {
309         this.meta = meta;
310     }
311 }
Popular Tags