KickJava   Java API By Example, From Geeks To Geeks.

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


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 import sync4j.framework.engine.MessageSizeCalculator;
26
27 /**
28  * Utility class for calculate the XML size and WBXML size of framework Objects
29  *
30  * @author Luigia Fassina @ Funambol
31  * @version $Id: XMLSizeCalculator.java,v 1.9 2005/04/29 15:32:51 nichele Exp $
32  */

33 public class XMLSizeCalculator
34 implements MessageSizeCalculator {
35
36     // ---------------------------------------------------------- Public methods
37
/**
38      * Returns the default XML overhead for the SyncML message
39      *
40      * @return overhead for SyncML message
41      */

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

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

68     public long getSize(SyncML syncML) {
69         SyncHdr syncHdr = syncML.getSyncHdr() ;
70         SyncBody syncBody = syncML.getSyncBody();
71
72         return 43
73              + getSize(syncHdr )
74              + getSize(syncBody)
75              ;
76     }
77
78     // ----------------------------------------------------------------- SyncHdr
79
/**
80      * Returns the XML size of SyncHdr element as:
81      * sizeof(<SyncHdr>\n) +
82      * if verDTD != null
83      * sizeof(verDTD) +
84      * if verProto != null
85      * sizeof(verProto) +
86      * if sessionID != null
87      * sizeof(<SessionID>) +
88      * if msgId != null
89      * sizeof(<MsgID>) +
90      * msgId.length +
91      * sizeof(</MsgID>\n) +
92      * if target != null
93      * sizeof(target) +
94      * if source != null
95      * sizeof(source) +
96      * if respURI
97      * sizeof(<RespURI>) +
98      * sizeof(respURI) +
99      * sizeof(</RespURI>\n) +
100      * if noResp
101      * sizeof(<NoResp></NoResp>\n) +
102      * if cred != null
103      * sizeof(cred) +
104      * if meta != null
105      * sizeof(meta) +
106      * sizeof(</SyncHdr>\n) +
107      *
108      * @return the XML size of this element
109      */

110     public long getSize(SyncHdr syncHdr) {
111
112         VerDTD verDTD = syncHdr.getVerDTD() ;
113         VerProto verProto = syncHdr.getVerProto() ;
114         SessionID sessionID = syncHdr.getSessionID();
115         String JavaDoc msgID = syncHdr.getMsgID() ;
116         Target target = syncHdr.getTarget() ;
117         Source source = syncHdr.getSource() ;
118         String JavaDoc respURI = syncHdr.getRespURI() ;
119         boolean noResp = syncHdr.isNoResp() ;
120         Cred cred = syncHdr.getCred() ;
121         Meta meta = syncHdr.getMeta() ;
122
123         return 21
124              + ((verDTD != null) ? getSize(verDTD) : 0)
125              + ((verProto != null) ? getSize(verProto) : 0)
126              + ((sessionID != null) ? getSize(sessionID) : 0)
127              + ((msgID != null) ? 16 + msgID.length() : 0)
128              + ((target != null) ? getSize(target) : 0)
129              + ((source != null) ? getSize(source) : 0)
130              + ((respURI != null) ? 19 + respURI.length() : 90)
131              + (noResp ? 18 : 0)
132              + ((cred != null) ? getSize(cred) : 0)
133              + ((meta != null) ? getSize(meta) : 0)
134              ;
135     }
136     
137     /**
138      * Returns the XML overhead of the RespURI element.
139      *
140      * @return the XML overhead of the RespURI element.
141      */

142     public long getRespURIOverhead() {
143         return 150;
144     }
145
146     // ---------------------------------------------------------------- SyncBody
147
/**
148      * Returns the XML overhead for SyncBody object
149      * sizeof(<SyncBody>\n</SyncBody>\n)
150      *
151      * @return overhead for SyncBody object
152      */

153     public long getSyncBodyOverhead() {
154         return 23;
155     }
156
157     /**
158      * Returns the XML size of the SyncBody object
159      *
160      * sizeof(<SyncBody>\n) +
161      * for (i=0; i<commands.size(); i++)
162      * sizeof(commands[i]) +
163      * if final
164      * sizeof(<Final></Final>\n) +
165      * sizeof(</SyncBody>\n) +
166      * @param syncBody the SyncBody element
167      *
168      * @return size the XML size of the SyncBody element
169      */

170     public long getSize(SyncBody syncBody) {
171         ArrayList JavaDoc commands = syncBody.getCommands();
172
173         long size = 23
174                   + ((syncBody.isFinalMsg()) ? 16 : 0)
175                   ;
176
177         for (int i=0; i<commands.size(); i++) {
178             size += getCommandSize((AbstractCommand)commands.get(i));
179         }
180         return size;
181     }
182
183     // ------------------------------------------------------------------ VerDTD
184
/**
185      * Returns the XML size of VerDTD object:
186      * sizeof(<VerDTD>) +
187      * sizeof(value) +
188      * sizeof(</VerDTD>\n)
189      *
190      * @return the XML size of VerDTD object
191      */

192     public long getSize(VerDTD verDTD) {
193         return 18
194              + verDTD.getValue().length()
195              ;
196     }
197
198     // ---------------------------------------------------------------- VerProto
199
/**
200      * Returns the XML size of VerProto object:
201      * sizeof("<VerProto>") +
202      * sizeof(version) +
203      * sizeof("</VerProto>\n")
204      *
205      * @return the XML size of this object
206      */

207     public long getSize(VerProto verProto) {
208         return 22
209              + verProto.getVersion().length()
210              ;
211     }
212
213     // --------------------------------------------------------------- SessionID
214
/**
215      * Returns the XML size of SessionID element as:
216      * sizeof("<SessionID>") +
217      * sizeof(sessionID) +
218      * sizeof("</SessionID>\n")
219      *
220      * @return the XML size of this element
221      */

222     public long getSize(SessionID sessionID) {
223         return 24
224              + sessionID.getSessionID().length()
225              ;
226     }
227
228     // ------------------------------------------------------------------ Target
229
/**
230      * Returns the XML size of Target element:
231      * sizeof(<Target>\n) +
232      * if locURI != null
233      * sizeof(<LocURI>) +
234      * sizeof(locURI) +
235      * sizeof(</LocURI>\n) +
236      * if locName != null
237      * sizeof(<LocName>) +
238      * sizeof(locName) +
239      * sizeof(</LocName>\n) +
240      * sizeof(</Target>\n)
241      *
242      * @return the XML size of this element
243      */

244     public long getSize(Target target) {
245         String JavaDoc locURI = target.getLocURI() ;
246         String JavaDoc locName = target.getLocName();
247
248         return 19
249              + ((locURI != null) ? (18 + locURI.length() ) : 0)
250              + ((locName != null) ? (20 + locName.length()) : 0)
251              ;
252     }
253     // ------------------------------------------------------------------ Source
254
/**
255      * Returns the XML size of Source element:
256      * sizeof(<Source>\n) +
257      * if locURI != null
258      * sizeof(<LocURI>) +
259      * sizeof(locURI) +
260      * sizeof(</LocURI>\n) +
261      * if locName != null
262      * sizeof(<LocName>) +
263      * sizeof(locName) +
264      * sizeof(</LocName>\n) +
265      * sizeof(</Source>\n)
266      *
267      * @return the XML size of this element
268      */

269     public long getSize(Source source) {
270         String JavaDoc locURI = source.getLocURI() ;
271         String JavaDoc locName = source.getLocName();
272
273         return 19
274              + ((locURI != null) ? (18 + locURI.length() ) : 0)
275              + ((locName != null) ? (20 + locName.length()) : 0)
276              ;
277     }
278     // -------------------------------------------------------------------- Cred
279
/**
280      * Returns the XML size of Cred element as:
281      * sizeof(<Cred>\n) +
282      * if meta != null
283      * sizeof(meta) +
284      * if data != null
285      * sizeof(<Data>) +
286      * sizeof(data) +
287      * sizeof(</Data>\n) +
288      * sizeof(</Cred>\n)
289      *
290      * @return the XML size of this element
291      */

292     public long getSize(Cred cred) {
293         Authentication auth = cred.getAuthentication();
294         Meta meta = auth.getMeta();
295         String JavaDoc data = cred.getData();
296
297         return 15
298              + ((meta != null) ? getSize(meta) : 0)
299              + ((data != null) ? 14 + data.length() : 0)
300              ;
301     }
302
303     // -------------------------------------------------------------------- Meta
304
/**
305      * Returns the XML size of Meta object.
306      * sizeof(<Meta>\n) +
307      * if format != null
308      * sizeof(<Format>) +
309      * sizeof(format) +
310      * sizeof(</Format>\n) +
311      * if type != null
312      * sizeof(<Type>) +
313      * sizeof(type) +
314      * sizeof(</Type>\n) +
315      * if mark != null
316      * sizeof(mark) +
317      * if size != null
318      * sizeof(<Size>) +
319      * sizeof(size) +
320      * sizeof(</Size>\n) +
321      * if anchor != null
322      * sizeof(anchor) +
323      * if version != null
324      * sizeof(<Version>) +
325      * sizeof(version) +
326      * sizeof(</Version>\n) +
327      * if nextNonce != null
328      * sizeof(nextNonce) +
329      * if maxMsgSize != null
330      * sizeof(<MaxMsgSize>) +
331      * sizeof(maxMsgSize) +
332      * sizeof(</MaxMsgSize>\n) +
333      * if maxObjSize != null
334      * sizeof(<MaxObjSize>) +
335      * sizeof(maxObjSize) +
336      * sizeof(</MaxObjSize>\n) +
337      * for (i=0; emi != null && i<emi.size(); i++)
338      * sizeof(emi[i] +
339      * if mem != null
340      * sizeof(mem) +
341      * sizeof(</Meta>\n)
342      * @return the XML size of Meta object
343      */

344     public long getSize(Meta meta) {
345         long sizeMeta = 0;
346
347         String JavaDoc format = meta.getFormat() ;
348         String JavaDoc type = meta.getType() ;
349         String JavaDoc mark = meta.getMark() ;
350         Long JavaDoc size = meta.getSize() ;
351         Anchor anchor = meta.getAnchor() ;
352         String JavaDoc version = meta.getVersion() ;
353         NextNonce nextNonce = meta.getNextNonce() ;
354         Long JavaDoc maxMsgSize = meta.getMaxMsgSize();
355         Long JavaDoc maxObjSize = meta.getMaxObjSize();
356         ArrayList JavaDoc emi = meta.getEMI() ;
357         Mem mem = meta.getMem() ;
358
359         sizeMeta = 37
360                  + ((format != null) ? 18 + format.length() : 0)
361                  + ((type != null) ? 14 + type.length() : 0)
362                  + ((mark != null) ? 14 + mark.length() : 0)
363                  + ((size != null) ? 14 + String.valueOf(size).length(): 0)
364                  + ((anchor != null) ? getSize(anchor) : 0)
365                  + ((version != null) ? 20 + version.length() : 0)
366                  + ((nextNonce != null) ? getSize(nextNonce) : 0)
367                  + ((maxMsgSize!= null) ? 26 + String.valueOf(maxMsgSize).length() : 0)
368                  + ((maxObjSize!= null) ? 26 + String.valueOf(maxObjSize).length() : 0)
369                  + ((mem != null) ? getSize(mem) : 0)
370                  ;
371
372     for (int i=0; emi != null && i < emi.size(); i++) {
373             sizeMeta += getSize((EMI)emi.get(i));
374         }
375
376        return sizeMeta;
377     }
378
379
380
381     // ------------------------------------------------------------------ Anchor
382
/**
383      * Returns the XML size of Anchor element as:
384      * sizeof(<Anchor xmlns='syncml:metinf'>\n) +
385      * if last != null
386      * sizeof(<Last>) +
387      * sizeof(last) +
388      * sizeof(</Last>\n) +
389      * if next != null
390      * sizeof(<Next>) +
391      * sizeof(next) +
392      * sizeof(</Next>\n) +
393      * sizeof(</Anchor>\n) +
394      *
395      * @return the XML size of this element
396      */

397     public long getSize(Anchor anchor) {
398         String JavaDoc last = anchor.getLast();
399         String JavaDoc next = anchor.getNext();
400
401         return 41
402              + ((last != null) ? 14 + last.length() : 0)
403              + ((next != null) ? 14 + next.length() : 0)
404              ;
405     }
406
407     // --------------------------------------------------------------------- EMI
408
/**
409      * Returns the XML size of EMI element as:
410      * sizeof(<EMI>) +
411      * sizeof(value) +
412      * sizeof(</EMI>\n)
413      *
414      * @return the XML size of this element
415      */

416     public long getSize(EMI emi) {
417         return 12
418              + emi.getValue().length()
419              ;
420     }
421
422     // --------------------------------------------------------------- NextNonce
423
/**
424      * Returns the XML size of NextNonce element as:
425      * sizeof(<NextNonce>) +
426      * sizeof(value) +
427      * sizeof(</NextNonce>\n)
428      *
429      * @return the XML size of NextNonce element
430      */

431     public long getSize(NextNonce nextNonce) {
432         return 24
433              + nextNonce.getValueAsBase64().length()
434              ;
435     }
436
437     // --------------------------------------------------------------------- Mem
438
/**
439      * Returns the XML size of Mem element as:
440      * sizeof("<Mem>\n") +
441      * if sharedMem
442      * sizeof("<Shared></Shared>\n") +
443      * if freeMem
444      * sizeof("<FreeMem>") +
445      * sizeof(freeMem) +
446      * sizeof("</FreeMem>\n") +
447      * if freeID
448      * sizeof("<FreeID>") +
449      * sizeof(freeID) +
450      * sizeof("</FreeID>\n") +
451      * sizeof("</Mem>\n")
452      *
453      * @return the XML size of Mem element
454      */

455     public long getSize(Mem mem) {
456         boolean sharedMem = mem.isSharedMem();
457         long freeMem = mem.getFreeMem() ;
458         long freeID = mem.getFreeID() ;
459
460         return 13
461              + ((sharedMem) ? 18 : 0)
462              + ((freeMem != 0) ? 20 + String.valueOf(freeMem).length() : 0)
463              + ((freeID != 0) ? 18 + String.valueOf(freeID).length() : 0)
464              ;
465     }
466
467     // --------------------------------------------------------- AbstractCommand
468
/**
469      * Gets the XML size of all element of AbstractCommand
470      * if cmdID != null
471      * sizeof(cmdID) +
472      * if noResp
473      * sizeof(<NoResp></NoResp>\n) +
474      * if cred != null
475      * sizeof(cred) +
476      * @return the XML size of all element of AbstractCommand
477      */

478     public long getSize(AbstractCommand command) {
479         CmdID cmdID = command.getCmdID();
480         Cred cred = command.getCred() ;
481
482         return ((cmdID != null) ? getSize(cmdID) : 0)
483              + ((command.isNoResp()) ? 18 : 0)
484              + ((cred != null) ? getSize(cred) : 0)
485              ;
486     }
487
488     /**
489      * Gets the XML size of the command
490      *
491      * @return the XML size of the command
492      */

493     public long getCommandSize(AbstractCommand command) {
494         long size = 0;
495         if (command instanceof Add) {
496             size = getSize((Add)command);
497         } else if (command instanceof Alert) {
498             size = getSize((Alert)command);
499         } else if (command instanceof Atomic) {
500             size = getSize((Atomic)command);
501         } else if (command instanceof Copy) {
502             size = getSize((Copy)command);
503         } else if (command instanceof Delete) {
504             size = getSize((Delete)command);
505         } else if (command instanceof Exec) {
506             size = getSize((Exec)command);
507         } else if (command instanceof Get) {
508             size = getSize((Get)command);
509         } else if (command instanceof Map) {
510             size = getSize((Map)command);
511         } else if (command instanceof Put) {
512             size = getSize((Put)command);
513         } else if (command instanceof Replace) {
514             size = getSize((Replace)command);
515         } else if (command instanceof Results) {
516             size = getSize((Results)command);
517         } else if (command instanceof Search) {
518             size = getSize((Search)command);
519         } else if (command instanceof Sequence) {
520             size = getSize((Sequence)command);
521         } else if (command instanceof Status) {
522             size = getSize((Status)command);
523         } else if (command instanceof Sync) {
524             size = getSize((Sync)command);
525         }
526
527         return size;
528     }
529
530     // ------------------------------------------------------------------- CmdID
531
/**
532      * Returns the XML size of CmdID element as:
533      * sizeof(<CmdID>) +
534      * sizeof(cmdID) +
535      * sizeof(</CmdID>\n)
536      *
537      * @return the XML size of CmdID element
538      */

539     public long getSize(CmdID cmdID) {
540         return 16
541              + cmdID.getCmdID().length();
542     }
543
544     // --------------------------------------------------------------------- Add
545
/**
546      * Returns the XML size of Add element as:
547      * sizeof(<Add>\n) +
548      * if cmdID != null
549      * sizeof(cmdID) +
550      * if noResp
551      * sizeof(<NoResp></NoResp>\n) +
552      * if cred != null
553      * sizeof(cred) +
554      * if meta != null
555      * sizeof(meta) +
556      * for (int i=0; items != null && i<items.size(); i++)
557      * sizeof(items[i]) +
558      * sizeof(</Add>\n)
559      *
560      * @return the XML size of Add element
561      */

562     public long getSize(Add add) {
563         Meta meta = add.getMeta() ;
564         ArrayList JavaDoc items = add.getItems();
565
566         long size = 13
567                   + getSize((AbstractCommand)add)
568                   + ((meta != null) ? getSize(meta) : 0)
569                   ;
570         for (int i=0; items != null && i<items.size(); i++) {
571             size += getSize((Item)items.get(i));
572         }
573         return size;
574     }
575
576     // -------------------------------------------------------------------- Item
577
/**
578      * Returns the XML size of Item element as:
579      * sizeof(<Item>\n) +
580      * if target != null
581      * sizeof(target) +
582      * if source != null
583      * sizeof(source) +
584      * if meta != null
585      * sizeof(meta) +
586      * if data != null
587      * sizeof(data) +
588      * if moreData
589      * sizeof(<MoreData></MoreData>\n) +
590      * sizeof(</Item>\n)
591      *
592      * @return the XML size of Item element
593      */

594     public long getSize(Item item) {
595         Target target = item.getTarget();
596         Source source = item.getSource();
597         Meta meta = item.getMeta() ;
598         ComplexData data = item.getData() ;
599
600         return 15
601              + ((target != null) ? getSize(target) : 0)
602              + ((source != null) ? getSize(source) : 0)
603              + ((meta != null) ? getSize(meta) : 0)
604              + ((data != null) ? getSize(data) : 0)
605              + ((item.isMoreData()) ? 22 : 0)
606              ;
607     }
608
609     // ------------------------------------------------------------- ComplexData
610
/**
611      * Returns the XML size of ComplexData element as:
612      * sizeof(<Data>\n) +
613      * if data != null
614      * sizeof(data) +
615      * if anchor != null
616      * sizeof(anchor) +
617      * if devinf != null
618      * sizeof(devinf) +
619      * sizeof(</Data>\n)
620      * @return the XML size of ComplexData element
621      */

622     public long getSize(ComplexData complexData) {
623         String JavaDoc data = complexData.getData() ;
624         Anchor anchor = complexData.getAnchor();
625         DevInf devInf = complexData.getDevInf();
626
627         return 15
628              + ((data != null) ? data.length() :0)
629              + ((anchor != null) ? getSize(anchor) :0)
630              + ((devInf != null) ? getSize(devInf) :0)
631              ;
632     }
633
634     // -------------------------------------------------------------------- Data
635
/**
636      * Returns the XML size of Data element as:
637      * sizeof(<Data>) +
638      * sizeof(data) +
639      * sizeof(</Data>\n)
640      *
641      * @return the XML size of Data element
642      */

643     public long getSize(Data data) {
644         return 14
645              + data.getData().length();
646     }
647
648     // -------------------------------------------------------------- DevInfData
649
/**
650      * Returns the XML size of DevInfData element as:
651      * sizeof(<Data>\n) +
652      * id devInf != null
653      * sizeof(devInf) +
654      * sizeof(</Data>\n)
655      *
656      * @return the XML size of DevInfData element
657      */

658     public long getSize(DevInfData devInfData) {
659         DevInf devInf = devInfData.getDevInf();
660         return 15
661              + ((devInf != null) ? getSize(devInf) : 0)
662              ;
663     }
664
665     // ------------------------------------------------------------------ DevInf
666
/**
667      * Returns the XML size of DevInf element as:
668      * sizeof(<DevInf xmlns='syncml:devinf'>\n) +
669      * if verDTD != null
670      * sizeof(verDTD) +
671      * if man != null
672      * sizeof(<Man>) +
673      * sizeof(man) +
674      * sizeof(</Man>\n) +
675      * if mod != null
676      * sizeof(<Mod>) +
677      * sizeof(mod) +
678      * sizeof(</Mod>\n) +
679      * if oem != null
680      * sizeof(<OEM>) +
681      * sizeof(oem) +
682      * sizeof(</OEM>\n) +
683      * if fwV != null
684      * sizeof(<FwV>) +
685      * sizeof(fwV) +
686      * sizeof(</FwV>\n) +
687      * if swV != null
688      * sizeof(<SwV>) +
689      * sizeof(swV) +
690      * sizeof(</SwV>\n) +
691      * if hwV != null
692      * sizeof(<HwV>) +
693      * sizeof(hwV) +
694      * sizeof(</HwV>\n) +
695      * if devID != null
696      * sizeof(<DevID>) +
697      * sizeof(devID) +
698      * sizeof(</DevID>\n) +
699      * if devTyp != null
700      * sizeof(<DevTyp>) +
701      * sizeof(devTyp) +
702      * sizeof(</DevTyp>\n) +
703      * if utc
704      * sizeof(<UTC></UTC>\n) +
705      * if supportLargeObjs
706      * sizeof(<SupportLargeObjs></SupportLargeObjs>\n) +
707      * if supportNumberOfChanges
708      * sizeof(<SupportNumberOfChanges></SupportNumberOfChanges>\n) +
709      * for (int i=0; datastores != null && i<datastores.size(); i++)
710      * sizeof(datastores[i]) +
711      * for (int i=0; ctCaps != null && i<ctCaps.size(); i++)
712      * sizeof(ctCaps[i]) +
713      * for (int i=0; exts != null && i<exts.size(); i++)
714      * sizeof(exts[i]) +
715      * sizeof(</DevInf>\n)
716      *
717      * @return the XML size of DevInf element
718      */

719     public long getSize(DevInf devInf) {
720         VerDTD verDTD = devInf.getVerDTD() ;
721         String JavaDoc man = devInf.getMan() ;
722         String JavaDoc mod = devInf.getMod() ;
723         String JavaDoc oem = devInf.getOEM() ;
724         String JavaDoc fwV = devInf.getFwV() ;
725         String JavaDoc swV = devInf.getSwV() ;
726         String JavaDoc hwV = devInf.getHwV() ;
727         String JavaDoc devID = devInf.getDevID() ;
728         String JavaDoc devTyp = devInf.getDevTyp() ;
729         ArrayList JavaDoc dataStores = devInf.getDataStore();
730         ArrayList JavaDoc ctCaps = devInf.getCTCap() ;
731         ArrayList JavaDoc exts = devInf.getExt() ;
732
733         long size = 0;
734
735         for (int i=0; dataStores != null && i<dataStores.size(); i++) {
736             size += getSize((DataStore)dataStores.get(i));
737         }
738         for (int i=0; ctCaps != null && i<ctCaps.size(); i++) {
739             size += getSize((CTCap)ctCaps.get(i));
740         }
741         for (int i=0; exts != null && i<exts.size(); i++) {
742             size += getSize((Ext)exts.get(i));
743         }
744
745         return 41
746              + ((verDTD != null) ? getSize(verDTD) : 0)
747              + ((man != null) ? 12 + man.length() : 0)
748              + ((mod != null) ? 12 + mod.length() : 0)
749              + ((oem != null) ? 12 + oem.length() : 0)
750              + ((fwV != null) ? 12 + fwV.length() : 0)
751              + ((swV != null) ? 12 + swV.length() : 0)
752              + ((hwV != null) ? 12 + hwV.length() : 0)
753              + ((devID != null) ? 16 + devID.length() : 0)
754              + ((devTyp != null) ? 18 + devTyp.length() : 0)
755              + ((devInf.isUTC()) ? 12 : 0)
756              + ((devInf.isSupportLargeObjs()) ? 38 : 0)
757              + ((devInf.isSupportNumberOfChanges()) ? 50 : 0)
758              + size;
759     }
760
761     // --------------------------------------------------------------- DataStore
762
/**
763      * Returns the XML size of DataStore element as:
764      * sizeof(<DataStore>\n) +
765      * if sourceRef != null
766      * sizeof(sourceRef) +
767      * if displayName != null && displayName.length() != 0
768      * sizeof(<DisplayName>) +
769      * sizeof(displayName) +
770      * sizeof(</DisplayName>\n) +
771      * if maxGUIDSize > 0
772      * sizeof(<MaxGUIDSize>) +
773      * sizeof(maxGUIDSize) +
774      * sizeof(</MaxGUIDSize>\n) +
775      * if rxPref != null
776      * sizeof(<Rx-Pref>\n) +
777      * sizeof(rxPref) +
778      * sizeof(</Rx-Pref>\n) +
779      * for (int i=0; rxs != null && i<rxs.size(); i++)
780      * sizeof(<Rx>\n) +
781      * sizeof(rxs[i]) +
782      * sizeof(</Rx>\n) +
783      * if txPref != null
784      * sizeof(<Tx-Pref>\n) +
785      * sizeof(txPref) +
786      * sizeof(</Tx-Pref>\n) +
787      * for (int i=0; txs != null && i<txs.size(); i++)
788      * sizeof(<Tx>\n) +
789      * sizeof(txs[i]) +
790      * sizeof(</Tx>\n) +
791      * if dsMem != null
792      * sizeof(dsMem) +
793      * if syncCap != null
794      * sizeof(syncCap) +
795      * sizeof(</DataStore>\n)
796      *
797      * @return the XML size of DataStore element
798      */

799     public long getSize(DataStore dataStore) {
800         SourceRef sourceRef = dataStore.getSourceRef() ;
801         String JavaDoc displayName = dataStore.getDisplayName();
802         long maxGUIDSize = dataStore.getMaxGUIDSize();
803         ContentTypeInfo rxPref = dataStore.getRxPref() ;
804         ArrayList JavaDoc rxs = dataStore.getRx() ;
805         ContentTypeInfo txPref = dataStore.getTxPref() ;
806         ArrayList JavaDoc txs = dataStore.getTx() ;
807         DSMem dsMem = dataStore.getDSMem() ;
808         SyncCap syncCap = dataStore.getSyncCap() ;
809
810         long size = 0;
811
812         for (int i=0; rxs != null && i<rxs.size(); i++) {
813             size += 11 + getSize((ContentTypeInfo)rxs.get(i));
814         }
815         for (int i=0; txs != null && i<txs.size(); i++) {
816             size += 11 + getSize((ContentTypeInfo)txs.get(i));
817         }
818
819         return 25
820              + ((sourceRef != null) ? getSize(sourceRef) : 0)
821              + ((displayName != null && displayName.length() != 0)
822                              ? 28 + displayName.length() : 0)
823              + ((maxGUIDSize > 0)
824                              ? 28 + String.valueOf(maxGUIDSize).length() : 0)
825              + ((rxPref != null) ? 21 + getSize(rxPref) : 0)
826              + ((txPref != null) ? 21 + getSize(txPref) : 0)
827              + ((dsMem != null) ? getSize(dsMem) : 0)
828              + ((syncCap != null) ? getSize(syncCap) : 0)
829              + size
830              ;
831     }
832
833     // --------------------------------------------------------- ContentTypeInfo
834
/**
835      * Returns the XML size of ContentTypeInfo element as:
836      * if ctType != null
837      * sizeof(<CTType>) +
838      * sizeof(ctType) +
839      * sizeof(</CTType>\n) +
840      * if verCT != null
841      * sizeof(<VerCT>) +
842      * sizeof(verCT) +
843      * sizeof(</VerCT>\n) +
844      *
845      * @return the XML size of ContentTypeInfo element
846      */

847     public long getSize(ContentTypeInfo contentTypeInfo) {
848         String JavaDoc ctType = contentTypeInfo.getCTType();
849         String JavaDoc verCT = contentTypeInfo.getVerCT() ;
850
851         return ((ctType != null) ? 18 + ctType.length() : 0)
852              + ((verCT != null) ? 16 + verCT.length() : 0)
853              ;
854     }
855
856     // --------------------------------------------------------------- SourceRef
857
/**
858      * Returns the XML size of SourceRef element as:
859      * sizeof(<SourceRef>) +
860      * if value != null
861      * sizeof(value) +
862      * if source != null
863      * sizeof(source) +
864      * sizeof(</SourceRef>\n)
865      *
866      * @return the XML size of SourceRef element
867      */

868     public long getSize(SourceRef sourceRef) {
869         String JavaDoc value = sourceRef.getValue() ;
870         Source source = sourceRef.getSource();
871
872         return 24
873              + ((value != null) ? value.length() : 0)
874              + ((source != null) ? getSize(source) : 0)
875              ;
876     }
877
878     // ------------------------------------------------------------------- DSMem
879
/**
880      * Returns the XML size of DSMem element as:
881      * sizeof(<DSMem>\n) +
882      * if sharedMem
883      * sizeof(<SharedMem></SharedMem>\n) +
884      * if maxMem >= 0
885      * sizeof(<MaxMem>) +
886      * sizeof(maxMem) +
887      * sizeof(</<MaxMem>\n) +
888      * if maxID >= 0
889      * sizeof(<MaxID>) +
890      * sizeof(maxID) +
891      * sizeof(</MaxID>\n) +
892      * sizeof(</DSMem>\n)
893      *
894      * @return the XML size of DSMem element
895      */

896     public long getSize(DSMem dsMem) {
897         long maxMem = dsMem.getMaxMem();
898         long maxID = dsMem.getMaxID() ;
899
900         return 17
901              + ((dsMem.isSharedMem()) ? 24 :0)
902              + ((maxMem>=0) ? 18 + String.valueOf(maxMem).length() :0)
903              + ((maxID >=0) ? 16 + String.valueOf(maxID).length() :0)
904              ;
905     }
906
907     // ----------------------------------------------------------------- SyncCap
908
/**
909      * Returns the XML size of SyncCap element as:
910      * sizeof(<SyncCap>\n) +
911      * for (i=0; syncTypes != null && i < syncTypes.size(); i++)
912      * sizeof(syncTypes[i]) +
913      * sizeof(</SyncCap>\n)
914      *
915      * @return the XML size of SyncCap element
916      */

917     public long getSize(SyncCap syncCap) {
918         ArrayList JavaDoc syncTypes = syncCap.getSyncType();
919         long size = 21;
920
921         for (int i=0; i<syncTypes.size(); ++i) {
922             size += getSize((SyncType)syncTypes.get(i));
923         }
924         return size;
925     }
926
927     // ---------------------------------------------------------------- SyncType
928
/**
929      * Returns the XML size of SyncType element as:
930      * sizeof(<SyncType>) +
931      * sizeof(syncType) +
932      * sizeof(</SyncType>\n)
933      *
934      * @return the XML size of SyncType element
935      */

936     public long getSize(SyncType syncType) {
937         return 22
938              + String.valueOf(syncType.getType()).length()
939              ;
940     }
941
942     // ------------------------------------------------------------------- CTCap
943
/**
944      * Returns the XML size of CTCap element as:
945      * sizeof(<CTCap>\n) +
946      * for (int i=0; ctTypeSupported != null && i<ctTypeSupported.size(); i++)
947      * sizeof(ctTypeSupported.get(i)) +
948      * sizeof(</CTCap>\n)
949      *
950      * @return the XML size of CTCap element
951      */

952     public long getSize(CTCap ctCap) {
953         ArrayList JavaDoc ctTypeSup = ctCap.getCTTypeSupported();
954         long size = 17;
955
956         for (int i=0; ctTypeSup != null && i<ctTypeSup.size(); i++) {
957             size += getSize((CTTypeSupported)ctTypeSup.get(i));
958         }
959         return size;
960     }
961
962     // --------------------------------------------------------- CTTypeSupported
963
/**
964      * Returns the XML size of CTTypeSupported element as:
965      * if ctType != null
966      * sizeof(ctType) +
967      * for (int i=0; ctPropParams != null && i<ctPropParams.size(); i++)
968      * sizeof(ctPropParam.get(i))
969      *
970      * @return the XML size of CTTypeSupported element
971      */

972     public long getSize(CTTypeSupported ctTypeSupported) {
973         String JavaDoc ctType = ctTypeSupported.getCTType() ;
974         ArrayList JavaDoc ctPropParams = ctTypeSupported.getCTPropParams();
975         long size = 0;
976
977         for (int i=0; ctPropParams != null && i<ctPropParams.size(); i++) {
978             size += getSize((CTPropParam)ctPropParams.get(i));
979         }
980         return ((ctType != null) ? 18 + ctType.length() : 0)
981              + size
982              ;
983     }
984
985
986     // ------------------------------------------------------------- CTPropParam
987
/**
988      * Returns the XML size of CTPropParam element as:
989      * sizeof(<PropName>) +
990      * sizeof(propName) +
991      * sizeof(</PropName>\n) +
992      * for (int i=0; valEnums != null && i<valEnums.size(); i++)
993      * sizeof(<ValEnum>) +
994      * sizeof(valEnums.get(i)) +
995      * sizeof(</ValEnum>\n) +
996      * if dataType != null
997      * sizeof(<DataType>) +
998      * sizeof(dataType) +
999      * sizeof(</DataType>\n) +
1000     * if size != 0
1001     * sizeof(<Size>) +
1002     * sizeof(size) +
1003     * sizeof(</Size>\n) +
1004     * if displayName != null
1005     * sizeof(<DisplayName>) +
1006     * sizeof(displayName) +
1007     * sizeof(</DisplayName>\n) +
1008     * for (int i=0; ctParameters != null && i<ctParameters.size(); i++)
1009     * sizeof(ctParameters.get(i))
1010     * @return the XML size of CTPropParam element
1011     */

1012    public long getSize(CTPropParam ctPropParam) {
1013        String JavaDoc propName = ctPropParam.getPropName() ;
1014        ArrayList JavaDoc valEnums = ctPropParam.getValEnum() ;
1015        String JavaDoc dataType = ctPropParam.getDataType() ;
1016        int size = ctPropParam.getSize() ;
1017        String JavaDoc displayName = ctPropParam.getDisplayName() ;
1018        ArrayList JavaDoc ctParameters = ctPropParam.getContentTypeParameters();
1019
1020        long sizeCTPP = 0;
1021        for (int i=0; valEnums != null && i<valEnums.size(); i++) {
1022            sizeCTPP += 20 + ((String JavaDoc)valEnums.get(i)).length();
1023        }
1024
1025        for (int i=0; ctParameters!=null && i<ctParameters.size(); i++) {
1026            sizeCTPP += getSize((ContentTypeParameter)ctParameters.get(i));
1027        }
1028
1029        return ((propName != null) ? 22 + propName.length() : 0)
1030             + ((dataType != null) ? 22 + dataType.length() : 0)
1031             + ((size != 0 ) ? 14 + String.valueOf(size).length() : 0)
1032             + ((displayName != null) ? 28 + displayName.length() : 0)
1033             + sizeCTPP
1034             ;
1035    }
1036
1037    // ---------------------------------------------------- ContentTypeParameter
1038
/**
1039     * Returns the XML size of ContentTypeParameter element as:
1040     * sizeof(<ParamName>) +
1041     * sizeof(paramName) +
1042     * sizeof(</ParamName>\n) +
1043     * for (int i=0; valEnums != null && i<valEnums.size(); i++)
1044     * sizeof(<ValEnum>) +
1045     * sizeof(valEnum.get(i)) +
1046     * sizeof(</ValEnum>\n) +
1047     * if dataType != null
1048     * sizeof(<DataType>) +
1049     * sizeof(dataType) +
1050     * sizeof(</DataType>\n) +
1051     * if size != 0
1052     * sizeof(<Size>) +
1053     * sizeof(size) +
1054     * sizeof(</Size>\n) +
1055     * if displayName != null
1056     * sizeof(<DisplayName>) +
1057     * sizeof(displayName) +
1058     * sizeof(</DisplayName>\n) +
1059     *
1060     * @return the XML size of CTPropParam element
1061     */

1062    public long getSize(ContentTypeParameter ctParameter) {
1063        String JavaDoc paramName = ctParameter.getParamName() ;
1064        ArrayList JavaDoc valEnums = ctParameter.getValEnum() ;
1065        String JavaDoc dataType = ctParameter.getDataType() ;
1066        int size = ctParameter.getSize() ;
1067        String JavaDoc displayName = ctParameter.getDisplayName();
1068        long sizeCTP = 0;
1069
1070        for (int i=0; valEnums != null && i<valEnums.size(); i++) {
1071            sizeCTP += 20 + ((String JavaDoc)valEnums.get(i)).length();
1072        }
1073
1074        return ((paramName != null) ? 24 + paramName.length() : 0)
1075             + ((dataType != null) ? 22 + dataType.length() : 0)
1076             + ((size != 0 ) ? 14 + String.valueOf(size).length() : 0)
1077             + ((displayName != null) ? 28 + displayName.length() : 0)
1078             + sizeCTP
1079             ;
1080    }
1081
1082    // --------------------------------------------------------------------- Ext
1083
/**
1084     * Returns the XML size of Ext element as:
1085     * sizeof(<Ext>\n) +
1086     * if name != null
1087     * sizeof(<XNam>) +
1088     * sizeof(name) +
1089     * sizeof(</XNam>\n) +
1090     * for (int i=0; values != null && i<values.size(); i++)
1091     * sizeof(<XVal>) +
1092     * sizeof(values[i]) +
1093     * sizeof(</XVal>\n) +
1094     * sizeof(</Ext>\n)
1095     *
1096     * @return the XML size of Ext element
1097     */

1098    public long getSize(Ext ext) {
1099        String JavaDoc name = ext.getXNam();
1100        ArrayList JavaDoc values = ext.getXVal();
1101        long size = 13;
1102
1103        for (int i=0; values != null && i<values.size(); i++) {
1104            size += 14 + ((String JavaDoc)values.get(i)).length();
1105        }
1106
1107        return ((name != null) ? 14 + name.length() : 0)
1108             + size
1109             ;
1110    }
1111    // ------------------------------------------------------------------- Alert
1112
/**
1113     * Returns the XML size of Alert element as:
1114     * sizeof(<Alert>\n) +
1115     * if cmdID != null
1116     * sizeof(cmdID) +
1117     * if noResp
1118     * sizeof(<NoResp></NoResp>\n) +
1119     * if cred != null
1120     * sizeof(cred) +
1121     * if data != null
1122     * sizeof(<Data>) +
1123     * sizeof(data) +
1124     * sizeof(</Data>\n) +
1125     * for (int i=0; items != null && i<items.size(); i++)
1126     * sizeof(items[i]) +
1127     * sizeof(</Alert>\n)
1128     *
1129     * @return the XML size of Alert element
1130     */

1131    public long getSize(Alert alert) {
1132        int data = alert.getData() ;
1133        ArrayList JavaDoc items = alert.getItems();
1134
1135        long size = 17
1136                  + getSize((AbstractCommand)alert)
1137                  + ((data != 0) ? 14 + String.valueOf(data).length() : 0)
1138                  ;
1139        for (int i=0; items != null && i<items.size(); i++) {
1140            size += getSize((Item)items.get(i));
1141        }
1142        return size;
1143    }
1144
1145    // ------------------------------------------------------------------ Atomic
1146
/**
1147     * Returns the XML size of Atomic element as:
1148     * sizeof(<Atomic>\n) +
1149     * if cmdID != null
1150     * sizeof(cmdID) +
1151     * if noResp
1152     * sizeof(<NoResp></NoResp>\n) +
1153     * if cred != null
1154     * sizeof(cred) +
1155     * if meta != null
1156     * sizeof(meta) +
1157     * for (int i=0; commands != null && i<commands.size(); i++)
1158     * sizeof(commands[i]) +
1159     * sizeof(</Atomic>\n)
1160     *
1161     * @return the XML size of Atomic element
1162     */

1163    public long getSize(Atomic atomic) {
1164        Meta meta = atomic.getMeta() ;
1165        ArrayList JavaDoc commands = atomic.getCommands();
1166
1167        long size = 19
1168                  + getSize((AbstractCommand)atomic)
1169                  + ((meta != null) ? getSize(meta) : 0)
1170                  ;
1171        for (int i=0; commands != null && i<commands.size(); i++) {
1172            size += getCommandSize((AbstractCommand)commands.get(i));
1173        }
1174        return size;
1175    }
1176
1177    // -------------------------------------------------------------------- Copy
1178
/**
1179     * Returns the XML size of Copy element as:
1180     * sizeof(<Copy>\n) +
1181     * if cmdID != null
1182     * sizeof(cmdID) +
1183     * if noResp
1184     * sizeof(<NoResp></NoResp>\n) +
1185     * if cred != null
1186     * sizeof(cred) +
1187     * if meta != null
1188     * sizeof(meta) +
1189     * for (int i=0; items != null && i<items.size(); i++)
1190     * sizeof(items[i]) +
1191     * sizeof(</Copy>\n)
1192     *
1193     * @return the XML size of Copy element
1194     */

1195    public long getSize(Copy copy) {
1196        Meta meta = copy.getMeta() ;
1197        ArrayList JavaDoc items = copy.getItems();
1198
1199        long size = 13
1200                  + getSize((AbstractCommand)copy)
1201                  + ((meta != null) ? getSize(meta) : 0)
1202                  ;
1203        for (int i=0; items != null && i<items.size(); i++) {
1204            size += getSize((Item)items.get(i));
1205        }
1206        return size;
1207    }
1208
1209    // ------------------------------------------------------------------ Delete
1210
/**
1211     * Returns the XML size of Delete element as:
1212     * sizeof(<Delete>\n) +
1213     * if cmdID != null
1214     * sizeof(cmdID) +
1215     * if noResp
1216     * sizeof(<NoResp></NoResp>\n) +
1217     * if cred != null
1218     * sizeof(cred) +
1219     * if archive
1220     * sizeof(<Archive></Archive>\n) +
1221     * if sftDel
1222     * sizeof(<SftDel></SftDel>\n) +
1223     * if meta != null
1224     * sizeof(meta) +
1225     * for (int i=0; items != null && i<items.size(); i++)
1226     * sizeof(items[i]) +
1227     * sizeof(</Delete>\n)
1228     *
1229     * @return the XML size of Delete element
1230     */

1231    public long getSize(Delete delete) {
1232        Meta meta = delete.getMeta() ;
1233        ArrayList JavaDoc items = delete.getItems();
1234
1235        long size = 20
1236                  + getSize((AbstractCommand)delete)
1237                  + ((delete.isArchive()) ? 20 : 0)
1238                  + ((delete.isSftDel() ) ? 18 : 0)
1239                  + ((meta != null ) ? getSize(meta) : 0)
1240                  ;
1241        for (int i=0; items != null && i<items.size(); i++) {
1242            size += getSize((Item)items.get(i));
1243        }
1244        return size;
1245    }
1246
1247    // -------------------------------------------------------------------- Exec
1248
/**
1249     * Returns the XML size of Exec element as:
1250     * sizeof(<Exec>\n) +
1251     * if cmdID != null
1252     * sizeof(cmdID) +
1253     * if noResp
1254     * sizeof(<NoResp></NoResp>\n) +
1255     * if cred != null
1256     * sizeof(cred) +
1257     * for (int i=0; items != null && i<items.size(); i++)
1258     * sizeof(items[i]) +
1259     * sizeof(</Exec>\n)
1260     *
1261     * @return the XML size of Delete element
1262     */

1263    public long getSize(Exec exec) {
1264        ArrayList JavaDoc items = exec.getItems();
1265
1266        long size = 14
1267                  + getSize((AbstractCommand)exec)
1268                  ;
1269        for (int i=0; items != null && i<items.size(); i++) {
1270            size += getSize((Item)items.get(i));
1271        }
1272        return size;
1273    }
1274
1275    // --------------------------------------------------------------------- Get
1276
/**
1277     * Returns the XML size of Get element as:
1278     * sizeof(<Get>\n) +
1279     * if cmdID != null
1280     * sizeof(cmdID) +
1281     * if noResp
1282     * sizeof(<NoResp></NoResp>\n) +
1283     * if cred != null
1284     * sizeof(cred) +
1285     * if lang != null
1286     * sizeof(<Lang>) +
1287     * sizeof(lang) +
1288     * sizeof(</Lang>\n) +
1289     * if meta != null
1290     * sizeof(meta) +
1291     * for (int i=0; items != null && i<items.size(); i++)
1292     * sizeof(items[i]) +
1293     * sizeof(</Get>\n)
1294     *
1295     * @return the XML size of Get element
1296     */

1297    public long getSize(Get get) {
1298        String JavaDoc lang = get.getLang();
1299        Meta meta = get.getMeta() ;
1300        ArrayList JavaDoc items = get.getItems();
1301
1302        long size = 13
1303                  + getSize((AbstractCommand)get)
1304                  + ((lang != null) ? 14 + lang.length() : 0)
1305                  + ((meta != null) ? getSize(meta) : 0)
1306                  ;
1307        for (int i=0; items != null && i<items.size(); i++) {
1308            size += getSize((Item)items.get(i));
1309        }
1310        return size;
1311    }
1312
1313    // --------------------------------------------------------------------- Map
1314
/**
1315     * Returns the XML size of Map element as:
1316     * sizeof(<Map>\n) +
1317     * if cmdID != null
1318     * sizeof(cmdID) +
1319     * if noResp
1320     * sizeof(<NoResp></NoResp>\n) +
1321     * if cred != null
1322     * sizeof(cred) +
1323     * if target != null
1324     * sizeof(target) +
1325     * if source != null
1326     * sizeof(source) +
1327     * if meta != null
1328     * sizeof(meta) +
1329     * for (int i=0; mapItems != null && i<mapItems.size(); i++)
1330     * sizeof(mapItems[i]) +
1331     * sizeof(</Map>\n)
1332     *
1333     * @return the XML size of Map element
1334     */

1335    public long getSize(Map map) {
1336        Target target = map.getTarget();
1337        Source source = map.getSource();
1338        Meta meta = map.getMeta() ;
1339        ArrayList JavaDoc mapItems = map.getMapItems();
1340
1341        long size = 13
1342                  + getSize((AbstractCommand)map)
1343                  + ((target != null) ? getSize(target) : 0)
1344                  + ((source != null) ? getSize(source) : 0)
1345                  + ((meta != null) ? getSize(meta) : 0)
1346                  ;
1347        for (int i=0; mapItems != null && i<mapItems.size(); i++) {
1348            size += getSize((MapItem)mapItems.get(i));
1349        }
1350        return size;
1351    }
1352
1353    // ----------------------------------------------------------------- MapItem
1354
/**
1355     * Returns the XML size of MapItem element as:
1356     * sizeof(<MapItem>\n) +
1357     * if target != null
1358     * sizeof(target) +
1359     * if source != null
1360     * sizeof(source) +
1361     * sizeof(</MapItem>\n)
1362     *
1363     * @return the XML size of MapItem element
1364     */

1365    public long getSize(MapItem mapItem) {
1366        Target target = mapItem.getTarget();
1367        Source source = mapItem.getSource();
1368
1369        return 21
1370             + ((target != null) ? getSize(target) : 0)
1371             + ((source != null) ? getSize(source) : 0)
1372             ;
1373    }
1374
1375    // --------------------------------------------------------------------- Put
1376
/**
1377     * Returns the XML size of Put element as:
1378     * sizeof(<Put>\n) +
1379     * if cmdID != null
1380     * sizeof(cmdID) +
1381     * if noResp
1382     * sizeof(<NoResp></NoResp>\n) +
1383     * if cred != null
1384     * sizeof(cred) +
1385     * if lang != null
1386     * sizeof(<Lang>) +
1387     * sizeof(lang) +
1388     * sizeof(</Lang>\n) +
1389     * if meta != null
1390     * sizeof(meta) +
1391     * for (int i=0; devInfItems != null && i<devInfItems.size(); i++)
1392     * sizeof(devInfItems[i]) +
1393     * sizeof(</Put>\n)
1394     *
1395     * @return the XML size of Put element
1396     */

1397    public long getSize(Put put) {
1398        String JavaDoc lang = put.getLang();
1399        Meta meta = put.getMeta() ;
1400        ArrayList JavaDoc devInfItems = put.getItems();
1401
1402        long size = 14
1403                  + getSize((AbstractCommand)put)
1404                  + ((lang != null) ? 14 + lang.length() : 0)
1405                  + ((meta != null) ? getSize(meta) : 0)
1406                  ;
1407        for (int i=0; devInfItems != null && i<devInfItems.size(); i++) {
1408            size += getSize((DevInfItem)devInfItems.get(i));
1409        }
1410        return size;
1411    }
1412
1413    // -------------------------------------------------------------- DevInfItem
1414
/**
1415     * Returns the XML size of Item element as:
1416     * sizeof(<Item>\n) +
1417     * if target != null
1418     * sizeof(target) +
1419     * if source != null
1420     * sizeof(source) +
1421     * if meta != null
1422     * sizeof(meta) +
1423     * if data != null
1424     * sizeof(data) +
1425     * sizeof(</Item>\n)
1426     *
1427     * @return the XML size of Item element
1428     */

1429    public long getSize(DevInfItem devInfItem) {
1430        Target target = devInfItem.getTarget() ;
1431        Source source = devInfItem.getSource() ;
1432        Meta meta = devInfItem.getMeta() ;
1433        DevInfData devInfData = devInfItem.getDevInfData();
1434
1435        return 15
1436             + ((target != null) ? getSize(target) : 0)
1437             + ((source != null) ? getSize(source) : 0)
1438             + ((meta != null) ? getSize(meta) : 0)
1439             + ((devInfData != null) ? getSize(devInfData) : 0)
1440             ;
1441    }
1442
1443    // ----------------------------------------------------------------- Replace
1444
/**
1445     * Returns the XML size of Replace element as:
1446     * sizeof(<Replace>\n) +
1447     * if cmdID != null
1448     * sizeof(cmdID) +
1449     * if noResp
1450     * sizeof(<NoResp></NoResp>\n) +
1451     * if cred != null
1452     * sizeof(cred) +
1453     * if meta != null
1454     * sizeof(meta) +
1455     * for (int i=0; items != null && i<items.size(); i++)
1456     * sizeof(items[i]) +
1457     * sizeof(</Replace>\n)
1458     *
1459     * @return the XML size of Replace element
1460     */

1461    public long getSize(Replace replace) {
1462        Meta meta = replace.getMeta() ;
1463        ArrayList JavaDoc items = replace.getItems();
1464
1465        long size = 21
1466                  + getSize((AbstractCommand)replace)
1467                  + ((meta != null) ? getSize(meta) : 0)
1468                  ;
1469        for (int i=0; items != null && i<items.size(); i++) {
1470            size += getSize((Item)items.get(i));
1471        }
1472        return size;
1473    }
1474
1475    // ----------------------------------------------------------------- Results
1476
/**
1477     * Returns the XML size of Results element as:
1478     * sizeof(<Results>\n) +
1479     * if cmdID != null
1480     * sizeof(cmdID) +
1481     * if noResp
1482     * sizeof(<NoResp></NoResp>\n) +
1483     * if cred != null
1484     * sizeof(cred) +
1485     * if msgRef != null
1486     * sizeof(<MsgRef>) +
1487     * sizeof(msgRef) +
1488     * sizeof(</MsgRef>\n) +
1489     * if cmdRef != null
1490     * sizeof(<CmdRef>) +
1491     * sizeof(cmdRef) +
1492     * sizeof(</CmdRef>\n) +
1493     * if meta != null
1494     * sizeof(meta) +
1495     * for (int i=0; targetRefs != null && i<targetRefs.size(); i++)
1496     * sizeof(targetRefs[i]) +
1497     * for (int i=0; sourceRefs != null && i<sourceRefs.size(); i++)
1498     * sizeof(sourceRefs[i]) +
1499     * for (int i=0; items != null && i<items.size(); i++)
1500     * sizeof(items[i]) +
1501     * sizeof(</Results>\n)
1502     *
1503     * @return the XML size of Results element
1504     */

1505    public long getSize(Results results) {
1506        String JavaDoc msgRef = results.getMsgRef() ;
1507        String JavaDoc cmdRef = results.getCmdRef() ;
1508        Meta meta = results.getMeta() ;
1509        ArrayList JavaDoc targetRefs = results.getTargetRef();
1510        ArrayList JavaDoc sourceRefs = results.getSourceRef();
1511        ArrayList JavaDoc items = results.getItems() ;
1512
1513        long size = 21
1514                  + getSize((AbstractCommand)results)
1515                  + ((msgRef != null) ? 18 + msgRef.length() : 0)
1516                  + ((cmdRef != null) ? 18 + cmdRef.length() : 0)
1517                  + ((meta != null) ? getSize(meta) : 0)
1518                  ;
1519        for (int i=0; targetRefs != null && i<targetRefs.size(); i++) {
1520            size += getSize((TargetRef)targetRefs.get(i));
1521        }
1522        for (int i=0; sourceRefs != null && i<sourceRefs.size(); i++) {
1523            size += getSize((SourceRef)sourceRefs.get(i));
1524        }
1525        for (int i=0; items != null && i<items.size(); i++) {
1526            size += getSize((Item)items.get(i));
1527        }
1528        return size;
1529    }
1530
1531    // --------------------------------------------------------------- TargetRef
1532
/**
1533     * Returns the XML size of TargetRef element as:
1534     * sizeof(<TargetRef>) +
1535     * if value != null
1536     * sizeof(value) +
1537     * if target != null
1538     * sizeof(targe) +
1539     * sizeof(</TargetRef>\n)
1540     *
1541     * @return the XML size of TargetRef element
1542     */

1543    public long getSize(TargetRef targetRef) {
1544        String JavaDoc value = targetRef.getValue() ;
1545        Target target = targetRef.getTarget();
1546
1547        return 24
1548             + ((value != null) ? value.length() : 0)
1549             + ((target != null) ? getSize(target) : 0)
1550             ;
1551    }
1552
1553    // ------------------------------------------------------------------ Search
1554
/**
1555     * Returns the XML size of Search element as:
1556     * sizeof(<Search>\n) +
1557     * if cmdID != null
1558     * sizeof(cmdID) +
1559     * if noResp
1560     * sizeof(<NoResp></NoResp>\n) +
1561     * if cred != null
1562     * sizeof(cred) +
1563     * if noResults
1564     * sizeof(<NoResults></NoResults>\n) +
1565     * if target != null
1566     * sizeof(target) +
1567     * for (int i=0; sources != null && i<sources.size(); i++)
1568     * sizeof(sources[i]) +
1569     * if lang != null
1570     * sizeof(<Lang>) +
1571     * sizeof(lang) +
1572     * sizeof(</Lang)\n) +
1573     * if meta != null
1574     * sizeof(meta) +
1575     * if data != null
1576     * sizeof(data) +
1577     * sizeof(</Search>\n)
1578     *
1579     * @return the XML size of Search element
1580     */

1581    public long getSize(Search search) {
1582        Target target = search.getTarget() ;
1583        ArrayList JavaDoc sources = search.getSources();
1584        String JavaDoc lang = search.getLang() ;
1585        Meta meta = search.getMeta() ;
1586        Data data = search.getData() ;
1587
1588        long size =
1589                  + getSize((AbstractCommand)search)
1590                  + ((search.isNoResults()) ? 24 : 0)
1591                  + ((target != null) ? getSize(target) : 0)
1592                  + ((lang != null) ? 14 + lang.length() : 0)
1593                  + ((meta != null) ? getSize(meta) : 0)
1594                  + ((data != null) ? getSize(data) : 0)
1595                  ;
1596        for (int i=0; sources != null && i<sources.size(); i++) {
1597            size += getSize((Source)sources.get(i));
1598        }
1599        return size;
1600    }
1601
1602    // ---------------------------------------------------------------- Sequence
1603
/**
1604     * Returns the XML size of Sequence element as:
1605     * sizeof(<Sequence>\n) +
1606     * if cmdID != null
1607     * sizeof(cmdID) +
1608     * if noResp
1609     * sizeof(<NoResp></NoResp>\n) +
1610     * if cred != null
1611     * sizeof(cred) +
1612     * if meta != null
1613     * sizeof(meta) +
1614     * for (int i=0; commands != null && i<commands.size(); i++)
1615     * sizeof(commands[i]) +
1616     * sizeof(</Sequence>\n)
1617     *
1618     * @return the XML size of Sequence element
1619     */

1620    public long getSize(Sequence sequence) {
1621        Meta meta = sequence.getMeta() ;
1622        ArrayList JavaDoc commands = sequence.getCommands();
1623
1624        long size = 23
1625                  + getSize((AbstractCommand)sequence)
1626                  + ((meta != null) ? getSize(meta) : 0)
1627                  ;
1628        for (int i=0; commands != null && i<commands.size(); i++) {
1629            size += getCommandSize((AbstractCommand)commands.get(i));
1630        }
1631        return size;
1632    }
1633
1634    // ------------------------------------------------------------------ Status
1635
/**
1636     * Returns the XML size of Status element as:
1637     * sizeof(<Status>\n) +
1638     * if cmdID != null
1639     * sizeof(cmdID) +
1640     * if msgRef != null
1641     * sizeof(<MsgRef>) +
1642     * sizeof(msgRef) +
1643     * sizeof(</MsgRef>\n) +
1644     * if cmdRef != null
1645     * sizeof(<CmdRef>) +
1646     * sizeof(cmdRef) +
1647     * sizeof(</CmdRef>\n) +
1648     * if cmd != null
1649     * sizeof(<Cmd) +
1650     * sizeof(cmd) +
1651     * sizeof(</Cmd>\n) +
1652     * for (int i=0; targetRefs != null && i<targetRefs.size(); i++)
1653     * sizeof(targetRefs[i]) +
1654     * for (int i=0; sourceRefs != null && i<sourceRefs.size(); i++)
1655     * sizeof(sourceRefs[i]) +
1656     * if cred != null
1657     * sizeof(cred) +
1658     * if chal != null
1659     * sizeof(chal) +
1660     * if data != null
1661     * sizeof(data) +
1662     * for (int i=0; items != null && i<items.size(); i++)
1663     * sizeof(items[i]) +
1664     * sizeof(</Status>\n)
1665     *
1666     * @return the XML size of Status element
1667     */

1668    public long getSize(Status status) {
1669        CmdID cmdID = status.getCmdID() ;
1670        String JavaDoc msgRef = status.getMsgRef() ;
1671        String JavaDoc cmdRef = status.getCmdRef() ;
1672        String JavaDoc cmd = status.getCmd() ;
1673        ArrayList JavaDoc targetRefs = status.getTargetRef();
1674        ArrayList JavaDoc sourceRefs = status.getSourceRef();
1675        Cred cred = status.getCred() ;
1676        Chal chal = status.getChal() ;
1677        Data data = status.getData() ;
1678        ArrayList JavaDoc items = status.getItems() ;
1679
1680        long size = 19
1681                  + ((cmdID != null) ? getSize(cmdID) : 0)
1682                  + ((msgRef != null) ? 18 + msgRef.length() : 0)
1683                  + ((cmdRef != null) ? 18 + cmdRef.length() : 0)
1684                  + ((cmd != null) ? 12 + cmd.length() : 0)
1685                  + ((cred != null) ? getSize(cred) : 0)
1686                  + ((chal != null) ? getSize(chal) : 0)
1687                  + ((data != null) ? getSize(data) : 0)
1688                  ;
1689        for (int i=0; targetRefs != null && i<targetRefs.size(); i++) {
1690            size += getSize((TargetRef)targetRefs.get(i));
1691        }
1692        for (int i=0; sourceRefs != null && i<sourceRefs.size(); i++) {
1693            size += getSize((SourceRef)sourceRefs.get(i));
1694        }
1695        for (int i=0; items != null && i<items.size(); i++) {
1696            size += getSize((Item)items.get(i));
1697        }
1698        return size;
1699    }
1700    // -------------------------------------------------------------------- Chal
1701
/**
1702     * Returns the XML size of Chal element as:
1703     * sizeof(<Chal>\n) +
1704     * if meta != null
1705     * sizeof(meta) +
1706     * sizeof</Chal>\n)
1707     *
1708     * @return the XML size of Chal element
1709     */

1710    public long getSize(Chal chal) {
1711        Meta meta = chal.getMeta();
1712
1713        return 15
1714             + ((meta != null) ? getSize(meta) : 0)
1715             ;
1716    }
1717
1718    // -------------------------------------------------------------------- Sync
1719
/**
1720     * Returns the XML size of Sync element as:
1721     * sizeof(<Sync>\n) +
1722     * if cmdID != null
1723     * sizeof(cmdID) +
1724     * if noResp
1725     * sizeof(<NoResp></NoResp>\n) +
1726     * if cred != null
1727     * sizeof(cred) +
1728     * if target != null
1729     * sizeof(target) +
1730     * if source != null
1731     * sizeof(source) +
1732     * if meta != null
1733     * sizeof(meta) +
1734     * if numberOfChanges != 0
1735     * sizeof(<NumberOfChanges>) +
1736     * sizeof(numberOfChanges) +
1737     * sizeof(</NumberOfChanges>\n) +
1738     * for (int i=0; commands != null && i<commands.size(); i++)
1739     * sizeof(commands[i]) +
1740     * sizeof(</Sync>\n)
1741     *
1742     * @return the XML size of Sync element
1743     */

1744    public long getSize(Sync sync) {
1745        Target target = sync.getTarget() ;
1746        Source source = sync.getSource() ;
1747        Meta meta = sync.getMeta() ;
1748        Long JavaDoc numberOfChanges = sync.getNumberOfChanges();
1749        ArrayList JavaDoc commands = sync.getCommands() ;
1750
1751        long size = 15
1752                  + getSize((AbstractCommand)sync)
1753                  + ((target != null) ? getSize(target) : 0)
1754                  + ((source != null) ? getSize(source) : 0)
1755                  + ((meta != null) ? getSize(meta) : 0)
1756                  + ((numberOfChanges != null) ? 36 : 0)
1757                  ;
1758        for (int i=0; commands != null && i<commands.size(); i++) {
1759            size += getCommandSize((AbstractCommand)commands.get(i));
1760        }
1761        return size;
1762    }
1763
1764    // --------------------------------------------------------- ItemizedCommand
1765
/**
1766     * Returns the XML size of the ItemizedCommand element
1767     */

1768    public long getSize(ItemizedCommand itemCmd) {
1769        Meta meta = itemCmd.getMeta() ;
1770        ArrayList JavaDoc items = itemCmd.getItems();
1771        long size = 0;
1772
1773        size = getSize((AbstractCommand)itemCmd)
1774             + ((meta != null) ? getSize(meta) : 0)
1775             ;
1776
1777        for (int i=0; items != null && i<items.size(); i++) {
1778            size += getSize((Item)items.get(i));
1779        }
1780        return size;
1781    }
1782
1783    // ----------------------------------------------------- ModificationCommand
1784
/**
1785     * Returns the XML size of ModificationCommand object.
1786     *
1787     * @return the XML size of ModificationCommand object
1788     */

1789    public long getSize(ModificationCommand modCmd) {
1790        return getSize((ItemizedCommand)modCmd);
1791    }
1792
1793    // --------------------------------------------------------- ResponseCommand
1794
/**
1795     * Returns the XML size of ResponseCommand object.
1796     *
1797     * @return the XML size of ResponseCommand object
1798     */

1799    public long getSize(ResponseCommand responseCmd) {
1800        String JavaDoc msgRef = responseCmd.getMsgRef() ;
1801        String JavaDoc cmdRef = responseCmd.getCmdRef() ;
1802        ArrayList JavaDoc targetRefs = responseCmd.getTargetRef();
1803        ArrayList JavaDoc sourceRefs = responseCmd.getSourceRef();
1804        long size = 0;
1805
1806        size = getSize((ItemizedCommand)responseCmd)
1807             + ((msgRef != null) ? 18 + msgRef.length() : 0)
1808             + ((cmdRef != null) ? 18 + cmdRef.length() : 0)
1809             ;
1810
1811        for (int i=0; targetRefs != null && i<targetRefs.size(); ++i) {
1812            size += getSize((TargetRef)targetRefs.get(i));
1813        }
1814        for (int i=0; sourceRefs != null && i<sourceRefs.size(); ++i) {
1815            size += getSize((SourceRef)sourceRefs.get(i));
1816        }
1817        return size;
1818    }
1819    
1820}
1821
Popular Tags