KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > sync4j > framework > tools > SizeCalculator


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 package sync4j.framework.tools;
19
20 import java.io.*;
21 import java.util.ArrayList JavaDoc;
22
23 import sync4j.framework.core.*;
24
25 /**
26  * Utility class for calculate the XML size and WBXML size of framework Objects
27  *
28  * @author Luigia Fassina @ Funambol
29  * @version $Id: SizeCalculator.java,v 1.1 2005/05/16 17:32:56 nichele Exp $
30  */

31 public class SizeCalculator {
32
33     // ---------------------------------------------------------- Public methods
34

35     // ------------------------------------------------------------------ SyncML
36
/**
37      * Returns the XML overhead for SyncML object
38      * sizeof(<SyncML xmlns='SYNCML:SYNCML1.1'>\n</SyncML>\n)
39      *
40      * @return overhead for SyncML object
41      */

42     public static long getXMLOverheadSyncML() {
43         return 43;
44     }
45     
46     /**
47      * Returns the WBXML overhead for SyncML object
48      * sizeof(<SyncML xmlns='SYNCML:SYNCML1.1'>\n</SyncML>\n)
49      *
50      * @return overhead for SyncML object
51      */

52     public static long getWBXMLOverheadSyncML() {
53         return 29;
54     }
55     
56     /**
57      * Returns the XML size of the SyncML object
58      * sizeof(<SyncML xmlns='SYNCML:SYNCML1.1'>\n) +
59      * sizeof(syncHdr) +
60      * sizeof(syncBody) +
61      * sizeof(</SyncML>)
62      *
63      * @param syncML the SyncML element
64      *
65      * @return size the XML size of the SyncML element
66      */

67     public static long getXMLSize(SyncML syncML) {
68         SyncHdr syncHdr = syncML.getSyncHdr() ;
69         SyncBody syncBody = syncML.getSyncBody();
70
71         return 43
72              + getXMLSize(syncHdr )
73              + getXMLSize(syncBody)
74              ;
75     }
76
77     /**
78      * Returns the WBXML size of the SyncML object
79      *
80      * @param syncML the SyncML element
81      *
82      * @return size the WBXML size of the SyncML element
83      */

84     public static long getWBXMLSize(SyncML syncML) {
85         SyncHdr syncHdr = syncML.getSyncHdr() ;
86         SyncBody syncBody = syncML.getSyncBody();
87
88         return 29
89              + getWBXMLSize(syncHdr )
90              + getWBXMLSize(syncBody)
91              ;
92     }
93
94     // ----------------------------------------------------------------- SyncHdr
95
/**
96      * Returns the XML size of SyncHdr element as:
97      * sizeof(<SyncHdr>\n) +
98      * if verDTD != null
99      * sizeof(verDTD) +
100      * if verProto != null
101      * sizeof(verProto) +
102      * if sessionID != null
103      * sizeof(<SessionID>) +
104      * if msgId != null
105      * sizeof(<MsgID>) +
106      * msgId.length +
107      * sizeof(</MsgID>\n) +
108      * if target != null
109      * sizeof(target) +
110      * if source != null
111      * sizeof(source) +
112      * if respURI
113      * sizeof(<RespURI>) +
114      * sizeof(respURI) +
115      * sizeof(</RespURI>\n) +
116      * if noResp
117      * sizeof(<NoResp></NoResp>\n) +
118      * if cred != null
119      * sizeof(cred) +
120      * if meta != null
121      * sizeof(meta) +
122      * sizeof(</SyncHdr>\n) +
123      *
124      * @return the XML size of this element
125      */

126     public static long getXMLSize(SyncHdr syncHdr) {
127
128         VerDTD verDTD = syncHdr.getVerDTD() ;
129         VerProto verProto = syncHdr.getVerProto() ;
130         SessionID sessionID = syncHdr.getSessionID();
131         String JavaDoc msgID = syncHdr.getMsgID() ;
132         Target target = syncHdr.getTarget() ;
133         Source source = syncHdr.getSource() ;
134         String JavaDoc respURI = syncHdr.getRespURI() ;
135         boolean noResp = syncHdr.isNoResp() ;
136         Cred cred = syncHdr.getCred() ;
137         Meta meta = syncHdr.getMeta() ;
138
139         return 21
140              + ((verDTD != null) ? getXMLSize(verDTD) : 0)
141              + ((verProto != null) ? getXMLSize(verProto) : 0)
142              + ((sessionID != null) ? getXMLSize(sessionID) : 0)
143              + ((msgID != null) ? 16 + msgID.length() : 0)
144              + ((target != null) ? getXMLSize(target) : 0)
145              + ((source != null) ? getXMLSize(source) : 0)
146              + ((respURI != null) ? 19 + respURI.length() : 90)
147              + (noResp ? 18 : 0)
148              + ((cred != null) ? getXMLSize(cred) : 0)
149              + ((meta != null) ? getXMLSize(meta) : 0)
150              ;
151     }
152
153     /**
154      * Returns the WBXML size of the SyncHdr object
155      *
156      * @param syncHdr the SyncHdr element
157      *
158      * @return size the WBXML size of the SyncHdr element
159      */

160     public static long getWBXMLSize(SyncHdr syncHdr) {
161         VerDTD verDTD = syncHdr.getVerDTD() ;
162         VerProto verProto = syncHdr.getVerProto() ;
163         SessionID sessionID = syncHdr.getSessionID();
164         String JavaDoc msgID = syncHdr.getMsgID() ;
165         Target target = syncHdr.getTarget() ;
166         Source source = syncHdr.getSource() ;
167         String JavaDoc respURI = syncHdr.getRespURI() ;
168         boolean noResp = syncHdr.isNoResp() ;
169         Cred cred = syncHdr.getCred() ;
170         Meta meta = syncHdr.getMeta() ;
171
172         return 4
173              + ((verDTD != null) ? getWBXMLSize(verDTD) : 0)
174              + ((verProto != null) ? getWBXMLSize(verProto) : 0)
175              + ((sessionID != null) ? getWBXMLSize(sessionID) : 0)
176              + ((msgID != null) ? 4 + msgID.length() : 0)
177              + ((target != null) ? getWBXMLSize(target) : 0)
178              + ((source != null) ? getWBXMLSize(source) : 0)
179              + ((respURI != null) ? 4 + respURI.length() : 80)
180              + (noResp ? 1 : 0)
181              + ((cred != null) ? getWBXMLSize(cred) : 0)
182              + ((meta != null) ? getWBXMLSize(meta) : 0)
183              ;
184     }
185
186     // ---------------------------------------------------------------- SyncBody
187
/**
188      * Returns the XML overhead for SyncBody object
189      * sizeof(<SyncBody>\n</SyncBody>\n)
190      *
191      * @return overhead for SyncBody object
192      */

193     public static long getXMLOverheadSyncBody() {
194         return 23;
195     }
196     
197     /**
198      * Returns the WBXML overhead for SyncBody object
199      * sizeof(<SyncBody>\n</SyncBody>\n)
200      *
201      * @return overhead for SyncBody object
202      */

203     public static long getWBXMLOverheadSyncBody() {
204         return 4;
205     }
206     
207     /**
208      * Returns the XML size of the SyncBody object
209      *
210      * sizeof(<SyncBody>\n) +
211      * for (i=0; i<commands.size(); i++)
212      * sizeof(commands[i]) +
213      * if final
214      * sizeof(<Final></Final>\n) +
215      * sizeof(</SyncBody>\n) +
216      * @param syncBody the SyncBody element
217      *
218      * @return size the XML size of the SyncBody element
219      */

220     public static long getXMLSize(SyncBody syncBody) {
221         ArrayList JavaDoc commands = syncBody.getCommands();
222
223         long size = 23
224                   + ((syncBody.isFinalMsg()) ? 16 : 0)
225                   ;
226
227         for (int i=0; i<commands.size(); i++) {
228             size += getCommandXMLSize((AbstractCommand)commands.get(i));
229         }
230         return size;
231     }
232
233     /**
234      * Returns the WBXML size of the SyncBody object
235      *
236      * @param syncBody the SyncBody element
237      *
238      * @return size the WBXML size of the SyncBody element
239      */

240     public static long getWBXMLSize(SyncBody syncBody) {
241         ArrayList JavaDoc commands = syncBody.getCommands();
242
243         long size = 4
244                   + ((syncBody.isFinalMsg()) ? 1 : 0)
245                   ;
246
247        for (int i=0; i<commands.size(); ++i) {
248            size += getCommandWBXMLSize((AbstractCommand)commands.get(i));
249        }
250        return size;
251     }
252
253     // ------------------------------------------------------------------ VerDTD
254
/**
255      * Returns the XML size of VerDTD object:
256      * sizeof(<VerDTD>) +
257      * sizeof(value) +
258      * sizeof(</VerDTD>\n)
259      *
260      * @return the XML size of VerDTD object
261      */

262     public static long getXMLSize(VerDTD verDTD) {
263         return 18
264              + verDTD.getValue().length()
265              ;
266     }
267
268     /**
269      * Returns the WBXML size of VerDTD object
270      *
271      * @return the WBXML size of VerDTD object
272      */

273     public static long getWBXMLSize(VerDTD verDTD) {
274         return 4
275              + verDTD.getValue().length()
276              ;
277     }
278
279     // ---------------------------------------------------------------- VerProto
280
/**
281      * Returns the XML size of VerProto object:
282      * sizeof("<VerProto>") +
283      * sizeof(version) +
284      * sizeof("</VerProto>\n")
285      *
286      * @return the XML size of this object
287      */

288     public static long getXMLSize(VerProto verProto) {
289         return 22
290              + verProto.getVersion().length()
291              ;
292     }
293
294     /**
295      * Returns the WBXML size of VerProto object
296      *
297      * @return the WBXML size of VerProto object
298      */

299     public static long getWBXMLSize(VerProto verProto) {
300         return 4
301              + verProto.getVersion().length()
302              ;
303     }
304
305     // --------------------------------------------------------------- SessionID
306
/**
307      * Returns the XML size of SessionID element as:
308      * sizeof("<SessionID>") +
309      * sizeof(sessionID) +
310      * sizeof("</SessionID>\n")
311      *
312      * @return the XML size of this element
313      */

314     public static long getXMLSize(SessionID sessionID) {
315         return 24
316              + sessionID.getSessionID().length()
317              ;
318     }
319
320     /**
321      * Returns the WBXML size of SessionID object
322      *
323      * @return the WBXML size of SessionID object
324      */

325     public static long getWBXMLSize(SessionID sessionID) {
326         return 4
327              + sessionID.getSessionID().length()
328              ;
329     }
330
331     // ------------------------------------------------------------------ Target
332
/**
333      * Returns the XML size of Target element:
334      * sizeof(<Target>\n) +
335      * if locURI != null
336      * sizeof(<LocURI>) +
337      * sizeof(locURI) +
338      * sizeof(</LocURI>\n) +
339      * if locName != null
340      * sizeof(<LocName>) +
341      * sizeof(locName) +
342      * sizeof(</LocName>\n) +
343      * sizeof(</Target>\n)
344      *
345      * @return the XML size of this element
346      */

347     public static long getXMLSize(Target target) {
348         String JavaDoc locURI = target.getLocURI() ;
349         String JavaDoc locName = target.getLocName();
350
351         return 19
352              + ((locURI != null) ? (18 + locURI.length() ) : 0)
353              + ((locName != null) ? (20 + locName.length()) : 0)
354              ;
355     }
356     /**
357      * Returns the WBXML size of this element.
358      * @return the WBXML size of this element
359      */

360     public static long getWBXMLSize(Target target) {
361         String JavaDoc locURI = target.getLocURI() ;
362         String JavaDoc locName = target.getLocName();
363
364         return 4
365              + ((locURI != null) ? (4 + locURI.length() ) : 0)
366              + ((locName != null) ? (4 + locName.length()) : 0)
367              ;
368     }
369
370     // ------------------------------------------------------------------ Source
371
/**
372      * Returns the XML size of Source element:
373      * sizeof(<Source>\n) +
374      * if locURI != null
375      * sizeof(<LocURI>) +
376      * sizeof(locURI) +
377      * sizeof(</LocURI>\n) +
378      * if locName != null
379      * sizeof(<LocName>) +
380      * sizeof(locName) +
381      * sizeof(</LocName>\n) +
382      * sizeof(</Source>\n)
383      *
384      * @return the XML size of this element
385      */

386     public static long getXMLSize(Source source) {
387         String JavaDoc locURI = source.getLocURI() ;
388         String JavaDoc locName = source.getLocName();
389
390         return 19
391              + ((locURI != null) ? (18 + locURI.length() ) : 0)
392              + ((locName != null) ? (20 + locName.length()) : 0)
393              ;
394     }
395     /**
396      * Returns the WBXML size of this element.
397      * @return the WBXML size of this element
398      */

399     public static long getWBXMLSize(Source source) {
400         String JavaDoc locURI = source.getLocURI() ;
401         String JavaDoc locName = source.getLocName();
402
403         return 4
404              + ((locURI != null) ? (4 + locURI.length() ) : 0)
405              + ((locName != null) ? (4 + locName.length()) : 0)
406              ;
407     }
408
409     // -------------------------------------------------------------------- Cred
410
/**
411      * Returns the XML size of Cred element as:
412      * sizeof(<Cred>\n) +
413      * if meta != null
414      * sizeof(meta) +
415      * if data != null
416      * sizeof(<Data>) +
417      * sizeof(data) +
418      * sizeof(</Data>\n) +
419      * sizeof(</Cred>\n)
420      *
421      * @return the XML size of this element
422      */

423     public static long getXMLSize(Cred cred) {
424         Authentication auth = cred.getAuthentication();
425         Meta meta = auth.getMeta();
426         String JavaDoc data = cred.getData();
427
428         return 15
429              + ((meta != null) ? getXMLSize(meta) : 0)
430              + ((data != null) ? 14 + data.length() : 0)
431              ;
432     }
433
434     /**
435      * Returns the WBXML size of this element.
436      * @return the WBXML size of this element
437      */

438     public static long getWBXMLSize(Cred cred) {
439         Authentication auth = cred.getAuthentication();
440         Meta meta = auth.getMeta();
441         String JavaDoc data = cred.getData();
442
443         return 4
444              + ((meta != null) ? getWBXMLSize(meta) : 0)
445              + ((data != null) ? 4 + data.length() : 0)
446              ;
447     }
448
449     // -------------------------------------------------------------------- Meta
450
/**
451      * Returns the XML size of Meta object.
452      * sizeof(<Meta>\n) +
453      * if format != null
454      * sizeof(<Format>) +
455      * sizeof(format) +
456      * sizeof(</Format>\n) +
457      * if type != null
458      * sizeof(<Type>) +
459      * sizeof(type) +
460      * sizeof(</Type>\n) +
461      * if mark != null
462      * sizeof(mark) +
463      * if size != null
464      * sizeof(<Size>) +
465      * sizeof(size) +
466      * sizeof(</Size>\n) +
467      * if anchor != null
468      * sizeof(anchor) +
469      * if version != null
470      * sizeof(<Version>) +
471      * sizeof(version) +
472      * sizeof(</Version>\n) +
473      * if nextNonce != null
474      * sizeof(nextNonce) +
475      * if maxMsgSize != null
476      * sizeof(<MaxMsgSize>) +
477      * sizeof(maxMsgSize) +
478      * sizeof(</MaxMsgSize>\n) +
479      * if maxObjSize != null
480      * sizeof(<MaxObjSize>) +
481      * sizeof(maxObjSize) +
482      * sizeof(</MaxObjSize>\n) +
483      * for (i=0; emi != null && i<emi.size(); i++)
484      * sizeof(emi[i] +
485      * if mem != null
486      * sizeof(mem) +
487      * sizeof(</Meta>\n)
488      * @return the XML size of Meta object
489      */

490     public static long getXMLSize(Meta meta) {
491         long sizeMeta = 0;
492
493         String JavaDoc format = meta.getFormat() ;
494         String JavaDoc type = meta.getType() ;
495         String JavaDoc mark = meta.getMark() ;
496         Long JavaDoc size = meta.getSize() ;
497         Anchor anchor = meta.getAnchor() ;
498         String JavaDoc version = meta.getVersion() ;
499         NextNonce nextNonce = meta.getNextNonce() ;
500         Long JavaDoc maxMsgSize = meta.getMaxMsgSize();
501         Long JavaDoc maxObjSize = meta.getMaxObjSize();
502         ArrayList JavaDoc emi = meta.getEMI() ;
503         Mem mem = meta.getMem() ;
504
505         sizeMeta = 37
506                  + ((format != null) ? 18 + format.length() : 0)
507                  + ((type != null) ? 14 + type.length() : 0)
508                  + ((mark != null) ? 14 + mark.length() : 0)
509                  + ((size != null) ? 14 + String.valueOf(size).length(): 0)
510                  + ((anchor != null) ? getXMLSize(anchor) : 0)
511                  + ((version != null) ? 20 + version.length() : 0)
512                  + ((nextNonce != null) ? getXMLSize(nextNonce) : 0)
513                  + ((maxMsgSize!= null) ? 26 + String.valueOf(maxMsgSize).length() : 0)
514                  + ((maxObjSize!= null) ? 26 + String.valueOf(maxObjSize).length() : 0)
515                  + ((mem != null) ? getXMLSize(mem) : 0)
516                  ;
517
518     for (int i=0; emi != null && i < emi.size(); i++) {
519             sizeMeta += getXMLSize((EMI)emi.get(i));
520         }
521
522        return sizeMeta;
523     }
524
525
526
527     /**
528      * Returns the WBXML size of this object.
529      *
530      * @return the WBXML size of this object
531      */

532     public static long getWBXMLSize(Meta meta) {
533         long sizeMeta = 0;
534
535         String JavaDoc format = meta.getFormat() ;
536         String JavaDoc type = meta.getType() ;
537         String JavaDoc mark = meta.getMark() ;
538         Long JavaDoc size = meta.getSize() ;
539         Anchor anchor = meta.getAnchor() ;
540         String JavaDoc version = meta.getVersion() ;
541         NextNonce nextNonce = meta.getNextNonce() ;
542         Long JavaDoc maxMsgSize = meta.getMaxMsgSize();
543         Long JavaDoc maxObjSize = meta.getMaxObjSize();
544         ArrayList JavaDoc emi = meta.getEMI() ;
545         Mem mem = meta.getMem() ;
546
547         sizeMeta = 4
548                  + ((format != null) ? 4 + format.length() : 0)
549                  + ((type != null) ? 4 + type.length() : 0)
550                  + ((mark != null) ? 4 + mark.length() : 0)
551                  + ((size != null) ? 4 + String.valueOf(size).length() : 0)
552                  + ((anchor != null) ? getWBXMLSize(anchor) : 0)
553                  + ((version != null) ? 4 + version.length() : 0)
554                  + ((nextNonce != null) ? getWBXMLSize(nextNonce) : 0)
555                  + ((maxMsgSize!= null) ? 4 + String.valueOf(maxMsgSize).length() : 0)
556                  + ((maxObjSize!= null) ? 4 + String.valueOf(maxObjSize).length() : 0)
557                  + ((mem != null) ? getWBXMLSize(mem) : 0)
558                  ;
559
560     for (int i=0; emi != null && i < emi.size(); i++) {
561             sizeMeta += getWBXMLSize((EMI)emi.get(i));
562         }
563
564        return sizeMeta;
565     }
566
567     // ------------------------------------------------------------------ Anchor
568
/**
569      * Returns the XML size of Anchor element as:
570      * sizeof(<Anchor xmlns='syncml:metinf'>\n) +
571      * if last != null
572      * sizeof(<Last>) +
573      * sizeof(last) +
574      * sizeof(</Last>\n) +
575      * if next != null
576      * sizeof(<Next>) +
577      * sizeof(next) +
578      * sizeof(</Next>\n) +
579      * sizeof(</Anchor>\n) +
580      *
581      * @return the XML size of this element
582      */

583     public static long getXMLSize(Anchor anchor) {
584         String JavaDoc last = anchor.getLast();
585         String JavaDoc next = anchor.getNext();
586
587         return 41
588              + ((last != null) ? 14 + last.length() : 0)
589              + ((next != null) ? 14 + next.length() : 0)
590              ;
591     }
592
593     /**
594      * Returns the WBXML size of this element.
595      *
596      * @return the WBXML size of this element
597      */

598     public static long getWBXMLSize(Anchor anchor) {
599         String JavaDoc last = anchor.getLast();
600         String JavaDoc next = anchor.getNext();
601
602         return 25
603              + ((last != null) ? 4 + last.length() : 0)
604              + ((next != null) ? 4 + next.length() : 0)
605              ;
606     }
607
608     // --------------------------------------------------------------------- EMI
609
/**
610      * Returns the XML size of EMI element as:
611      * sizeof(<EMI>) +
612      * sizeof(value) +
613      * sizeof(</EMI>\n)
614      *
615      * @return the XML size of this element
616      */

617     public static long getXMLSize(EMI emi) {
618         return 12
619              + emi.getValue().length()
620              ;
621     }
622
623     /**
624      * Returns the WBXML size of EMI element.
625      *
626      * @return the WBXML size of EMI element
627      */

628     public static long getWBXMLSize(EMI emi) {
629         return 4
630              + emi.getValue().length()
631              ;
632     }
633
634     // --------------------------------------------------------------- NextNonce
635
/**
636      * Returns the XML size of NextNonce element as:
637      * sizeof(<NextNonce>) +
638      * sizeof(value) +
639      * sizeof(</NextNonce>\n)
640      *
641      * @return the XML size of NextNonce element
642      */

643     public static long getXMLSize(NextNonce nextNonce) {
644         return 24
645              + nextNonce.getValueAsBase64().length()
646              ;
647     }
648
649     /**
650      * Returns the WBXML size of NextNonce element.
651      *
652      * @return the WBXML size of NextNonce element
653      */

654     public static long getWBXMLSize(NextNonce nextNonce) {
655         return 4
656              + nextNonce.getValueAsBase64().length()
657              ;
658     }
659
660     // --------------------------------------------------------------------- Mem
661
/**
662      * Returns the XML size of Mem element as:
663      * sizeof("<Mem>\n") +
664      * if sharedMem
665      * sizeof("<Shared></Shared>\n") +
666      * if freeMem
667      * sizeof("<FreeMem>") +
668      * sizeof(freeMem) +
669      * sizeof("</FreeMem>\n") +
670      * if freeID
671      * sizeof("<FreeID>") +
672      * sizeof(freeID) +
673      * sizeof("</FreeID>\n") +
674      * sizeof("</Mem>\n")
675      *
676      * @return the XML size of Mem element
677      */

678     public static long getXMLSize(Mem mem) {
679         boolean sharedMem = mem.isSharedMem();
680         long freeMem = mem.getFreeMem() ;
681         long freeID = mem.getFreeID() ;
682
683         return 13
684              + ((sharedMem) ? 18 : 0)
685              + ((freeMem != 0) ? 20 + String.valueOf(freeMem).length() : 0)
686              + ((freeID != 0) ? 18 + String.valueOf(freeID).length() : 0)
687              ;
688     }
689
690     /**
691      * Returns the WBXML size of Mem object.
692      *
693      * @return the WBXML size of Mem object
694      */

695     public static long getWBXMLSize(Mem mem) {
696         boolean sharedMem = mem.isSharedMem();
697         long freeMem = mem.getFreeMem() ;
698         long freeID = mem.getFreeID() ;
699
700         return 4
701              + ((sharedMem) ? 1 : 0)
702              + ((freeMem != 0) ? 4 + String.valueOf(freeMem).length() : 0)
703              + ((freeID != 0) ? 4 + String.valueOf(freeID).length() : 0)
704              ;
705     }
706
707     // --------------------------------------------------------- AbstractCommand
708
/**
709      * Gets the XML size of all element of AbstractCommand
710      * if cmdID != null
711      * sizeof(cmdID) +
712      * if noResp
713      * sizeof(<NoResp></NoResp>\n) +
714      * if cred != null
715      * sizeof(cred) +
716      * @return the XML size of all element of AbstractCommand
717      */

718     public static long getXMLSize(AbstractCommand command) {
719         CmdID cmdID = command.getCmdID();
720         Cred cred = command.getCred() ;
721
722         return ((cmdID != null) ? getXMLSize(cmdID) : 0)
723              + ((command.isNoResp()) ? 18 : 0)
724              + ((cred != null) ? getXMLSize(cred) : 0)
725              ;
726     }
727
728     /**
729      * Returns the WBXML size of AbstractCommand object.
730      * @return the WBXML size of AbstractCommand object
731      */

732     public static long getWBXMLSize(AbstractCommand command) {
733         CmdID cmdID = command.getCmdID();
734         Cred cred = command.getCred() ;
735
736         return ((cmdID != null) ? getWBXMLSize(cmdID) : 0)
737              + ((command.isNoResp()) ? 1 : 0)
738              + ((cred != null) ? getWBXMLSize(cred) : 0)
739              ;
740     }
741
742     /**
743      * Gets the XML size of the command
744      *
745      * @return the XML size of the command
746      */

747     public static long getCommandXMLSize(AbstractCommand command) {
748         long size = 0;
749         if (command instanceof Add) {
750             size = getXMLSize((Add)command);
751         } else if (command instanceof Alert) {
752             size = getXMLSize((Alert)command);
753         } else if (command instanceof Atomic) {
754             size = getXMLSize((Atomic)command);
755         } else if (command instanceof Copy) {
756             size = getXMLSize((Copy)command);
757         } else if (command instanceof Delete) {
758             size = getXMLSize((Delete)command);
759         } else if (command instanceof Exec) {
760             size = getXMLSize((Exec)command);
761         } else if (command instanceof Get) {
762             size = getXMLSize((Get)command);
763         } else if (command instanceof Map) {
764             size = getXMLSize((Map)command);
765         } else if (command instanceof Put) {
766             size = getXMLSize((Put)command);
767         } else if (command instanceof Replace) {
768             size = getXMLSize((Replace)command);
769         } else if (command instanceof Results) {
770             size = getXMLSize((Results)command);
771         } else if (command instanceof Search) {
772             size = getXMLSize((Search)command);
773         } else if (command instanceof Sequence) {
774             size = getXMLSize((Sequence)command);
775         } else if (command instanceof Status) {
776             size = getXMLSize((Status)command);
777         } else if (command instanceof Sync) {
778             size = getXMLSize((Sync)command);
779         }
780
781         return size;
782     }
783
784     /**
785      * Gets the XML size of the command
786      *
787      * @return the XML size of the command
788      */

789     public static long getCommandWBXMLSize(AbstractCommand command) {
790         long size = 0;
791         if (command instanceof Add) {
792             size = getWBXMLSize((Add)command);
793         } else if (command instanceof Alert) {
794             size = getWBXMLSize((Alert)command);
795         } else if (command instanceof Atomic) {
796             size = getWBXMLSize((Atomic)command);
797         } else if (command instanceof Copy) {
798             size = getWBXMLSize((Copy)command);
799         } else if (command instanceof Delete) {
800             size = getWBXMLSize((Delete)command);
801         } else if (command instanceof Exec) {
802             size = getWBXMLSize((Exec)command);
803         } else if (command instanceof Get) {
804             size = getWBXMLSize((Get)command);
805         } else if (command instanceof Map) {
806             size = getWBXMLSize((Map)command);
807         } else if (command instanceof Put) {
808             size = getWBXMLSize((Put)command);
809         } else if (command instanceof Replace) {
810             size = getWBXMLSize((Replace)command);
811         } else if (command instanceof Results) {
812             size = getWBXMLSize((Results)command);
813         } else if (command instanceof Search) {
814             size = getWBXMLSize((Search)command);
815         } else if (command instanceof Sequence) {
816             size = getWBXMLSize((Sequence)command);
817         } else if (command instanceof Status) {
818             size = getWBXMLSize((Status)command);
819         } else if (command instanceof Sync) {
820             size = getWBXMLSize((Sync)command);
821         }
822
823         return size;
824     }
825
826     // ------------------------------------------------------------------- CmdID
827
/**
828      * Returns the XML size of CmdID element as:
829      * sizeof(<CmdID>) +
830      * sizeof(cmdID) +
831      * sizeof(</CmdID>\n)
832      *
833      * @return the XML size of CmdID element
834      */

835     public static long getXMLSize(CmdID cmdID) {
836         return 16
837              + cmdID.getCmdID().length();
838     }
839
840     /**
841      * Returns the WBXML size of CmdID element.
842      * @return the WBXML size of CmdID element
843      */

844     public static long getWBXMLSize(CmdID cmdID) {
845         return 2
846              + cmdID.getCmdID().length();
847     }
848
849     // --------------------------------------------------------------------- Add
850
/**
851      * Returns the XML size of Add element as:
852      * sizeof(<Add>\n) +
853      * if cmdID != null
854      * sizeof(cmdID) +
855      * if noResp
856      * sizeof(<NoResp></NoResp>\n) +
857      * if cred != null
858      * sizeof(cred) +
859      * if meta != null
860      * sizeof(meta) +
861      * for (int i=0; items != null && i<items.size(); i++)
862      * sizeof(items[i]) +
863      * sizeof(</Add>\n)
864      *
865      * @return the XML size of Add element
866      */

867     public static long getXMLSize(Add add) {
868         Meta meta = add.getMeta() ;
869         ArrayList JavaDoc items = add.getItems();
870
871         long size = 13
872                   + getXMLSize((AbstractCommand)add)
873                   + ((meta != null) ? getXMLSize(meta) : 0)
874                   ;
875         for (int i=0; items != null && i<items.size(); i++) {
876             size += getXMLSize((Item)items.get(i));
877         }
878         return size;
879     }
880
881     /**
882      * Returns the WBXML size of Add element.
883      *
884      * @return the WBXML size of Add element
885      */

886     public static long getWBXMLSize(Add add) {
887         Meta meta = add.getMeta() ;
888         ArrayList JavaDoc items = add.getItems();
889
890         long size = 4
891                   + getWBXMLSize((AbstractCommand)add)
892                   + ((meta != null) ? getWBXMLSize(meta) : 0)
893                   ;
894         for (int i=0; items != null && i<items.size(); i++) {
895             size += getWBXMLSize((Item)items.get(i));
896         }
897         return size;
898     }
899
900     // -------------------------------------------------------------------- Item
901
/**
902      * Returns the XML size of Item element as:
903      * sizeof(<Item>\n) +
904      * if target != null
905      * sizeof(target) +
906      * if source != null
907      * sizeof(source) +
908      * if meta != null
909      * sizeof(meta) +
910      * if data != null
911      * sizeof(data) +
912      * if moreData
913      * sizeof(<MoreData></MoreData>\n) +
914      * sizeof(</Item>\n)
915      *
916      * @return the XML size of Item element
917      */

918     public static long getXMLSize(Item item) {
919         Target target = item.getTarget();
920         Source source = item.getSource();
921         Meta meta = item.getMeta() ;
922         ComplexData data = item.getData() ;
923
924         return 15
925              + ((target != null) ? getXMLSize(target) : 0)
926              + ((source != null) ? getXMLSize(source) : 0)
927              + ((meta != null) ? getXMLSize(meta) : 0)
928              + ((data != null) ? getXMLSize(data) : 0)
929              + ((item.isMoreData()) ? 22 : 0)
930              ;
931     }
932
933     /**
934      * Returns the WBXML size of Item element.
935      * @return the WBXML size of Item element
936      */

937     public static long getWBXMLSize(Item item) {
938         Target target = item.getTarget();
939         Source source = item.getSource();
940         Meta meta = item.getMeta() ;
941         ComplexData data = item.getData() ;
942
943         return 4
944              + ((target != null) ? getWBXMLSize(target) : 0)
945              + ((source != null) ? getWBXMLSize(source) : 0)
946              + ((meta != null) ? getWBXMLSize(meta) : 0)
947              + ((data != null) ? getWBXMLSize(data) : 0)
948              + ((item.isMoreData()) ? 1 : 0)
949              ;
950     }
951
952     // ------------------------------------------------------------- ComplexData
953
/**
954      * Returns the XML size of ComplexData element as:
955      * sizeof(<Data>\n) +
956      * if data != null
957      * sizeof(data) +
958      * if anchor != null
959      * sizeof(anchor) +
960      * if devinf != null
961      * sizeof(devinf) +
962      * sizeof(</Data>\n)
963      * @return the XML size of ComplexData element
964      */

965     public static long getXMLSize(ComplexData complexData) {
966         String JavaDoc data = complexData.getData() ;
967         Anchor anchor = complexData.getAnchor();
968         DevInf devInf = complexData.getDevInf();
969
970         return 15
971              + ((data != null) ? data.length() :0)
972              + ((anchor != null) ? getXMLSize(anchor) :0)
973              + ((devInf != null) ? getXMLSize(devInf) :0)
974              ;
975     }
976
977     /**
978      * Returns the WBXML size of ComplexData element.
979      *
980      * @return the WBXML size of ComplexData element
981      */

982     public static long getWBXMLSize(ComplexData complexData) {
983         String JavaDoc data = complexData.getData() ;
984         Anchor anchor = complexData.getAnchor();
985         DevInf devInf = complexData.getDevInf();
986
987         return 4
988              + ((data != null) ? data.length() :0)
989              + ((anchor != null) ? getWBXMLSize(anchor) :0)
990              + ((devInf != null) ? getWBXMLSize(devInf) :0)
991              ;
992     }
993
994     // -------------------------------------------------------------------- Data
995
/**
996      * Returns the XML size of Data element as:
997      * sizeof(<Data>) +
998      * sizeof(data) +
999      * sizeof(</Data>\n)
1000     *
1001     * @return the XML size of Data element
1002     */

1003    public static long getXMLSize(Data data) {
1004        return 14
1005             + data.getData().length();
1006    }
1007
1008    /**
1009     * Returns the WBXML size of Data element.
1010     *
1011     * @return the WBXML size of Data element
1012     */

1013    public static long getWBXMLSize(Data data) {
1014        return 4
1015             + data.getData().length();
1016    }
1017
1018    // -------------------------------------------------------------- DevInfData
1019
/**
1020     * Returns the XML size of DevInfData element as:
1021     * sizeof(<Data>\n) +
1022     * id devInf != null
1023     * sizeof(devInf) +
1024     * sizeof(</Data>\n)
1025     *
1026     * @return the XML size of DevInfData element
1027     */

1028    public static long getXMLSize(DevInfData devInfData) {
1029        DevInf devInf = devInfData.getDevInf();
1030        return 15
1031             + ((devInf != null) ? getXMLSize(devInf) : 0)
1032             ;
1033    }
1034
1035    /**
1036     * Returns the WBXML size of DevInfData element.
1037     *
1038     * @return the WBXML size of DevInfData element
1039     */

1040    public static long getWBXMLSize(DevInfData devInfData) {
1041        DevInf devInf = devInfData.getDevInf();
1042        return 4
1043             + ((devInf != null) ? getWBXMLSize(devInf) : 0)
1044             ;
1045    }
1046
1047    // ------------------------------------------------------------------ DevInf
1048
/**
1049     * Returns the XML size of DevInf element as:
1050     * sizeof(<DevInf xmlns='syncml:devinf'>\n) +
1051     * if verDTD != null
1052     * sizeof(verDTD) +
1053     * if man != null
1054     * sizeof(<Man>) +
1055     * sizeof(man) +
1056     * sizeof(</Man>\n) +
1057     * if mod != null
1058     * sizeof(<Mod>) +
1059     * sizeof(mod) +
1060     * sizeof(</Mod>\n) +
1061     * if oem != null
1062     * sizeof(<OEM>) +
1063     * sizeof(oem) +
1064     * sizeof(</OEM>\n) +
1065     * if fwV != null
1066     * sizeof(<FwV>) +
1067     * sizeof(fwV) +
1068     * sizeof(</FwV>\n) +
1069     * if swV != null
1070     * sizeof(<SwV>) +
1071     * sizeof(swV) +
1072     * sizeof(</SwV>\n) +
1073     * if hwV != null
1074     * sizeof(<HwV>) +
1075     * sizeof(hwV) +
1076     * sizeof(</HwV>\n) +
1077     * if devID != null
1078     * sizeof(<DevID>) +
1079     * sizeof(devID) +
1080     * sizeof(</DevID>\n) +
1081     * if devTyp != null
1082     * sizeof(<DevTyp>) +
1083     * sizeof(devTyp) +
1084     * sizeof(</DevTyp>\n) +
1085     * if utc
1086     * sizeof(<UTC></UTC>\n) +
1087     * if supportLargeObjs
1088     * sizeof(<SupportLargeObjs></SupportLargeObjs>\n) +
1089     * if supportNumberOfChanges
1090     * sizeof(<SupportNumberOfChanges></SupportNumberOfChanges>\n) +
1091     * for (int i=0; datastores != null && i<datastores.size(); i++)
1092     * sizeof(datastores[i]) +
1093     * for (int i=0; ctCaps != null && i<ctCaps.size(); i++)
1094     * sizeof(ctCaps[i]) +
1095     * for (int i=0; exts != null && i<exts.size(); i++)
1096     * sizeof(exts[i]) +
1097     * sizeof(</DevInf>\n)
1098     *
1099     * @return the XML size of DevInf element
1100     */

1101    public static long getXMLSize(DevInf devInf) {
1102        VerDTD verDTD = devInf.getVerDTD() ;
1103        String JavaDoc man = devInf.getMan() ;
1104        String JavaDoc mod = devInf.getMod() ;
1105        String JavaDoc oem = devInf.getOEM() ;
1106        String JavaDoc fwV = devInf.getFwV() ;
1107        String JavaDoc swV = devInf.getSwV() ;
1108        String JavaDoc hwV = devInf.getHwV() ;
1109        String JavaDoc devID = devInf.getDevID() ;
1110        String JavaDoc devTyp = devInf.getDevTyp() ;
1111        ArrayList JavaDoc dataStores = devInf.getDataStore();
1112        ArrayList JavaDoc ctCaps = devInf.getCTCap() ;
1113        ArrayList JavaDoc exts = devInf.getExt() ;
1114
1115        long size = 0;
1116
1117        for (int i=0; dataStores != null && i<dataStores.size(); i++) {
1118            size += getXMLSize((DataStore)dataStores.get(i));
1119        }
1120        for (int i=0; ctCaps != null && i<ctCaps.size(); i++) {
1121            size += getXMLSize((CTCap)ctCaps.get(i));
1122        }
1123        for (int i=0; exts != null && i<exts.size(); i++) {
1124            size += getXMLSize((Ext)exts.get(i));
1125        }
1126
1127        return 41
1128             + ((verDTD != null) ? getXMLSize(verDTD) : 0)
1129             + ((man != null) ? 12 + man.length() : 0)
1130             + ((mod != null) ? 12 + mod.length() : 0)
1131             + ((oem != null) ? 12 + oem.length() : 0)
1132             + ((fwV != null) ? 12 + fwV.length() : 0)
1133             + ((swV != null) ? 12 + swV.length() : 0)
1134             + ((hwV != null) ? 12 + hwV.length() : 0)
1135             + ((devID != null) ? 16 + devID.length() : 0)
1136             + ((devTyp != null) ? 18 + devTyp.length() : 0)
1137             + ((devInf.isUTC()) ? 12 : 0)
1138             + ((devInf.isSupportLargeObjs()) ? 38 : 0)
1139             + ((devInf.isSupportNumberOfChanges()) ? 50 : 0)
1140             + size;
1141    }
1142
1143    /**
1144     * Returns the WBXML size of DevInf element.
1145     *
1146     * @return the WBXML size of DevInf element
1147     */

1148    public static long getWBXMLSize(DevInf devInf) {
1149        VerDTD verDTD = devInf.getVerDTD() ;
1150        String JavaDoc man = devInf.getMan() ;
1151        String JavaDoc mod = devInf.getMod() ;
1152        String JavaDoc oem = devInf.getOEM() ;
1153        String JavaDoc fwV = devInf.getFwV() ;
1154        String JavaDoc swV = devInf.getSwV() ;
1155        String JavaDoc hwV = devInf.getHwV() ;
1156        String JavaDoc devID = devInf.getDevID() ;
1157        String JavaDoc devTyp = devInf.getDevTyp() ;
1158        ArrayList JavaDoc dataStores = devInf.getDataStore();
1159        ArrayList JavaDoc ctCaps = devInf.getCTCap() ;
1160        ArrayList JavaDoc exts = devInf.getExt() ;
1161
1162        long size = 0;
1163
1164        for (int i=0; dataStores != null && i<dataStores.size(); i++) {
1165            size += getWBXMLSize((DataStore)dataStores.get(i));
1166        }
1167        for (int i=0; ctCaps != null && i<ctCaps.size(); i++) {
1168            size += getWBXMLSize((CTCap)ctCaps.get(i));
1169        }
1170        for (int i=0; exts != null && i<exts.size(); i++) {
1171            size += getWBXMLSize((Ext)exts.get(i));
1172        }
1173
1174        return 4
1175             + ((verDTD != null) ? getWBXMLSize(verDTD) : 0)
1176             + ((man != null) ? 4 + man.length() : 0)
1177             + ((mod != null) ? 4 + mod.length() : 0)
1178             + ((oem != null) ? 4 + oem.length() : 0)
1179             + ((fwV != null) ? 4 + fwV.length() : 0)
1180             + ((swV != null) ? 4 + swV.length() : 0)
1181             + ((hwV != null) ? 4 + hwV.length() : 0)
1182             + ((devID != null) ? 4 + devID.length() : 0)
1183             + ((devTyp != null) ? 4 + devTyp.length() : 0)
1184             + ((devInf.isUTC()) ? 1 : 0)
1185             + ((devInf.isSupportLargeObjs()) ? 1 : 0)
1186             + ((devInf.isSupportNumberOfChanges()) ? 1 : 0)
1187             + size;
1188    }
1189
1190    // --------------------------------------------------------------- DataStore
1191
/**
1192     * Returns the XML size of DataStore element as:
1193     * sizeof(<DataStore>\n) +
1194     * if sourceRef != null
1195     * sizeof(sourceRef) +
1196     * if displayName != null && displayName.length() != 0
1197     * sizeof(<DisplayName>) +
1198     * sizeof(displayName) +
1199     * sizeof(</DisplayName>\n) +
1200     * if maxGUIDSize > 0
1201     * sizeof(<MaxGUIDSize>) +
1202     * sizeof(maxGUIDSize) +
1203     * sizeof(</MaxGUIDSize>\n) +
1204     * if rxPref != null
1205     * sizeof(<Rx-Pref>\n) +
1206     * sizeof(rxPref) +
1207     * sizeof(</Rx-Pref>\n) +
1208     * for (int i=0; rxs != null && i<rxs.size(); i++)
1209     * sizeof(<Rx>\n) +
1210     * sizeof(rxs[i]) +
1211     * sizeof(</Rx>\n) +
1212     * if txPref != null
1213     * sizeof(<Tx-Pref>\n) +
1214     * sizeof(txPref) +
1215     * sizeof(</Tx-Pref>\n) +
1216     * for (int i=0; txs != null && i<txs.size(); i++)
1217     * sizeof(<Tx>\n) +
1218     * sizeof(txs[i]) +
1219     * sizeof(</Tx>\n) +
1220     * if dsMem != null
1221     * sizeof(dsMem) +
1222     * if syncCap != null
1223     * sizeof(syncCap) +
1224     * sizeof(</DataStore>\n)
1225     *
1226     * @return the XML size of DataStore element
1227     */

1228    public static long getXMLSize(DataStore dataStore) {
1229        SourceRef sourceRef = dataStore.getSourceRef() ;
1230        String JavaDoc displayName = dataStore.getDisplayName();
1231        long maxGUIDSize = dataStore.getMaxGUIDSize();
1232        ContentTypeInfo rxPref = dataStore.getRxPref() ;
1233        ArrayList JavaDoc rxs = dataStore.getRx() ;
1234        ContentTypeInfo txPref = dataStore.getTxPref() ;
1235        ArrayList JavaDoc txs = dataStore.getTx() ;
1236        DSMem dsMem = dataStore.getDSMem() ;
1237        SyncCap syncCap = dataStore.getSyncCap() ;
1238
1239        long size = 0;
1240
1241        for (int i=0; rxs != null && i<rxs.size(); i++) {
1242            size += 11 + getXMLSize((ContentTypeInfo)rxs.get(i));
1243        }
1244        for (int i=0; txs != null && i<txs.size(); i++) {
1245            size += 11 + getXMLSize((ContentTypeInfo)txs.get(i));
1246        }
1247
1248        return 25
1249             + ((sourceRef != null) ? getXMLSize(sourceRef) : 0)
1250             + ((displayName != null && displayName.length() != 0)
1251                             ? 28 + displayName.length() : 0)
1252             + ((maxGUIDSize > 0)
1253                             ? 28 + String.valueOf(maxGUIDSize).length() : 0)
1254             + ((rxPref != null) ? 21 + getXMLSize(rxPref) : 0)
1255             + ((txPref != null) ? 21 + getXMLSize(txPref) : 0)
1256             + ((dsMem != null) ? getXMLSize(dsMem) : 0)
1257             + ((syncCap != null) ? getXMLSize(syncCap) : 0)
1258             + size
1259             ;
1260    }
1261
1262    /**
1263     * Returns the WBXML size of DataStore element.
1264     *
1265     * @return the WBXML size of DataStore element
1266     */

1267    public static long getWBXMLSize(DataStore dataStore) {
1268        SourceRef sourceRef = dataStore.getSourceRef() ;
1269        String JavaDoc displayName = dataStore.getDisplayName();
1270        long maxGUIDSize = dataStore.getMaxGUIDSize();
1271        ContentTypeInfo rxPref = dataStore.getRxPref() ;
1272        ArrayList JavaDoc rxs = dataStore.getRx() ;
1273        ContentTypeInfo txPref = dataStore.getTxPref() ;
1274        ArrayList JavaDoc txs = dataStore.getTx() ;
1275        DSMem dsMem = dataStore.getDSMem() ;
1276        SyncCap syncCap = dataStore.getSyncCap() ;
1277
1278        long size = 0;
1279
1280        for (int i=0; rxs != null && i<rxs.size(); i++) {
1281            size += 4 + getWBXMLSize((ContentTypeInfo)rxs.get(i));
1282        }
1283        for (int i=0; txs != null && i<txs.size(); i++) {
1284            size += 4 + getWBXMLSize((ContentTypeInfo)txs.get(i));
1285        }
1286
1287        return 4
1288             + ((sourceRef != null) ? getWBXMLSize(sourceRef) : 0)
1289             + ((displayName != null && displayName.length() != 0)
1290                             ? 1 + displayName.length() : 0)
1291             + ((maxGUIDSize > 0)
1292                             ? 4 + String.valueOf(maxGUIDSize).length() : 0)
1293             + ((rxPref != null) ? 4 + getWBXMLSize(rxPref) : 0)
1294             + ((txPref != null) ? 4 + getWBXMLSize(txPref) : 0)
1295             + ((dsMem != null) ? getWBXMLSize(dsMem) : 0)
1296             + ((syncCap != null) ? getWBXMLSize(syncCap) : 0)
1297             + size
1298             ;
1299    }
1300
1301    // --------------------------------------------------------- ContentTypeInfo
1302
/**
1303     * Returns the XML size of ContentTypeInfo element as:
1304     * if ctType != null
1305     * sizeof(<CTType>) +
1306     * sizeof(ctType) +
1307     * sizeof(</CTType>\n) +
1308     * if verCT != null
1309     * sizeof(<VerCT>) +
1310     * sizeof(verCT) +
1311     * sizeof(</VerCT>\n) +
1312     *
1313     * @return the XML size of ContentTypeInfo element
1314     */

1315    public static long getXMLSize(ContentTypeInfo contentTypeInfo) {
1316        String JavaDoc ctType = contentTypeInfo.getCTType();
1317        String JavaDoc verCT = contentTypeInfo.getVerCT() ;
1318
1319        return ((ctType != null) ? 18 + ctType.length() : 0)
1320             + ((verCT != null) ? 16 + verCT.length() : 0)
1321             ;
1322    }
1323
1324    /**
1325     * Returns the WBXML size of ContentTypeInfo element.
1326     *
1327     * @return the WBXML size of ContentTypeInfo element
1328     */

1329    public static long getWBXMLSize(ContentTypeInfo contentTypeInfo) {
1330        String JavaDoc ctType = contentTypeInfo.getCTType();
1331        String JavaDoc verCT = contentTypeInfo.getVerCT() ;
1332
1333        return ((ctType != null) ? 4 + ctType.length() : 0)
1334             + ((verCT != null) ? 4 + verCT.length() : 0)
1335             ;
1336    }
1337
1338    // --------------------------------------------------------------- SourceRef
1339
/**
1340     * Returns the XML size of SourceRef element as:
1341     * sizeof(<SourceRef>) +
1342     * if value != null
1343     * sizeof(value) +
1344     * if source != null
1345     * sizeof(source) +
1346     * sizeof(</SourceRef>\n)
1347     *
1348     * @return the XML size of SourceRef element
1349     */

1350    public static long getXMLSize(SourceRef sourceRef) {
1351        String JavaDoc value = sourceRef.getValue() ;
1352        Source source = sourceRef.getSource();
1353
1354        return 24
1355             + ((value != null) ? value.length() : 0)
1356             + ((source != null) ? getXMLSize(source) : 0)
1357             ;
1358    }
1359
1360    /**
1361     * Returns the WBXML size of SourceRef element.
1362     * @return the WBXML size of SourceRef element
1363     */

1364    public static long getWBXMLSize(SourceRef sourceRef) {
1365        String JavaDoc value = sourceRef.getValue() ;
1366        Source source = sourceRef.getSource();
1367
1368        return 4
1369             + ((value != null) ? value.length() : 0)
1370             + ((source != null) ? getWBXMLSize(source) : 0)
1371             ;
1372    }
1373
1374    // ------------------------------------------------------------------- DSMem
1375
/**
1376     * Returns the XML size of DSMem element as:
1377     * sizeof(<DSMem>\n) +
1378     * if sharedMem
1379     * sizeof(<SharedMem></SharedMem>\n) +
1380     * if maxMem >= 0
1381     * sizeof(<MaxMem>) +
1382     * sizeof(maxMem) +
1383     * sizeof(</<MaxMem>\n) +
1384     * if maxID >= 0
1385     * sizeof(<MaxID>) +
1386     * sizeof(maxID) +
1387     * sizeof(</MaxID>\n) +
1388     * sizeof(</DSMem>\n)
1389     *
1390     * @return the XML size of DSMem element
1391     */

1392    public static long getXMLSize(DSMem dsMem) {
1393        long maxMem = dsMem.getMaxMem();
1394        long maxID = dsMem.getMaxID() ;
1395
1396        return 17
1397             + ((dsMem.isSharedMem()) ? 24 :0)
1398             + ((maxMem>=0) ? 18 + String.valueOf(maxMem).length() :0)
1399             + ((maxID >=0) ? 16 + String.valueOf(maxID).length() :0)
1400             ;
1401    }
1402
1403    /**
1404     * Returns the WBXML size of DSMem element
1405     *
1406     * @return the WBXML size of DSMem element
1407     */

1408    public static long getWBXMLSize(DSMem dsMem) {
1409        long maxMem = dsMem.getMaxMem();
1410        long maxID = dsMem.getMaxID() ;
1411
1412        return 4
1413             + ((dsMem.isSharedMem()) ? 1 :0)
1414             + ((maxMem >=0) ? 4 + String.valueOf(maxMem).length() :0)
1415             + ((maxID >=0) ? 4 + String.valueOf(maxID).length() :0)
1416             ;
1417    }
1418
1419    // ----------------------------------------------------------------- SyncCap
1420
/**
1421     * Returns the XML size of SyncCap element as:
1422     * sizeof(<SyncCap>\n) +
1423     * for (i=0; syncTypes != null && i < syncTypes.size(); i++)
1424     * sizeof(syncTypes[i]) +
1425     * sizeof(</SyncCap>\n)
1426     *
1427     * @return the XML size of SyncCap element
1428     */

1429    public static long getXMLSize(SyncCap syncCap) {
1430        ArrayList JavaDoc syncTypes = syncCap.getSyncType();
1431        long size = 21;
1432
1433        for (int i=0; i<syncTypes.size(); ++i) {
1434            size += getXMLSize((SyncType)syncTypes.get(i));
1435        }
1436        return size;
1437    }
1438
1439    /**
1440     * Returns the WBXML size of SyncCap object.
1441     *
1442     * @return the WBXML size of SyncCap object
1443     */

1444    public static long getWBXMLSize(SyncCap syncCap) {
1445        ArrayList JavaDoc syncTypes = syncCap.getSyncType();
1446        long size = 4;
1447
1448        for (int i=0; i<syncTypes.size(); ++i) {
1449            size += getWBXMLSize((SyncType)syncTypes.get(i));
1450        }
1451        return size;
1452    }
1453
1454    // ---------------------------------------------------------------- SyncType
1455
/**
1456     * Returns the XML size of SyncType element as:
1457     * sizeof(<SyncType>) +
1458     * sizeof(syncType) +
1459     * sizeof(</SyncType>\n)
1460     *
1461     * @return the XML size of SyncType element
1462     */

1463    public static long getXMLSize(SyncType syncType) {
1464        return 22
1465             + String.valueOf(syncType.getType()).length()
1466             ;
1467    }
1468
1469    /**
1470     * Returns the WBXML size of SyncType object.
1471     *
1472     * @return the WBXML size of SyncType object
1473     */

1474    public static long getWBXMLSize(SyncType syncType) {
1475       return 4
1476            + String.valueOf(syncType.getType()).length()
1477            ;
1478    }
1479
1480    // ------------------------------------------------------------------- CTCap
1481
/**
1482     * Returns the XML size of CTCap element as:
1483     * sizeof(<CTCap>\n) +
1484     * for (int i=0; ctTypeSupported != null && i<ctTypeSupported.size(); i++)
1485     * sizeof(ctTypeSupported.get(i)) +
1486     * sizeof(</CTCap>\n)
1487     *
1488     * @return the XML size of CTCap element
1489     */

1490    public static long getXMLSize(CTCap ctCap) {
1491        ArrayList JavaDoc ctTypeSup = ctCap.getCTTypeSupported();
1492        long size = 17;
1493
1494        for (int i=0; ctTypeSup != null && i<ctTypeSup.size(); i++) {
1495            size += getXMLSize((CTTypeSupported)ctTypeSup.get(i));
1496        }
1497        return size;
1498    }
1499
1500    /**
1501     * Returns the WBXML size of CTCap element.
1502     *
1503     * @return the WBXML size of CTCap element
1504     */

1505    public static long getWBXMLSize(CTCap ctCap) {
1506        ArrayList JavaDoc ctTypeSup = ctCap.getCTTypeSupported();
1507        long size = 4;
1508
1509        for (int i=0; ctTypeSup != null && i<ctTypeSup.size(); i++) {
1510            size += getWBXMLSize((CTTypeSupported)ctTypeSup.get(i));
1511        }
1512        return size;
1513    }
1514
1515    // --------------------------------------------------------- CTTypeSupported
1516
/**
1517     * Returns the XML size of CTTypeSupported element as:
1518     * if ctType != null
1519     * sizeof(ctType) +
1520     * for (int i=0; ctPropParams != null && i<ctPropParams.size(); i++)
1521     * sizeof(ctPropParam.get(i))
1522     *
1523     * @return the XML size of CTTypeSupported element
1524     */

1525    public static long getXMLSize(CTTypeSupported ctTypeSupported) {
1526        CTType ctType = ctTypeSupported.getCTType() ;
1527        ArrayList JavaDoc ctPropParams = ctTypeSupported.getCTPropParams();
1528        long size = 0;
1529
1530        for (int i=0; ctPropParams != null && i<ctPropParams.size(); i++) {
1531            size += getXMLSize((CTPropParam)ctPropParams.get(i));
1532        }
1533        return ((ctType != null) ? getXMLSize(ctType) : 0)
1534             + size
1535             ;
1536    }
1537
1538    /**
1539     * Returns the WBXML size of this element.
1540     *
1541     * @return the WBXML size of this element
1542     */

1543    public static long getWBXMLSize(CTTypeSupported ctTypeSupported) {
1544        CTType ctType = ctTypeSupported.getCTType() ;
1545        ArrayList JavaDoc ctPropParams = ctTypeSupported.getCTPropParams();
1546        long size = 0;
1547
1548        for (int i=0; ctPropParams != null && i<ctPropParams.size(); i++) {
1549            size += getWBXMLSize((CTPropParam)ctPropParams.get(i));
1550        }
1551        return ((ctType != null) ? getWBXMLSize(ctType) : 0)
1552             + size
1553             ;
1554    }
1555
1556    // ------------------------------------------------------------------ CTType
1557
/**
1558     * Returns the XML size of CTType element as:
1559     * sizeof(<CTType>) +
1560     * sizeof(ctType) +
1561     * sizeof(</CTType>\n)
1562     *
1563     * @return the XML size of CTType element
1564     */

1565    public static long getXMLSize(CTType ctType) {
1566        return 18
1567             + String.valueOf(ctType.getCTType()).length()
1568             ;
1569    }
1570
1571    /**
1572     * Returns the WBXML size of CTType object.
1573     *
1574     * @return the WBXML size of CTType object
1575     */

1576    public static long getWBXMLSize(CTType ctType) {
1577       return 4
1578            + String.valueOf(ctType.getCTType()).length()
1579        ;
1580    }
1581
1582    // ------------------------------------------------------------- CTPropParam
1583
/**
1584     * Returns the XML size of CTPropParam element as:
1585     * sizeof(<PropName>) +
1586     * sizeof(propName) +
1587     * sizeof(</PropName>\n) +
1588     * for (int i=0; valEnums != null && i<valEnums.size(); i++)
1589     * sizeof(<ValEnum>) +
1590     * sizeof(valEnums.get(i)) +
1591     * sizeof(</ValEnum>\n) +
1592     * if dataType != null
1593     * sizeof(<DataType>) +
1594     * sizeof(dataType) +
1595     * sizeof(</DataType>\n) +
1596     * if size != 0
1597     * sizeof(<Size>) +
1598     * sizeof(size) +
1599     * sizeof(</Size>\n) +
1600     * if displayName != null
1601     * sizeof(<DisplayName>) +
1602     * sizeof(displayName) +
1603     * sizeof(</DisplayName>\n) +
1604     * for (int i=0; ctParameters != null && i<ctParameters.size(); i++)
1605     * sizeof(ctParameters.get(i))
1606     * @return the XML size of CTPropParam element
1607     */

1608    public static long getXMLSize(CTPropParam ctPropParam) {
1609        String JavaDoc propName = ctPropParam.getPropName() ;
1610        ArrayList JavaDoc valEnums = ctPropParam.getValEnum() ;
1611        String JavaDoc dataType = ctPropParam.getDataType() ;
1612        int size = ctPropParam.getSize() ;
1613        String JavaDoc displayName = ctPropParam.getDisplayName() ;
1614        ArrayList JavaDoc ctParameters = ctPropParam.getContentTypeParameters();
1615
1616        long sizeCTPP = 0;
1617        for (int i=0; valEnums != null && i<valEnums.size(); i++) {
1618            sizeCTPP += 20 + ((String JavaDoc)valEnums.get(i)).length();
1619        }
1620
1621        for (int i=0; ctParameters!=null && i<ctParameters.size(); i++) {
1622            sizeCTPP += getXMLSize((ContentTypeParameter)ctParameters.get(i));
1623        }
1624
1625        return ((propName != null) ? 22 + propName.length() : 0)
1626             + ((dataType != null) ? 22 + dataType.length() : 0)
1627             + ((size != 0 ) ? 14 + String.valueOf(size).length() : 0)
1628             + ((displayName != null) ? 28 + displayName.length() : 0)
1629             + sizeCTPP
1630             ;
1631    }
1632
1633    /**
1634     * Returns the WBXML size of CTPropParam element.
1635     *
1636     * @return the WBXML size of CTPropParam element
1637     */

1638    public static long getWBXMLSize(CTPropParam ctPropParam) {
1639        String JavaDoc propName = ctPropParam.getPropName() ;
1640        ArrayList JavaDoc valEnums = ctPropParam.getValEnum() ;
1641        String JavaDoc dataType = ctPropParam.getDataType() ;
1642        int size = ctPropParam.getSize() ;
1643        String JavaDoc displayName = ctPropParam.getDisplayName() ;
1644        ArrayList JavaDoc ctParameters = ctPropParam.getContentTypeParameters();
1645
1646        long sizeCTPP = 0;
1647        for (int i=0; valEnums != null && i<valEnums.size(); i++) {
1648            sizeCTPP += 4 + ((String JavaDoc)valEnums.get(i)).length();
1649        }
1650
1651        for (int i=0; ctParameters!=null && i<ctParameters.size(); i++) {
1652            sizeCTPP += getWBXMLSize((ContentTypeParameter)ctParameters.get(i));
1653        }
1654
1655        return ((propName != null) ? 4 + propName.length() : 0)
1656             + ((dataType != null) ? 4 + dataType.length() : 0)
1657             + ((size != 0 ) ? 4 + String.valueOf(size).length() : 0)
1658             + ((displayName != null) ? 4 + displayName.length() : 0)
1659             + sizeCTPP
1660             ;
1661    }
1662
1663    // ---------------------------------------------------- ContentTypeParameter
1664
/**
1665     * Returns the XML size of ContentTypeParameter element as:
1666     * sizeof(<ParamName>) +
1667     * sizeof(paramName) +
1668     * sizeof(</ParamName>\n) +
1669     * for (int i=0; valEnums != null && i<valEnums.size(); i++)
1670     * sizeof(<ValEnum>) +
1671     * sizeof(valEnum.get(i)) +
1672     * sizeof(</ValEnum>\n) +
1673     * if dataType != null
1674     * sizeof(<DataType>) +
1675     * sizeof(dataType) +
1676     * sizeof(</DataType>\n) +
1677     * if size != 0
1678     * sizeof(<Size>) +
1679     * sizeof(size) +
1680     * sizeof(</Size>\n) +
1681     * if displayName != null
1682     * sizeof(<DisplayName>) +
1683     * sizeof(displayName) +
1684     * sizeof(</DisplayName>\n) +
1685     *
1686     * @return the XML size of CTPropParam element
1687     */

1688    public static long getXMLSize(ContentTypeParameter ctParameter) {
1689        String JavaDoc paramName = ctParameter.getParamName() ;
1690        ArrayList JavaDoc valEnums = ctParameter.getValEnum() ;
1691        String JavaDoc dataType = ctParameter.getDataType() ;
1692        int size = ctParameter.getSize() ;
1693        String JavaDoc displayName = ctParameter.getDisplayName();
1694        long sizeCTP = 0;
1695
1696        for (int i=0; valEnums != null && i<valEnums.size(); i++) {
1697            sizeCTP += 20 + ((String JavaDoc)valEnums.get(i)).length();
1698        }
1699
1700        return ((paramName != null) ? 24 + paramName.length() : 0)
1701             + ((dataType != null) ? 22 + dataType.length() : 0)
1702             + ((size != 0 ) ? 14 + String.valueOf(size).length() : 0)
1703             + ((displayName != null) ? 28 + displayName.length() : 0)
1704             + sizeCTP
1705             ;
1706    }
1707
1708    /**
1709     * Returns the WBXML size of ContentTypeParameter element.
1710     *
1711     * @return the WBXML size of ContentTypeParameter element
1712     */

1713    public static long getWBXMLSize(ContentTypeParameter ctParameter) {
1714        String JavaDoc paramName = ctParameter.getParamName() ;
1715        ArrayList JavaDoc valEnums = ctParameter.getValEnum() ;
1716        String JavaDoc dataType = ctParameter.getDataType() ;
1717        int size = ctParameter.getSize() ;
1718        String JavaDoc displayName = ctParameter.getDisplayName();
1719        long sizeCTP = 0;
1720
1721        for (int i=0; valEnums != null && i<valEnums.size(); i++) {
1722            sizeCTP += 4 + ((String JavaDoc)valEnums.get(i)).length();
1723        }
1724
1725        return ((paramName != null) ? 4 + paramName.length() : 0)
1726             + ((dataType != null) ? 4 + dataType.length() : 0)
1727             + ((size != 0 ) ? 4 + String.valueOf(size).length() : 0)
1728             + ((displayName != null) ? 4 + displayName.length() : 0)
1729             + sizeCTP
1730             ;
1731    }
1732
1733    // --------------------------------------------------------------------- Ext
1734
/**
1735     * Returns the XML size of Ext element as:
1736     * sizeof(<Ext>\n) +
1737     * if name != null
1738     * sizeof(<XNam>) +
1739     * sizeof(name) +
1740     * sizeof(</XNam>\n) +
1741     * for (int i=0; values != null && i<values.size(); i++)
1742     * sizeof(<XVal>) +
1743     * sizeof(values[i]) +
1744     * sizeof(</XVal>\n) +
1745     * sizeof(</Ext>\n)
1746     *
1747     * @return the XML size of Ext element
1748     */

1749    public static long getXMLSize(Ext ext) {
1750        String JavaDoc name = ext.getXNam();
1751        ArrayList JavaDoc values = ext.getXVal();
1752        long size = 13;
1753
1754        for (int i=0; values != null && i<values.size(); i++) {
1755            size += 14 + ((String JavaDoc)values.get(i)).length();
1756        }
1757
1758        return ((name != null) ? 14 + name.length() : 0)
1759             + size
1760             ;
1761    }
1762
1763    /**
1764     * Returns the WBXML size of Ext element.
1765     *
1766     * @return the WBXML size of Ext element
1767     */

1768    public static long getWBXMLSize(Ext ext) {
1769        String JavaDoc name = ext.getXNam();
1770        ArrayList JavaDoc values = ext.getXVal();
1771        long size = 4;
1772
1773        for (int i=0; values != null && i<values.size(); i++) {
1774            size += 4 + ((String JavaDoc)values.get(i)).length();
1775        }
1776
1777        return ((name != null) ? 4 + name.length() : 0)
1778             + size
1779             ;
1780    }
1781    // ------------------------------------------------------------------- Alert
1782
/**
1783     * Returns the XML size of Alert element as:
1784     * sizeof(<Alert>\n) +
1785     * if cmdID != null
1786     * sizeof(cmdID) +
1787     * if noResp
1788     * sizeof(<NoResp></NoResp>\n) +
1789     * if cred != null
1790     * sizeof(cred) +
1791     * if data != null
1792     * sizeof(<Data>) +
1793     * sizeof(data) +
1794     * sizeof(</Data>\n) +
1795     * for (int i=0; items != null && i<items.size(); i++)
1796     * sizeof(items[i]) +
1797     * sizeof(</Alert>\n)
1798     *
1799     * @return the XML size of Alert element
1800     */

1801    public static long getXMLSize(Alert alert) {
1802        int data = alert.getData() ;
1803        ArrayList JavaDoc items = alert.getItems();
1804
1805        long size = 17
1806                  + getXMLSize((AbstractCommand)alert)
1807                  + ((data != 0) ? 14 + String.valueOf(data).length() : 0)
1808                  ;
1809        for (int i=0; items != null && i<items.size(); i++) {
1810            size += getXMLSize((Item)items.get(i));
1811        }
1812        return size;
1813    }
1814
1815    /**
1816     * Returns the WBXML size of Alert element.
1817     *
1818     * @return the WBXML size of Alert element
1819     */

1820    public static long getWBXMLSize(Alert alert) {
1821        int data = alert.getData() ;
1822        ArrayList JavaDoc items = alert.getItems();
1823
1824        long size = 4
1825                  + getWBXMLSize((AbstractCommand)alert)
1826                  + ((data != 0) ? 2 + String.valueOf(data).length() : 0)
1827                  ;
1828        for (int i=0; items != null && i<items.size(); i++) {
1829            size += getWBXMLSize((Item)items.get(i));
1830        }
1831        return size;
1832    }
1833
1834    // ------------------------------------------------------------------ Atomic
1835
/**
1836     * Returns the XML size of Atomic element as:
1837     * sizeof(<Atomic>\n) +
1838     * if cmdID != null
1839     * sizeof(cmdID) +
1840     * if noResp
1841     * sizeof(<NoResp></NoResp>\n) +
1842     * if cred != null
1843     * sizeof(cred) +
1844     * if meta != null
1845     * sizeof(meta) +
1846     * for (int i=0; commands != null && i<commands.size(); i++)
1847     * sizeof(commands[i]) +
1848     * sizeof(</Atomic>\n)
1849     *
1850     * @return the XML size of Atomic element
1851     */

1852    public static long getXMLSize(Atomic atomic) {
1853        Meta meta = atomic.getMeta() ;
1854        ArrayList JavaDoc commands = atomic.getCommands();
1855
1856        long size = 19
1857                  + getXMLSize((AbstractCommand)atomic)
1858                  + ((meta != null) ? getXMLSize(meta) : 0)
1859                  ;
1860        for (int i=0; commands != null && i<commands.size(); i++) {
1861            size += getCommandXMLSize((AbstractCommand)commands.get(i));
1862        }
1863        return size;
1864    }
1865
1866    /**
1867     * Returns the WBXML size of Atomic element.
1868     *
1869     * @return the WBXML size of Atomic element
1870     */

1871    public static long getWBXMLSize(Atomic atomic) {
1872        Meta meta = atomic.getMeta() ;
1873        ArrayList JavaDoc commands = atomic.getCommands();
1874
1875        long size = 4
1876                  + getWBXMLSize((AbstractCommand)atomic)
1877                  + ((meta != null) ? getWBXMLSize(meta) : 0)
1878                  ;
1879        for (int i=0; commands != null && i<commands.size(); i++) {
1880            size += getCommandWBXMLSize((AbstractCommand)commands.get(i));
1881        }
1882        return size;
1883    }
1884
1885    // -------------------------------------------------------------------- Copy
1886
/**
1887     * Returns the XML size of Copy element as:
1888     * sizeof(<Copy>\n) +
1889     * if cmdID != null
1890     * sizeof(cmdID) +
1891     * if noResp
1892     * sizeof(<NoResp></NoResp>\n) +
1893     * if cred != null
1894     * sizeof(cred) +
1895     * if meta != null
1896     * sizeof(meta) +
1897     * for (int i=0; items != null && i<items.size(); i++)
1898     * sizeof(items[i]) +
1899     * sizeof(</Copy>\n)
1900     *
1901     * @return the XML size of Copy element
1902     */

1903    public static long getXMLSize(Copy copy) {
1904        Meta meta = copy.getMeta() ;
1905        ArrayList JavaDoc items = copy.getItems();
1906
1907        long size = 13
1908                  + getXMLSize((AbstractCommand)copy)
1909                  + ((meta != null) ? getXMLSize(meta) : 0)
1910                  ;
1911        for (int i=0; items != null && i<items.size(); i++) {
1912            size += getXMLSize((Item)items.get(i));
1913        }
1914        return size;
1915    }
1916
1917    /**
1918     * Returns the WBXML size of Copy element.
1919     *
1920     * @return the WBXML size of Copy element
1921     */

1922    public static long getWBXMLSize(Copy copy) {
1923        Meta meta = copy.getMeta() ;
1924        ArrayList JavaDoc items = copy.getItems();
1925
1926        long size = 4
1927                  + getWBXMLSize((AbstractCommand)copy)
1928                  + ((meta != null) ? getWBXMLSize(meta) : 0)
1929                  ;
1930        for (int i=0; items != null && i<items.size(); i++) {
1931            size += getWBXMLSize((Item)items.get(i));
1932        }
1933        return size;
1934    }
1935
1936    // ------------------------------------------------------------------ Delete
1937
/**
1938     * Returns the XML size of Delete element as:
1939     * sizeof(<Delete>\n) +
1940     * if cmdID != null
1941     * sizeof(cmdID) +
1942     * if noResp
1943     * sizeof(<NoResp></NoResp>\n) +
1944     * if cred != null
1945     * sizeof(cred) +
1946     * if archive
1947     * sizeof(<Archive></Archive>\n) +
1948     * if sftDel
1949     * sizeof(<SftDel></SftDel>\n) +
1950     * if meta != null
1951     * sizeof(meta) +
1952     * for (int i=0; items != null && i<items.size(); i++)
1953     * sizeof(items[i]) +
1954     * sizeof(</Delete>\n)
1955     *
1956     * @return the XML size of Delete element
1957     */

1958    public static long getXMLSize(Delete delete) {
1959        Meta meta = delete.getMeta() ;
1960        ArrayList JavaDoc items = delete.getItems();
1961
1962        long size = 20
1963                  + getXMLSize((AbstractCommand)delete)
1964                  + ((delete.isArchive()) ? 20 : 0)
1965                  + ((delete.isSftDel() ) ? 18 : 0)
1966                  + ((meta != null ) ? getXMLSize(meta) : 0)
1967                  ;
1968        for (int i=0; items != null && i<items.size(); i++) {
1969            size += getXMLSize((Item)items.get(i));
1970        }
1971        return size;
1972    }
1973
1974    /**
1975     * Returns the WBXML size of Delete element.
1976     *
1977     * @return the WBXML size of Delete element
1978     */

1979    public static long getWBXMLSize(Delete delete) {
1980        Meta meta = delete.getMeta() ;
1981        ArrayList JavaDoc items = delete.getItems();
1982
1983        long size = 4
1984                  + getWBXMLSize((AbstractCommand)delete)
1985                  + ((delete.isArchive()) ? 1 : 0)
1986                  + ((delete.isSftDel() ) ? 1 : 0)
1987                  + ((meta != null ) ? getWBXMLSize(meta) : 0)
1988                  ;
1989        for (int i=0; items != null && i<items.size(); i++) {
1990            size += getWBXMLSize((Item)items.get(i));
1991        }
1992        return size;
1993    }
1994
1995    // -------------------------------------------------------------------- Exec
1996
/**
1997     * Returns the XML size of Exec element as:
1998     * sizeof(<Exec>\n) +
1999     * if cmdID != null
2000     * sizeof(cmdID) +
2001     * if noResp
2002     * sizeof(<NoResp></NoResp>\n) +
2003     * if cred != null
2004     * sizeof(cred) +
2005     * for (int i=0; items != null && i<items.size(); i++)
2006     * sizeof(items[i]) +
2007     * sizeof(</Exec>\n)
2008     *
2009     * @return the XML size of Delete element
2010     */

2011    public static long getXMLSize(Exec exec) {
2012        ArrayList JavaDoc items = exec.getItems();
2013
2014        long size = 14
2015                  + getXMLSize((AbstractCommand)exec)
2016                  ;
2017        for (int i=0; items != null && i<items.size(); i++) {
2018            size += getXMLSize((Item)items.get(i));
2019        }
2020        return size;
2021    }
2022
2023    /**
2024     * Returns the WBXML size of Exec element.
2025     *
2026     * @return the WBXML size of Exec element
2027     */

2028    public static long getWBXMLSize(Exec exec) {
2029        ArrayList JavaDoc items = exec.getItems();
2030
2031        long size = 4
2032                  + getWBXMLSize((AbstractCommand)exec)
2033                  ;
2034        for (int i=0; items != null && i<items.size(); i++) {
2035            size += getWBXMLSize((Item)items.get(i));
2036        }
2037        return size;
2038    }
2039
2040    // --------------------------------------------------------------------- Get
2041
/**
2042     * Returns the XML size of Get element as:
2043     * sizeof(<Get>\n) +
2044     * if cmdID != null
2045     * sizeof(cmdID) +
2046     * if noResp
2047     * sizeof(<NoResp></NoResp>\n) +
2048     * if cred != null
2049     * sizeof(cred) +
2050     * if lang != null
2051     * sizeof(<Lang>) +
2052     * sizeof(lang) +
2053     * sizeof(</Lang>\n) +
2054     * if meta != null
2055     * sizeof(meta) +
2056     * for (int i=0; items != null && i<items.size(); i++)
2057     * sizeof(items[i]) +
2058     * sizeof(</Get>\n)
2059     *
2060     * @return the XML size of Get element
2061     */

2062    public static long getXMLSize(Get get) {
2063        String JavaDoc lang = get.getLang();
2064        Meta meta = get.getMeta() ;
2065        ArrayList JavaDoc items = get.getItems();
2066
2067        long size = 13
2068                  + getXMLSize((AbstractCommand)get)
2069                  + ((lang != null) ? 14 + lang.length() : 0)
2070                  + ((meta != null) ? getXMLSize(meta) : 0)
2071                  ;
2072        for (int i=0; items != null && i<items.size(); i++) {
2073            size += getXMLSize((Item)items.get(i));
2074        }
2075        return size;
2076    }
2077
2078    /**
2079     * Returns the WBXML size of Get element.
2080     *
2081     * @return the WBXML size of Get element
2082     */

2083    public static long getWBXMLSize(Get get) {
2084        String JavaDoc lang = get.getLang();
2085        Meta meta = get.getMeta() ;
2086        ArrayList JavaDoc items = get.getItems();
2087
2088        long size = 4
2089                  + getXMLSize((AbstractCommand)get)
2090                  + ((lang != null) ? 1 + lang.length() : 0)
2091                  + ((meta != null) ? getXMLSize(meta) : 0)
2092                  ;
2093        for (int i=0; items != null && i<items.size(); i++) {
2094            size += getXMLSize((Item)items.get(i));
2095        }
2096        return size;
2097    }
2098
2099    // --------------------------------------------------------------------- Map
2100
/**
2101     * Returns the XML size of Map element as:
2102     * sizeof(<Map>\n) +
2103     * if cmdID != null
2104     * sizeof(cmdID) +
2105     * if noResp
2106     * sizeof(<NoResp></NoResp>\n) +
2107     * if cred != null
2108     * sizeof(cred) +
2109     * if target != null
2110     * sizeof(target) +
2111     * if source != null
2112     * sizeof(source) +
2113     * if meta != null
2114     * sizeof(meta) +
2115     * for (int i=0; mapItems != null && i<mapItems.size(); i++)
2116     * sizeof(mapItems[i]) +
2117     * sizeof(</Map>\n)
2118     *
2119     * @return the XML size of Map element
2120     */

2121    public static long getXMLSize(Map map) {
2122        Target target = map.getTarget();
2123        Source source = map.getSource();
2124        Meta meta = map.getMeta() ;
2125        ArrayList JavaDoc mapItems = map.getMapItems();
2126
2127        long size = 13
2128                  + getXMLSize((AbstractCommand)map)
2129                  + ((target != null) ? getXMLSize(target) : 0)
2130                  + ((source != null) ? getXMLSize(source) : 0)
2131                  + ((meta != null) ? getXMLSize(meta) : 0)
2132                  ;
2133        for (int i=0; mapItems != null && i<mapItems.size(); i++) {
2134            size += getXMLSize((MapItem)mapItems.get(i));
2135        }
2136        return size;
2137    }
2138
2139    /**
2140     * Returns the WBXML size of Map element.
2141     *
2142     * @return the WBXML size of Map element
2143     */

2144    public static long getWBXMLSize(Map map) {
2145        Target target = map.getTarget();
2146        Source source = map.getSource();
2147        Meta meta = map.getMeta() ;
2148        ArrayList JavaDoc mapItems = map.getMapItems();
2149
2150        long size = 4
2151                  + getWBXMLSize((AbstractCommand)map)
2152                  + ((target != null) ? getWBXMLSize(target) : 0)
2153                  + ((source != null) ? getWBXMLSize(source) : 0)
2154                  + ((meta != null) ? getWBXMLSize(meta) : 0)
2155                  ;
2156        for (int i=0; mapItems != null && i<mapItems.size(); i++) {
2157            size += getWBXMLSize((MapItem)mapItems.get(i));
2158        }
2159        return size;
2160    }
2161
2162    // ----------------------------------------------------------------- MapItem
2163
/**
2164     * Returns the XML size of MapItem element as:
2165     * sizeof(<MapItem>\n) +
2166     * if target != null
2167     * sizeof(target) +
2168     * if source != null
2169     * sizeof(source) +
2170     * sizeof(</MapItem>\n)
2171     *
2172     * @return the XML size of MapItem element
2173     */

2174    public static long getXMLSize(MapItem mapItem) {
2175        Target target = mapItem.getTarget();
2176        Source source = mapItem.getSource();
2177
2178        return 21
2179             + ((target != null) ? getXMLSize(target) : 0)
2180             + ((source != null) ? getXMLSize(source) : 0)
2181             ;
2182    }
2183
2184    /**
2185     * Returns the WBXML size of MapItem element.
2186     *
2187     * @return the WBXML size of MapItem element
2188     */

2189    public static long getWBXMLSize(MapItem mapItem) {
2190        Target target = mapItem.getTarget();
2191        Source source = mapItem.getSource();
2192
2193        return 2
2194             + ((target != null) ? getWBXMLSize(target) : 0)
2195             + ((source != null) ? getWBXMLSize(source) : 0)
2196             ;
2197    }
2198
2199    // --------------------------------------------------------------------- Put
2200
/**
2201     * Returns the XML size of Put element as:
2202     * sizeof(<Put>\n) +
2203     * if cmdID != null
2204     * sizeof(cmdID) +
2205     * if noResp
2206     * sizeof(<NoResp></NoResp>\n) +
2207     * if cred != null
2208     * sizeof(cred) +
2209     * if lang != null
2210     * sizeof(<Lang>) +
2211     * sizeof(lang) +
2212     * sizeof(</Lang>\n) +
2213     * if meta != null
2214     * sizeof(meta) +
2215     * for (int i=0; devInfItems != null && i<devInfItems.size(); i++)
2216     * sizeof(devInfItems[i]) +
2217     * sizeof(</Put>\n)
2218     *
2219     * @return the XML size of Put element
2220     */

2221    public static long getXMLSize(Put put) {
2222        String JavaDoc lang = put.getLang();
2223        Meta meta = put.getMeta() ;
2224        ArrayList JavaDoc devInfItems = put.getItems();
2225
2226        long size = 14
2227                  + getXMLSize((AbstractCommand)put)
2228                  + ((lang != null) ? 14 + lang.length() : 0)
2229                  + ((meta != null) ? getXMLSize(meta) : 0)
2230                  ;
2231        for (int i=0; devInfItems != null && i<devInfItems.size(); i++) {
2232            size += getXMLSize((DevInfItem)devInfItems.get(i));
2233        }
2234        return size;
2235    }
2236
2237    /**
2238     * Returns the WBXML size of Put element.
2239     *
2240     * @return the WBXML size of Put element
2241     */

2242    public static long getWBXMLSize(Put put) {
2243        String JavaDoc lang = put.getLang();
2244        Meta meta = put.getMeta() ;
2245        ArrayList JavaDoc devInfItems = put.getItems();
2246
2247        long size = 4
2248                  + getWBXMLSize((AbstractCommand)put)
2249                  + ((lang != null) ? 1 + lang.length() : 0)
2250                  + ((meta != null) ? getWBXMLSize(meta) : 0)
2251                  ;
2252        for (int i=0; devInfItems != null && i<devInfItems.size(); i++) {
2253            size += getWBXMLSize((DevInfItem)devInfItems.get(i));
2254        }
2255        return size;
2256    }
2257
2258    // -------------------------------------------------------------- DevInfItem
2259
/**
2260     * Returns the XML size of Item element as:
2261     * sizeof(<Item>\n) +
2262     * if target != null
2263     * sizeof(target) +
2264     * if source != null
2265     * sizeof(source) +
2266     * if meta != null
2267     * sizeof(meta) +
2268     * if data != null
2269     * sizeof(data) +
2270     * sizeof(</Item>\n)
2271     *
2272     * @return the XML size of Item element
2273     */

2274    public static long getXMLSize(DevInfItem devInfItem) {
2275        Target target = devInfItem.getTarget() ;
2276        Source source = devInfItem.getSource() ;
2277        Meta meta = devInfItem.getMeta() ;
2278        DevInfData devInfData = devInfItem.getDevInfData();
2279
2280        return 15
2281             + ((target != null) ? getXMLSize(target) : 0)
2282             + ((source != null) ? getXMLSize(source) : 0)
2283             + ((meta != null) ? getXMLSize(meta) : 0)
2284             + ((devInfData != null) ? getXMLSize(devInfData) : 0)
2285             ;
2286    }
2287
2288    /**
2289     * Returns the WBXML size of Item element.
2290     * @return the WBXML size of Item element
2291     */

2292    public static long getWBXMLSize(DevInfItem devInfItem) {
2293        Target target = devInfItem.getTarget() ;
2294        Source source = devInfItem.getSource() ;
2295        Meta meta = devInfItem.getMeta() ;
2296        DevInfData devInfData = devInfItem.getDevInfData();
2297
2298        return 4
2299             + ((target != null) ? getWBXMLSize(target) : 0)
2300             + ((source != null) ? getWBXMLSize(source) : 0)
2301             + ((meta != null) ? getWBXMLSize(meta) : 0)
2302             + ((devInfData != null) ? getWBXMLSize(devInfData) : 0)
2303             ;
2304    }
2305
2306    // ----------------------------------------------------------------- Replace
2307
/**
2308     * Returns the XML size of Replace element as:
2309     * sizeof(<Replace>\n) +
2310     * if cmdID != null
2311     * sizeof(cmdID) +
2312     * if noResp
2313     * sizeof(<NoResp></NoResp>\n) +
2314     * if cred != null
2315     * sizeof(cred) +
2316     * if meta != null
2317     * sizeof(meta) +
2318     * for (int i=0; items != null && i<items.size(); i++)
2319     * sizeof(items[i]) +
2320     * sizeof(</Replace>\n)
2321     *
2322     * @return the XML size of Replace element
2323     */

2324    public static long getXMLSize(Replace replace) {
2325        Meta meta = replace.getMeta() ;
2326        ArrayList JavaDoc items = replace.getItems();
2327
2328        long size = 21
2329                  + getXMLSize((AbstractCommand)replace)
2330                  + ((meta != null) ? getXMLSize(meta) : 0)
2331                  ;
2332        for (int i=0; items != null && i<items.size(); i++) {
2333            size += getXMLSize((Item)items.get(i));
2334        }
2335        return size;
2336    }
2337
2338    /**
2339     * Returns the WBXML size of Replace element.
2340     *
2341     * @return the WBXML size of Replace element
2342     */

2343    public static long getWBXMLSize(Replace replace) {
2344        Meta meta = replace.getMeta() ;
2345        ArrayList JavaDoc items = replace.getItems();
2346
2347        long size = 4
2348                  + getWBXMLSize((AbstractCommand)replace)
2349                  + ((meta != null) ? getWBXMLSize(meta) : 0)
2350                  ;
2351        for (int i=0; items != null && i<items.size(); i++) {
2352            size += getWBXMLSize((Item)items.get(i));
2353        }
2354        return size;
2355    }
2356
2357    // ----------------------------------------------------------------- Results
2358
/**
2359     * Returns the XML size of Results element as:
2360     * sizeof(<Results>\n) +
2361     * if cmdID != null
2362     * sizeof(cmdID) +
2363     * if noResp
2364     * sizeof(<NoResp></NoResp>\n) +
2365     * if cred != null
2366     * sizeof(cred) +
2367     * if msgRef != null
2368     * sizeof(<MsgRef>) +
2369     * sizeof(msgRef) +
2370     * sizeof(</MsgRef>\n) +
2371     * if cmdRef != null
2372     * sizeof(<CmdRef>) +
2373     * sizeof(cmdRef) +
2374     * sizeof(</CmdRef>\n) +
2375     * if meta != null
2376     * sizeof(meta) +
2377     * for (int i=0; targetRefs != null && i<targetRefs.size(); i++)
2378     * sizeof(targetRefs[i]) +
2379     * for (int i=0; sourceRefs != null && i<sourceRefs.size(); i++)
2380     * sizeof(sourceRefs[i]) +
2381     * for (int i=0; items != null && i<items.size(); i++)
2382     * sizeof(items[i]) +
2383     * sizeof(</Results>\n)
2384     *
2385     * @return the XML size of Results element
2386     */

2387    public static long getXMLSize(Results results) {
2388        String JavaDoc msgRef = results.getMsgRef() ;
2389        String JavaDoc cmdRef = results.getCmdRef() ;
2390        Meta meta = results.getMeta() ;
2391        ArrayList JavaDoc targetRefs = results.getTargetRef();
2392        ArrayList JavaDoc sourceRefs = results.getSourceRef();
2393        ArrayList JavaDoc items = results.getItems() ;
2394
2395        long size = 21
2396                  + getXMLSize((AbstractCommand)results)
2397                  + ((msgRef != null) ? 18 + msgRef.length() : 0)
2398                  + ((cmdRef != null) ? 18 + cmdRef.length() : 0)
2399                  + ((meta != null) ? getXMLSize(meta) : 0)
2400                  ;
2401        for (int i=0; targetRefs != null && i<targetRefs.size(); i++) {
2402            size += getXMLSize((TargetRef)targetRefs.get(i));
2403        }
2404        for (int i=0; sourceRefs != null && i<sourceRefs.size(); i++) {
2405            size += getXMLSize((SourceRef)sourceRefs.get(i));
2406        }
2407        for (int i=0; items != null && i<items.size(); i++) {
2408            size += getXMLSize((Item)items.get(i));
2409        }
2410        return size;
2411    }
2412
2413    /**
2414     * Returns the WBXML size of Results element.
2415     *
2416     * @return the WBXML size of Results element
2417     */

2418    public static long getWBXMLSize(Results results) {
2419        String JavaDoc msgRef = results.getMsgRef() ;
2420        String JavaDoc cmdRef = results.getCmdRef() ;
2421        Meta meta = results.getMeta() ;
2422        ArrayList JavaDoc targetRefs = results.getTargetRef();
2423        ArrayList JavaDoc sourceRefs = results.getSourceRef();
2424        ArrayList JavaDoc items = results.getItems() ;
2425
2426        long size = 4
2427                  + getWBXMLSize((AbstractCommand)results)
2428                  + ((msgRef != null) ? 4 + msgRef.length() : 0)
2429                  + ((cmdRef != null) ? 4 + cmdRef.length() : 0)
2430                  + ((meta != null) ? getWBXMLSize(meta) : 0)
2431                  ;
2432        for (int i=0; targetRefs != null && i<targetRefs.size(); i++) {
2433            size += getWBXMLSize((TargetRef)targetRefs.get(i));
2434        }
2435        for (int i=0; sourceRefs != null && i<sourceRefs.size(); i++) {
2436            size += getWBXMLSize((SourceRef)sourceRefs.get(i));
2437        }
2438        for (int i=0; items != null && i<items.size(); i++) {
2439            size += getWBXMLSize((Item)items.get(i));
2440        }
2441        return size;
2442    }
2443
2444    // --------------------------------------------------------------- TargetRef
2445
/**
2446     * Returns the XML size of TargetRef element as:
2447     * sizeof(<TargetRef>) +
2448     * if value != null
2449     * sizeof(value) +
2450     * if target != null
2451     * sizeof(targe) +
2452     * sizeof(</TargetRef>\n)
2453     *
2454     * @return the XML size of TargetRef element
2455     */

2456    public static long getXMLSize(TargetRef targetRef) {
2457        String JavaDoc value = targetRef.getValue() ;
2458        Target target = targetRef.getTarget();
2459
2460        return 24
2461             + ((value != null) ? value.length() : 0)
2462             + ((target != null) ? getXMLSize(target) : 0)
2463             ;
2464    }
2465
2466    /**
2467     * Returns the WBXML size of TargetRef element.
2468     * @return the WBXML size of TargetRef element
2469     */

2470    public static long getWBXMLSize(TargetRef targetRef) {
2471        String JavaDoc value = targetRef.getValue() ;
2472        Target target = targetRef.getTarget();
2473
2474        return 4
2475             + ((value != null) ? value.length() : 0)
2476             + ((target != null) ? getWBXMLSize(target) : 0)
2477             ;
2478    }
2479
2480    // ------------------------------------------------------------------ Search
2481
/**
2482     * Returns the XML size of Search element as:
2483     * sizeof(<Search>\n) +
2484     * if cmdID != null
2485     * sizeof(cmdID) +
2486     * if noResp
2487     * sizeof(<NoResp></NoResp>\n) +
2488     * if cred != null
2489     * sizeof(cred) +
2490     * if noResults
2491     * sizeof(<NoResults></NoResults>\n) +
2492     * if target != null
2493     * sizeof(target) +
2494     * for (int i=0; sources != null && i<sources.size(); i++)
2495     * sizeof(sources[i]) +
2496     * if lang != null
2497     * sizeof(<Lang>) +
2498     * sizeof(lang) +
2499     * sizeof(</Lang)\n) +
2500     * if meta != null
2501     * sizeof(meta) +
2502     * if data != null
2503     * sizeof(data) +
2504     * sizeof(</Search>\n)
2505     *
2506     * @return the XML size of Search element
2507     */

2508    public static long getXMLSize(Search search) {
2509        Target target = search.getTarget() ;
2510        ArrayList JavaDoc sources = search.getSources();
2511        String JavaDoc lang = search.getLang() ;
2512        Meta meta = search.getMeta() ;
2513        Data data = search.getData() ;
2514
2515        long size =
2516                  + getXMLSize((AbstractCommand)search)
2517                  + ((search.isNoResults()) ? 24 : 0)
2518                  + ((target != null) ? getXMLSize(target) : 0)
2519                  + ((lang != null) ? 14 + lang.length() : 0)
2520                  + ((meta != null) ? getXMLSize(meta) : 0)
2521                  + ((data != null) ? getXMLSize(data) : 0)
2522                  ;
2523        for (int i=0; sources != null && i<sources.size(); i++) {
2524            size += getXMLSize((Source)sources.get(i));
2525        }
2526        return size;
2527    }
2528
2529    /**
2530     * Returns the WBXML size of Search element.
2531     *
2532     * @return the WBXML size of Search element
2533     */

2534    public static long getWBXMLSize(Search search) {
2535        Target target = search.getTarget() ;
2536        ArrayList JavaDoc sources = search.getSources();
2537        String JavaDoc lang = search.getLang() ;
2538        Meta meta = search.getMeta() ;
2539        Data data = search.getData() ;
2540
2541        long size =
2542                  + getWBXMLSize((AbstractCommand)search)
2543                  + ((search.isNoResults()) ? 1 : 0)
2544                  + ((target != null) ? getXMLSize(target) : 0)
2545                  + ((lang != null) ? 1 + lang.length() : 0)
2546                  + ((meta != null) ? getWBXMLSize(meta) : 0)
2547                  + ((data != null) ? getWBXMLSize(data) : 0)
2548                  ;
2549        for (int i=0; sources != null && i<sources.size(); i++) {
2550            size += getWBXMLSize((Source)sources.get(i));
2551        }
2552        return size;
2553    }
2554
2555    // ---------------------------------------------------------------- Sequence
2556
/**
2557     * Returns the XML size of Sequence element as:
2558     * sizeof(<Sequence>\n) +
2559     * if cmdID != null
2560     * sizeof(cmdID) +
2561     * if noResp
2562     * sizeof(<NoResp></NoResp>\n) +
2563     * if cred != null
2564     * sizeof(cred) +
2565     * if meta != null
2566     * sizeof(meta) +
2567     * for (int i=0; commands != null && i<commands.size(); i++)
2568     * sizeof(commands[i]) +
2569     * sizeof(</Sequence>\n)
2570     *
2571     * @return the XML size of Sequence element
2572     */

2573    public static long getXMLSize(Sequence sequence) {
2574        Meta meta = sequence.getMeta() ;
2575        ArrayList JavaDoc commands = sequence.getCommands();
2576
2577        long size = 23
2578                  + getXMLSize((AbstractCommand)sequence)
2579                  + ((meta != null) ? getXMLSize(meta) : 0)
2580                  ;
2581        for (int i=0; commands != null && i<commands.size(); i++) {
2582            size += getCommandXMLSize((AbstractCommand)commands.get(i));
2583        }
2584        return size;
2585    }
2586
2587    /**
2588     * Returns the WBXML size of Sequence element.
2589     *
2590     * @return the WBXML size of Sequence element
2591     */

2592    public static long getWBXMLSize(Sequence sequence) {
2593        Meta meta = sequence.getMeta() ;
2594        ArrayList JavaDoc commands = sequence.getCommands();
2595
2596        long size = 4
2597                  + getWBXMLSize((AbstractCommand)sequence)
2598                  + ((meta != null) ? getWBXMLSize(meta) : 0)
2599                  ;
2600        for (int i=0; commands != null && i<commands.size(); i++) {
2601            size += getCommandWBXMLSize((AbstractCommand)commands.get(i));
2602        }
2603        return size;
2604    }
2605
2606    // ------------------------------------------------------------------ Status
2607
/**
2608     * Returns the XML size of Status element as:
2609     * sizeof(<Status>\n) +
2610     * if cmdID != null
2611     * sizeof(cmdID) +
2612     * if msgRef != null
2613     * sizeof(<MsgRef>) +
2614     * sizeof(msgRef) +
2615     * sizeof(</MsgRef>\n) +
2616     * if cmdRef != null
2617     * sizeof(<CmdRef>) +
2618     * sizeof(cmdRef) +
2619     * sizeof(</CmdRef>\n) +
2620     * if cmd != null
2621     * sizeof(<Cmd) +
2622     * sizeof(cmd) +
2623     * sizeof(</Cmd>\n) +
2624     * for (int i=0; targetRefs != null && i<targetRefs.size(); i++)
2625     * sizeof(targetRefs[i]) +
2626     * for (int i=0; sourceRefs != null && i<sourceRefs.size(); i++)
2627     * sizeof(sourceRefs[i]) +
2628     * if cred != null
2629     * sizeof(cred) +
2630     * if chal != null
2631     * sizeof(chal) +
2632     * if data != null
2633     * sizeof(data) +
2634     * for (int i=0; items != null && i<items.size(); i++)
2635     * sizeof(items[i]) +
2636     * sizeof(</Status>\n)
2637     *
2638     * @return the XML size of Status element
2639     */

2640    public static long getXMLSize(Status status) {
2641        CmdID cmdID = status.getCmdID() ;
2642        String JavaDoc msgRef = status.getMsgRef() ;
2643        String JavaDoc cmdRef = status.getCmdRef() ;
2644        String JavaDoc cmd = status.getCmd() ;
2645        ArrayList JavaDoc targetRefs = status.getTargetRef();
2646        ArrayList JavaDoc sourceRefs = status.getSourceRef();
2647        Cred cred = status.getCred() ;
2648        Chal chal = status.getChal() ;
2649        Data data = status.getData() ;
2650        ArrayList JavaDoc items = status.getItems() ;
2651
2652        long size = 19
2653                  + ((cmdID != null) ? getXMLSize(cmdID) : 0)
2654                  + ((msgRef != null) ? 18 + msgRef.length() : 0)
2655                  + ((cmdRef != null) ? 18 + cmdRef.length() : 0)
2656                  + ((cmd != null) ? 12 + cmd.length() : 0)
2657                  + ((cred != null) ? getXMLSize(cred) : 0)
2658                  + ((chal != null) ? getXMLSize(chal) : 0)
2659                  + ((data != null) ? getXMLSize(data) : 0)
2660                  ;
2661        for (int i=0; targetRefs != null && i<targetRefs.size(); i++) {
2662            size += getXMLSize((TargetRef)targetRefs.get(i));
2663        }
2664        for (int i=0; sourceRefs != null && i<sourceRefs.size(); i++) {
2665            size += getXMLSize((SourceRef)sourceRefs.get(i));
2666        }
2667        for (int i=0; items != null && i<items.size(); i++) {
2668            size += getXMLSize((Item)items.get(i));
2669        }
2670        return size;
2671    }
2672
2673    /**
2674     * Returns the WBXML size of Status element.
2675     *
2676     * @return the WBXML size of Status element
2677     */

2678    public static long getWBXMLSize(Status status) {
2679        CmdID cmdID = status.getCmdID() ;
2680        String JavaDoc msgRef = status.getMsgRef() ;
2681        String JavaDoc cmdRef = status.getCmdRef() ;
2682        String JavaDoc cmd = status.getCmd() ;
2683        ArrayList JavaDoc targetRefs = status.getTargetRef();
2684        ArrayList JavaDoc sourceRefs = status.getSourceRef();
2685        Cred cred = status.getCred() ;
2686        Chal chal = status.getChal() ;
2687        Data data = status.getData() ;
2688        ArrayList JavaDoc items = status.getItems() ;
2689
2690        long size = 4
2691                  + ((cmdID != null) ? getWBXMLSize(cmdID) : 0)
2692                  + ((msgRef != null) ? 4 + msgRef.length() : 0)
2693                  + ((cmdRef != null) ? 4 + cmdRef.length() : 0)
2694                  + ((cmd != null) ? 4 + cmd.length() : 0)
2695                  + ((cred != null) ? getWBXMLSize(cred) : 0)
2696                  + ((chal != null) ? getWBXMLSize(chal) : 0)
2697                  + ((data != null) ? getWBXMLSize(data) : 0)
2698                  ;
2699        for (int i=0; targetRefs != null && i<targetRefs.size(); i++) {
2700            size += getWBXMLSize((TargetRef)targetRefs.get(i));
2701        }
2702        for (int i=0; sourceRefs != null && i<sourceRefs.size(); i++) {
2703            size += getWBXMLSize((SourceRef)sourceRefs.get(i));
2704        }
2705        for (int i=0; items != null && i<items.size(); i++) {
2706            size += getWBXMLSize((Item)items.get(i));
2707        }
2708        return size;
2709    }
2710    // -------------------------------------------------------------------- Chal
2711
/**
2712     * Returns the XML size of Chal element as:
2713     * sizeof(<Chal>\n) +
2714     * if meta != null
2715     * sizeof(meta) +
2716     * sizeof</Chal>\n)
2717     *
2718     * @return the XML size of Chal element
2719     */

2720    public static long getXMLSize(Chal chal) {
2721        Meta meta = chal.getMeta();
2722
2723        return 15
2724             + ((meta != null) ? getXMLSize(meta) : 0)
2725             ;
2726    }
2727
2728    /**
2729     * Returns the WBXML size of Chal element.
2730     *
2731     * @return the WBXML size of Chal element
2732     */

2733    public static long getWBXMLSize(Chal chal) {
2734        Meta meta = chal.getMeta();
2735
2736        return 4
2737             + ((meta != null) ? getXMLSize(meta) : 0)
2738             ;
2739    }
2740
2741    // -------------------------------------------------------------------- Sync
2742
/**
2743     * Returns the XML size of Sync element as:
2744     * sizeof(<Sync>\n) +
2745     * if cmdID != null
2746     * sizeof(cmdID) +
2747     * if noResp
2748     * sizeof(<NoResp></NoResp>\n) +
2749     * if cred != null
2750     * sizeof(cred) +
2751     * if target != null
2752     * sizeof(target) +
2753     * if source != null
2754     * sizeof(source) +
2755     * if meta != null
2756     * sizeof(meta) +
2757     * if numberOfChanges != 0
2758     * sizeof(<NumberOfChanges>) +
2759     * sizeof(numberOfChanges) +
2760     * sizeof(</NumberOfChanges>\n) +
2761     * for (int i=0; commands != null && i<commands.size(); i++)
2762     * sizeof(commands[i]) +
2763     * sizeof(</Sync>\n)
2764     *
2765     * @return the XML size of Sync element
2766     */

2767    public static long getXMLSize(Sync sync) {
2768        Target target = sync.getTarget() ;
2769        Source source = sync.getSource() ;
2770        Meta meta = sync.getMeta() ;
2771        int numberOfChanges = sync.getNumberOfChanges();
2772        ArrayList JavaDoc commands = sync.getCommands() ;
2773
2774        long size = 15
2775                  + getXMLSize((AbstractCommand)sync)
2776                  + ((target != null) ? getXMLSize(target) : 0)
2777                  + ((source != null) ? getXMLSize(source) : 0)
2778                  + ((meta != null) ? getXMLSize(meta) : 0)
2779                  + ((numberOfChanges != 0 ) ? 36 : 0)
2780                  ;
2781        for (int i=0; commands != null && i<commands.size(); i++) {
2782            size += getCommandXMLSize((AbstractCommand)commands.get(i));
2783        }
2784        return size;
2785    }
2786
2787    /**
2788     * Returns the WBXML size of Sync element.
2789     *
2790     * @return the WBXML size of Sync element
2791     */

2792    public static long getWBXMLSize(Sync sync) {
2793        Target target = sync.getTarget() ;
2794        Source source = sync.getSource() ;
2795        Meta meta = sync.getMeta() ;
2796        int numberOfChanges = sync.getNumberOfChanges();
2797        ArrayList JavaDoc commands = sync.getCommands() ;
2798
2799        long size = 4
2800                  + getWBXMLSize((AbstractCommand)sync)
2801                  + ((target != null) ? getWBXMLSize(target) : 0)
2802                  + ((source != null) ? getWBXMLSize(source) : 0)
2803                  + ((meta != null) ? getWBXMLSize(meta) : 0)
2804                  + ((numberOfChanges != 0 ) ? 4 : 0)
2805                  ;
2806        for (int i=0; commands != null && i<commands.size(); i++) {
2807            size += getCommandWBXMLSize((AbstractCommand)commands.get(i));
2808        }
2809        return size;
2810    }
2811
2812    // --------------------------------------------------------- ItemizedCommand
2813
/**
2814     * Returns the XML size of the ItemizedCommand element
2815     */

2816    public static long getXMLSize(ItemizedCommand itemCmd) {
2817        Meta meta = itemCmd.getMeta() ;
2818        ArrayList JavaDoc items = itemCmd.getItems();
2819        long size = 0;
2820
2821        size = getXMLSize((AbstractCommand)itemCmd)
2822             + ((meta != null) ? getXMLSize(meta) : 0)
2823             ;
2824
2825        for (int i=0; items != null && i<items.size(); i++) {
2826            size += getXMLSize((Item)items.get(i));
2827        }
2828        return size;
2829    }
2830
2831    /**
2832     * Returns the WBXML size of the ItemizedCommand element
2833     */

2834    public static long getWBXMLSize(ItemizedCommand itemCmd) {
2835        Meta meta = itemCmd.getMeta() ;
2836        ArrayList JavaDoc items = itemCmd.getItems();
2837        long size = 0;
2838
2839        size = getWBXMLSize((AbstractCommand)itemCmd)
2840             + ((meta != null) ? getWBXMLSize(meta) : 0)
2841             ;
2842
2843        for (int i=0; items != null && i<items.size(); i++) {
2844            size += getWBXMLSize((Item)items.get(i));
2845        }
2846        return size;
2847    }
2848
2849    // ----------------------------------------------------- ModificationCommand
2850
/**
2851     * Returns the XML size of ModificationCommand object.
2852     *
2853     * @return the XML size of ModificationCommand object
2854     */

2855    public static long getXMLSize(ModificationCommand modCmd) {
2856        return getXMLSize((ItemizedCommand)modCmd);
2857    }
2858
2859    /**
2860     * Returns the WBXML size of ModificationCommand object.
2861     *
2862     * @return the WBXML size of ModificationCommand object
2863     */

2864    public static long getWBXMLSize(ModificationCommand modCmd) {
2865        return getWBXMLSize((ItemizedCommand)modCmd);
2866    }
2867
2868    // --------------------------------------------------------- ResponseCommand
2869
/**
2870     * Returns the XML size of ResponseCommand object.
2871     *
2872     * @return the XML size of ResponseCommand object
2873     */

2874    public static long getXMLSize(ResponseCommand responseCmd) {
2875        String JavaDoc msgRef = responseCmd.getMsgRef() ;
2876        String JavaDoc cmdRef = responseCmd.getCmdRef() ;
2877        ArrayList JavaDoc targetRefs = responseCmd.getTargetRef();
2878        ArrayList JavaDoc sourceRefs = responseCmd.getSourceRef();
2879        long size = 0;
2880
2881        size = getXMLSize((ItemizedCommand)responseCmd)
2882             + ((msgRef != null) ? 18 + msgRef.length() : 0)
2883             + ((cmdRef != null) ? 18 + cmdRef.length() : 0)
2884             ;
2885
2886        for (int i=0; targetRefs != null && i<targetRefs.size(); ++i) {
2887            size += getXMLSize((TargetRef)targetRefs.get(i));
2888        }
2889        for (int i=0; sourceRefs != null && i<sourceRefs.size(); ++i) {
2890            size += getXMLSize((SourceRef)sourceRefs.get(i));
2891        }
2892        return size;
2893    }
2894
2895    /**
2896     * Returns the WBXML size of ResponseCommand object.
2897     *
2898     * @return the WBXML size of ResponseCommand object
2899     */

2900    public static long getWBXMLSize(ResponseCommand responseCmd) {
2901        String JavaDoc msgRef = responseCmd.getMsgRef() ;
2902        String JavaDoc cmdRef = responseCmd.getCmdRef() ;
2903        ArrayList JavaDoc targetRefs = responseCmd.getTargetRef();
2904        ArrayList JavaDoc sourceRefs = responseCmd.getSourceRef();
2905        long size = 0;
2906
2907        size = getWBXMLSize((ItemizedCommand)responseCmd)
2908             + ((msgRef != null) ? 4 + msgRef.length() : 0)
2909             + ((cmdRef != null) ? 4 + cmdRef.length() : 0)
2910             ;
2911
2912        for (int i=0; targetRefs != null && i<targetRefs.size(); ++i) {
2913            size += getWBXMLSize((TargetRef)targetRefs.get(i));
2914        }
2915        for (int i=0; sourceRefs != null && i<sourceRefs.size(); ++i) {
2916            size += getWBXMLSize((SourceRef)sourceRefs.get(i));
2917        }
2918        return size;
2919    }
2920}
Popular Tags