KickJava   Java API By Example, From Geeks To Geeks.

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


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 /**
25  * This class represents the <Meta> tag as defined by the SyncML
26  * representation specifications.
27  *
28  * @author Stefano Fornari @ Funambol
29  *
30  * @version $Id: Meta.java,v 1.5 2005/02/23 12:02:59 luigiafassina Exp $
31  *
32  */

33 public final class Meta implements java.io.Serializable JavaDoc {
34
35     // ------------------------------------------------------------ Private data
36
private MetInf metInf;
37
38     // ------------------------------------------------------------ Constructors
39

40     /**
41      * For serialization purposes
42      */

43     public Meta() {
44         set(
45             null,
46             null,
47             null,
48             null,
49             null,
50             null,
51             null,
52             null,
53             null,
54             null,
55             null
56         );
57     }
58
59     // ---------------------------------------------------------- Public methods
60

61     /**
62      * Returns the <i>metInf</i> object. If null, a new instance is created and
63      * stored in <i>metInf</i>
64      *
65      * @return the value of <i>metInf</i> or a new instance if <i>metInf</i> is null
66      */

67     public MetInf getMetInf() {
68         if (metInf == null) {
69             return (metInf = new MetInf());
70         }
71
72         return metInf;
73     }
74
75     /**
76      * Sets <i>metInf</i> to the given value.
77      *
78      * @param metInf the new <i>metInf</i> value
79      */

80     public void setMetInf(MetInf metInf) {
81         this.metInf = metInf;
82     }
83
84     /**
85      * This get method always returns null. This is a used in the JiBX mapping
86      * in order to do not output the MetInf element.
87      *
88      * @return always null
89      */

90     public MetInf getNullMetInf() {
91         return null;
92     }
93
94     /**
95      * Returns dateSize (in bytes)
96      *
97      * @return size
98      */

99     public Long JavaDoc getSize() {
100         return getMetInf().getSize();
101     }
102
103     /**
104      * Sets size
105      *
106      * @param size the new size value
107      */

108     public void setSize(Long JavaDoc size) {
109         getMetInf().setSize(size);
110     }
111
112     /**
113      * Returns format
114      *
115      * @return format
116      */

117     public String JavaDoc getFormat() {
118         return getMetInf().getFormat();
119     }
120
121     /**
122      * Sets format
123      *
124      * @param format the new format value
125      */

126     public void setFormat(String JavaDoc format) {
127         getMetInf().setFormat(format);
128     }
129
130     /**
131      * Returns type
132      *
133      * @return type
134      */

135     public String JavaDoc getType() {
136         return getMetInf().getType();
137     }
138
139     /**
140      * Sets type
141      *
142      * @param type the new type value
143      */

144     public void setType(String JavaDoc type) {
145         getMetInf().setType(type);
146     }
147
148     /**
149      * Returns mark
150      *
151      * @return mark
152      */

153     public String JavaDoc getMark() {
154         return getMetInf().getMark();
155     }
156
157     /**
158      * Sets mark
159      *
160      * @param mark the new mark value
161      */

162     public void setMark(String JavaDoc mark) {
163         getMetInf().setMark(mark);
164     }
165
166     /**
167      * Returns anchor
168      *
169      * @return anchor
170      */

171     public Anchor getAnchor() {
172         return getMetInf().getAnchor();
173     }
174
175     /**
176      * Sets anchor
177      *
178      * @param anchor the new anchor value
179      */

180     public void setAnchor(Anchor anchor) {
181         getMetInf().setAnchor(anchor);
182     }
183
184     /**
185      * Returns version
186      *
187      * @return version
188      */

189     public String JavaDoc getVersion() {
190         return getMetInf().getVersion();
191     }
192
193     /**
194      * Sets version
195      *
196      * @param version the new version value
197      */

198     public void setVersion(String JavaDoc version) {
199         getMetInf().setVersion(version);
200     }
201
202     /**
203      * Returns nextNonce
204      *
205      * @return nextNonce
206      */

207     public NextNonce getNextNonce() {
208         return getMetInf().getNextNonce();
209     }
210
211     /**
212      * Sets nextNonce
213      *
214      * @param nextNonce the new nextNonce value
215      */

216     public void setNextNonce(NextNonce nextNonce) {
217         getMetInf().setNextNonce(nextNonce);
218     }
219
220     /**
221      * Returns maxMsgSize
222      *
223      * @return maxMsgSize
224      */

225     public Long JavaDoc getMaxMsgSize() {
226         return getMetInf().getMaxMsgSize();
227     }
228
229     /**
230      * Sets maxMsgSize
231      *
232      * @param maxMsgSize the new maxMsgSize value
233      */

234     public void setMaxMsgSize(Long JavaDoc maxMsgSize) {
235         getMetInf().setMaxMsgSize(maxMsgSize);
236     }
237
238     /**
239      * Returns maxObjSize
240      *
241      * @return maxObjSize
242      */

243     public Long JavaDoc getMaxObjSize() {
244         return getMetInf().getMaxObjSize();
245     }
246
247     /**
248      * Sets maObjSize
249      *
250      * @param maxObjSize the new maxObjSize value
251      */

252     public void setMaxObjSize(Long JavaDoc maxObjSize) {
253         getMetInf().setMaxObjSize(maxObjSize);
254     }
255
256     /**
257      * Returns emi
258      *
259      * @return emi
260      */

261     public ArrayList getEMI() {
262         return getMetInf().getEMI();
263     }
264
265     /**
266      *
267      * This property is binding with set-method and there is a
268      * bug into JiBx: it uses the first method with the specified
269      * name without checking the parameter type.
270      * This method must be written before all other setEMI() methods
271      * to have a right marshalling.
272      *
273      * @param emi ArrayList of EMI object
274      */

275     public void setEMI(ArrayList emi) {
276         if (emi != null) {
277             getMetInf().getEMI().addAll(emi);
278         }
279     }
280
281     /**
282      * Returns mem
283      *
284      * @return mem
285      */

286     public Mem getMem() {
287         return getMetInf().getMem();
288     }
289
290     /**
291      * Sets mem
292      *
293      * @param mem the new mem value
294      */

295     public void setMem(Mem mem) {
296         getMetInf().setMem(mem);
297     }
298
299     // --------------------------------------------------------- Private methods
300

301     /**
302      * Sets all properties in once.
303      *
304      * @param format the encoding format
305      * @param type usually a MIME type
306      * @param mark the mark element
307      * @param sizeInBytes the data size in bytes
308      * @param anchor the Anchor
309      * @param version the data version
310      * @param nonce the next nonce value
311      * @param maxMsgSize the maximum message size in bytes
312      * @param emi experimental meta info
313      * @param memoryInfo memory information
314      *
315      */

316     private void set(final String JavaDoc format ,
317                      final String JavaDoc type ,
318                      final String JavaDoc mark ,
319                      final Long JavaDoc size ,
320                      final Anchor anchor ,
321                      final String JavaDoc version ,
322                      final NextNonce nonce ,
323                      final Long JavaDoc maxMsgSize,
324                      final Long JavaDoc maxObjSize,
325                      final EMI[] emi ,
326                      final Mem mem ) {
327
328         getMetInf(); // if still null, a new instance will be created
329

330         metInf.setFormat (format );
331         metInf.setType (type );
332         metInf.setMark (mark );
333         metInf.setAnchor (anchor );
334         metInf.setSize (size );
335         metInf.setVersion (version );
336         metInf.setNextNonce (nonce );
337         metInf.setMaxMsgSize (maxMsgSize);
338         metInf.setMaxObjSize (maxObjSize);
339         metInf.setMem (mem );
340         metInf.setEMI (emi );
341     }
342 }
343
Popular Tags