KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.util.*;
23
24 import sync4j.framework.core.RepresentationException;
25
26 /**
27  * This class represents the <SyncML> tag as defined by the SyncML r
28  * epresentation specifications.
29  *
30  * @author Stefano Fornari @ Funambol
31  *
32  * @version $Id: SyncML.java,v 1.4 2005/03/02 20:57:37 harrie Exp $
33  */

34 public final class SyncML
35 implements java.io.Serializable JavaDoc {
36     
37     // ------------------------------------------------------------ Private data
38

39     private SyncHdr header;
40     private SyncBody body;
41     
42     // ------------------------------------------------------------ Constructors
43

44     /**
45      * For serialization purposes
46      */

47     protected SyncML(){};
48         
49     /**
50      * Creates a new SyncML object from header and body.
51      *
52      * @param header the SyncML header - NOT NULL
53      * @param body the SyncML body - NOT NULL
54      *
55      */

56     public SyncML(final SyncHdr header,
57                   final SyncBody body)
58     throws RepresentationException {
59         
60         setSyncHdr(header);
61         setSyncBody(body);
62     }
63
64     // ---------------------------------------------------------- Public methods
65

66     /**
67      * Returns the SyncML header
68      *
69      * @return the SyncML header
70      *
71      */

72     public SyncHdr getSyncHdr() {
73         return header;
74     }
75     
76     /**
77      * Sets the SyncML header
78      *
79      * @param header the SyncML header - NOT NULL
80      *
81      * @throws IllegalArgumentException if header is null
82      */

83     public void setSyncHdr(SyncHdr header) {
84         if (header == null) {
85             throw new IllegalArgumentException JavaDoc("header cannot be null");
86         }
87         this.header = header;
88     }
89     
90     /**
91      * Returns the SyncML body
92      *
93      * @return the SyncML body
94      *
95      */

96     public SyncBody getSyncBody() {
97         return body;
98     }
99     
100     /**
101      * Sets the SyncML body
102      *
103      * @param body the SyncML body - NOT NULL
104      *
105      * @throws IllegalArgumentException if body is null
106      */

107     public void setSyncBody(SyncBody body) {
108         if (body == null) {
109             throw new IllegalArgumentException JavaDoc("body cannot be null");
110         }
111         this.body = body;
112     }
113     
114     /**
115      * Is this message the last one of the package?
116      *
117      * @return lastMessage
118      */

119     public boolean isLastMessage() {
120         return body.isFinalMsg();
121     }
122     
123     /**
124      * Sets lastMessage
125      *
126      * @param lastMessage the new lastMessage value
127      *
128      */

129     public void setLastMessage() {
130         body.setFinalMsg(Boolean.TRUE);
131     }
132 }
133
Popular Tags