1 18 package sync4j.framework.tools; 19 20 import java.io.*; 21 import java.util.ArrayList ; 22 23 import sync4j.framework.core.*; 24 25 31 public class SizeCalculator { 32 33 35 42 public static long getXMLOverheadSyncML() { 43 return 43; 44 } 45 46 52 public static long getWBXMLOverheadSyncML() { 53 return 29; 54 } 55 56 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 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 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 msgID = syncHdr.getMsgID() ; 132 Target target = syncHdr.getTarget() ; 133 Source source = syncHdr.getSource() ; 134 String 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 160 public static long getWBXMLSize(SyncHdr syncHdr) { 161 VerDTD verDTD = syncHdr.getVerDTD() ; 162 VerProto verProto = syncHdr.getVerProto() ; 163 SessionID sessionID = syncHdr.getSessionID(); 164 String msgID = syncHdr.getMsgID() ; 165 Target target = syncHdr.getTarget() ; 166 Source source = syncHdr.getSource() ; 167 String 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 193 public static long getXMLOverheadSyncBody() { 194 return 23; 195 } 196 197 203 public static long getWBXMLOverheadSyncBody() { 204 return 4; 205 } 206 207 220 public static long getXMLSize(SyncBody syncBody) { 221 ArrayList 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 240 public static long getWBXMLSize(SyncBody syncBody) { 241 ArrayList 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 262 public static long getXMLSize(VerDTD verDTD) { 263 return 18 264 + verDTD.getValue().length() 265 ; 266 } 267 268 273 public static long getWBXMLSize(VerDTD verDTD) { 274 return 4 275 + verDTD.getValue().length() 276 ; 277 } 278 279 288 public static long getXMLSize(VerProto verProto) { 289 return 22 290 + verProto.getVersion().length() 291 ; 292 } 293 294 299 public static long getWBXMLSize(VerProto verProto) { 300 return 4 301 + verProto.getVersion().length() 302 ; 303 } 304 305 314 public static long getXMLSize(SessionID sessionID) { 315 return 24 316 + sessionID.getSessionID().length() 317 ; 318 } 319 320 325 public static long getWBXMLSize(SessionID sessionID) { 326 return 4 327 + sessionID.getSessionID().length() 328 ; 329 } 330 331 347 public static long getXMLSize(Target target) { 348 String locURI = target.getLocURI() ; 349 String locName = target.getLocName(); 350 351 return 19 352 + ((locURI != null) ? (18 + locURI.length() ) : 0) 353 + ((locName != null) ? (20 + locName.length()) : 0) 354 ; 355 } 356 360 public static long getWBXMLSize(Target target) { 361 String locURI = target.getLocURI() ; 362 String 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 386 public static long getXMLSize(Source source) { 387 String locURI = source.getLocURI() ; 388 String locName = source.getLocName(); 389 390 return 19 391 + ((locURI != null) ? (18 + locURI.length() ) : 0) 392 + ((locName != null) ? (20 + locName.length()) : 0) 393 ; 394 } 395 399 public static long getWBXMLSize(Source source) { 400 String locURI = source.getLocURI() ; 401 String 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 423 public static long getXMLSize(Cred cred) { 424 Authentication auth = cred.getAuthentication(); 425 Meta meta = auth.getMeta(); 426 String data = cred.getData(); 427 428 return 15 429 + ((meta != null) ? getXMLSize(meta) : 0) 430 + ((data != null) ? 14 + data.length() : 0) 431 ; 432 } 433 434 438 public static long getWBXMLSize(Cred cred) { 439 Authentication auth = cred.getAuthentication(); 440 Meta meta = auth.getMeta(); 441 String data = cred.getData(); 442 443 return 4 444 + ((meta != null) ? getWBXMLSize(meta) : 0) 445 + ((data != null) ? 4 + data.length() : 0) 446 ; 447 } 448 449 490 public static long getXMLSize(Meta meta) { 491 long sizeMeta = 0; 492 493 String format = meta.getFormat() ; 494 String type = meta.getType() ; 495 String mark = meta.getMark() ; 496 Long size = meta.getSize() ; 497 Anchor anchor = meta.getAnchor() ; 498 String version = meta.getVersion() ; 499 NextNonce nextNonce = meta.getNextNonce() ; 500 Long maxMsgSize = meta.getMaxMsgSize(); 501 Long maxObjSize = meta.getMaxObjSize(); 502 ArrayList 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 532 public static long getWBXMLSize(Meta meta) { 533 long sizeMeta = 0; 534 535 String format = meta.getFormat() ; 536 String type = meta.getType() ; 537 String mark = meta.getMark() ; 538 Long size = meta.getSize() ; 539 Anchor anchor = meta.getAnchor() ; 540 String version = meta.getVersion() ; 541 NextNonce nextNonce = meta.getNextNonce() ; 542 Long maxMsgSize = meta.getMaxMsgSize(); 543 Long maxObjSize = meta.getMaxObjSize(); 544 ArrayList 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 583 public static long getXMLSize(Anchor anchor) { 584 String last = anchor.getLast(); 585 String 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 598 public static long getWBXMLSize(Anchor anchor) { 599 String last = anchor.getLast(); 600 String 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 617 public static long getXMLSize(EMI emi) { 618 return 12 619 + emi.getValue().length() 620 ; 621 } 622 623 628 public static long getWBXMLSize(EMI emi) { 629 return 4 630 + emi.getValue().length() 631 ; 632 } 633 634 643 public static long getXMLSize(NextNonce nextNonce) { 644 return 24 645 + nextNonce.getValueAsBase64().length() 646 ; 647 } 648 649 654 public static long getWBXMLSize(NextNonce nextNonce) { 655 return 4 656 + nextNonce.getValueAsBase64().length() 657 ; 658 } 659 660 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 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 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 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 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 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 835 public static long getXMLSize(CmdID cmdID) { 836 return 16 837 + cmdID.getCmdID().length(); 838 } 839 840 844 public static long getWBXMLSize(CmdID cmdID) { 845 return 2 846 + cmdID.getCmdID().length(); 847 } 848 849 867 public static long getXMLSize(Add add) { 868 Meta meta = add.getMeta() ; 869 ArrayList 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 886 public static long getWBXMLSize(Add add) { 887 Meta meta = add.getMeta() ; 888 ArrayList 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 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 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 965 public static long getXMLSize(ComplexData complexData) { 966 String 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 982 public static long getWBXMLSize(ComplexData complexData) { 983 String 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 1003 public static long getXMLSize(Data data) { 1004 return 14 1005 + data.getData().length(); 1006 } 1007 1008 1013 public static long getWBXMLSize(Data data) { 1014 return 4 1015 + data.getData().length(); 1016 } 1017 1018 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 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 1101 public static long getXMLSize(DevInf devInf) { 1102 VerDTD verDTD = devInf.getVerDTD() ; 1103 String man = devInf.getMan() ; 1104 String mod = devInf.getMod() ; 1105 String oem = devInf.getOEM() ; 1106 String fwV = devInf.getFwV() ; 1107 String swV = devInf.getSwV() ; 1108 String hwV = devInf.getHwV() ; 1109 String devID = devInf.getDevID() ; 1110 String devTyp = devInf.getDevTyp() ; 1111 ArrayList dataStores = devInf.getDataStore(); 1112 ArrayList ctCaps = devInf.getCTCap() ; 1113 ArrayList 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 1148 public static long getWBXMLSize(DevInf devInf) { 1149 VerDTD verDTD = devInf.getVerDTD() ; 1150 String man = devInf.getMan() ; 1151 String mod = devInf.getMod() ; 1152 String oem = devInf.getOEM() ; 1153 String fwV = devInf.getFwV() ; 1154 String swV = devInf.getSwV() ; 1155 String hwV = devInf.getHwV() ; 1156 String devID = devInf.getDevID() ; 1157 String devTyp = devInf.getDevTyp() ; 1158 ArrayList dataStores = devInf.getDataStore(); 1159 ArrayList ctCaps = devInf.getCTCap() ; 1160 ArrayList 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 1228 public static long getXMLSize(DataStore dataStore) { 1229 SourceRef sourceRef = dataStore.getSourceRef() ; 1230 String displayName = dataStore.getDisplayName(); 1231 long maxGUIDSize = dataStore.getMaxGUIDSize(); 1232 ContentTypeInfo rxPref = dataStore.getRxPref() ; 1233 ArrayList rxs = dataStore.getRx() ; 1234 ContentTypeInfo txPref = dataStore.getTxPref() ; 1235 ArrayList 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 1267 public static long getWBXMLSize(DataStore dataStore) { 1268 SourceRef sourceRef = dataStore.getSourceRef() ; 1269 String displayName = dataStore.getDisplayName(); 1270 long maxGUIDSize = dataStore.getMaxGUIDSize(); 1271 ContentTypeInfo rxPref = dataStore.getRxPref() ; 1272 ArrayList rxs = dataStore.getRx() ; 1273 ContentTypeInfo txPref = dataStore.getTxPref() ; 1274 ArrayList 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 1315 public static long getXMLSize(ContentTypeInfo contentTypeInfo) { 1316 String ctType = contentTypeInfo.getCTType(); 1317 String verCT = contentTypeInfo.getVerCT() ; 1318 1319 return ((ctType != null) ? 18 + ctType.length() : 0) 1320 + ((verCT != null) ? 16 + verCT.length() : 0) 1321 ; 1322 } 1323 1324 1329 public static long getWBXMLSize(ContentTypeInfo contentTypeInfo) { 1330 String ctType = contentTypeInfo.getCTType(); 1331 String verCT = contentTypeInfo.getVerCT() ; 1332 1333 return ((ctType != null) ? 4 + ctType.length() : 0) 1334 + ((verCT != null) ? 4 + verCT.length() : 0) 1335 ; 1336 } 1337 1338 1350 public static long getXMLSize(SourceRef sourceRef) { 1351 String 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 1364 public static long getWBXMLSize(SourceRef sourceRef) { 1365 String 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 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 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 1429 public static long getXMLSize(SyncCap syncCap) { 1430 ArrayList 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 1444 public static long getWBXMLSize(SyncCap syncCap) { 1445 ArrayList 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 1463 public static long getXMLSize(SyncType syncType) { 1464 return 22 1465 + String.valueOf(syncType.getType()).length() 1466 ; 1467 } 1468 1469 1474 public static long getWBXMLSize(SyncType syncType) { 1475 return 4 1476 + String.valueOf(syncType.getType()).length() 1477 ; 1478 } 1479 1480 1490 public static long getXMLSize(CTCap ctCap) { 1491 ArrayList 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 1505 public static long getWBXMLSize(CTCap ctCap) { 1506 ArrayList 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 1525 public static long getXMLSize(CTTypeSupported ctTypeSupported) { 1526 CTType ctType = ctTypeSupported.getCTType() ; 1527 ArrayList 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 1543 public static long getWBXMLSize(CTTypeSupported ctTypeSupported) { 1544 CTType ctType = ctTypeSupported.getCTType() ; 1545 ArrayList 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 1565 public static long getXMLSize(CTType ctType) { 1566 return 18 1567 + String.valueOf(ctType.getCTType()).length() 1568 ; 1569 } 1570 1571 1576 public static long getWBXMLSize(CTType ctType) { 1577 return 4 1578 + String.valueOf(ctType.getCTType()).length() 1579 ; 1580 } 1581 1582 1608 public static long getXMLSize(CTPropParam ctPropParam) { 1609 String propName = ctPropParam.getPropName() ; 1610 ArrayList valEnums = ctPropParam.getValEnum() ; 1611 String dataType = ctPropParam.getDataType() ; 1612 int size = ctPropParam.getSize() ; 1613 String displayName = ctPropParam.getDisplayName() ; 1614 ArrayList ctParameters = ctPropParam.getContentTypeParameters(); 1615 1616 long sizeCTPP = 0; 1617 for (int i=0; valEnums != null && i<valEnums.size(); i++) { 1618 sizeCTPP += 20 + ((String )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 1638 public static long getWBXMLSize(CTPropParam ctPropParam) { 1639 String propName = ctPropParam.getPropName() ; 1640 ArrayList valEnums = ctPropParam.getValEnum() ; 1641 String dataType = ctPropParam.getDataType() ; 1642 int size = ctPropParam.getSize() ; 1643 String displayName = ctPropParam.getDisplayName() ; 1644 ArrayList ctParameters = ctPropParam.getContentTypeParameters(); 1645 1646 long sizeCTPP = 0; 1647 for (int i=0; valEnums != null && i<valEnums.size(); i++) { 1648 sizeCTPP += 4 + ((String )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 1688 public static long getXMLSize(ContentTypeParameter ctParameter) { 1689 String paramName = ctParameter.getParamName() ; 1690 ArrayList valEnums = ctParameter.getValEnum() ; 1691 String dataType = ctParameter.getDataType() ; 1692 int size = ctParameter.getSize() ; 1693 String displayName = ctParameter.getDisplayName(); 1694 long sizeCTP = 0; 1695 1696 for (int i=0; valEnums != null && i<valEnums.size(); i++) { 1697 sizeCTP += 20 + ((String )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 1713 public static long getWBXMLSize(ContentTypeParameter ctParameter) { 1714 String paramName = ctParameter.getParamName() ; 1715 ArrayList valEnums = ctParameter.getValEnum() ; 1716 String dataType = ctParameter.getDataType() ; 1717 int size = ctParameter.getSize() ; 1718 String displayName = ctParameter.getDisplayName(); 1719 long sizeCTP = 0; 1720 1721 for (int i=0; valEnums != null && i<valEnums.size(); i++) { 1722 sizeCTP += 4 + ((String )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 1749 public static long getXMLSize(Ext ext) { 1750 String name = ext.getXNam(); 1751 ArrayList values = ext.getXVal(); 1752 long size = 13; 1753 1754 for (int i=0; values != null && i<values.size(); i++) { 1755 size += 14 + ((String )values.get(i)).length(); 1756 } 1757 1758 return ((name != null) ? 14 + name.length() : 0) 1759 + size 1760 ; 1761 } 1762 1763 1768 public static long getWBXMLSize(Ext ext) { 1769 String name = ext.getXNam(); 1770 ArrayList values = ext.getXVal(); 1771 long size = 4; 1772 1773 for (int i=0; values != null && i<values.size(); i++) { 1774 size += 4 + ((String )values.get(i)).length(); 1775 } 1776 1777 return ((name != null) ? 4 + name.length() : 0) 1778 + size 1779 ; 1780 } 1781 1801 public static long getXMLSize(Alert alert) { 1802 int data = alert.getData() ; 1803 ArrayList 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 1820 public static long getWBXMLSize(Alert alert) { 1821 int data = alert.getData() ; 1822 ArrayList 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 1852 public static long getXMLSize(Atomic atomic) { 1853 Meta meta = atomic.getMeta() ; 1854 ArrayList 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 1871 public static long getWBXMLSize(Atomic atomic) { 1872 Meta meta = atomic.getMeta() ; 1873 ArrayList 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 1903 public static long getXMLSize(Copy copy) { 1904 Meta meta = copy.getMeta() ; 1905 ArrayList 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 1922 public static long getWBXMLSize(Copy copy) { 1923 Meta meta = copy.getMeta() ; 1924 ArrayList 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 1958 public static long getXMLSize(Delete delete) { 1959 Meta meta = delete.getMeta() ; 1960 ArrayList 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 1979 public static long getWBXMLSize(Delete delete) { 1980 Meta meta = delete.getMeta() ; 1981 ArrayList 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 2011 public static long getXMLSize(Exec exec) { 2012 ArrayList 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 2028 public static long getWBXMLSize(Exec exec) { 2029 ArrayList 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 2062 public static long getXMLSize(Get get) { 2063 String lang = get.getLang(); 2064 Meta meta = get.getMeta() ; 2065 ArrayList 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 2083 public static long getWBXMLSize(Get get) { 2084 String lang = get.getLang(); 2085 Meta meta = get.getMeta() ; 2086 ArrayList 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 2121 public static long getXMLSize(Map map) { 2122 Target target = map.getTarget(); 2123 Source source = map.getSource(); 2124 Meta meta = map.getMeta() ; 2125 ArrayList 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 2144 public static long getWBXMLSize(Map map) { 2145 Target target = map.getTarget(); 2146 Source source = map.getSource(); 2147 Meta meta = map.getMeta() ; 2148 ArrayList 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 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 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 2221 public static long getXMLSize(Put put) { 2222 String lang = put.getLang(); 2223 Meta meta = put.getMeta() ; 2224 ArrayList 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 2242 public static long getWBXMLSize(Put put) { 2243 String lang = put.getLang(); 2244 Meta meta = put.getMeta() ; 2245 ArrayList 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 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 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 2324 public static long getXMLSize(Replace replace) { 2325 Meta meta = replace.getMeta() ; 2326 ArrayList 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 2343 public static long getWBXMLSize(Replace replace) { 2344 Meta meta = replace.getMeta() ; 2345 ArrayList 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 2387 public static long getXMLSize(Results results) { 2388 String msgRef = results.getMsgRef() ; 2389 String cmdRef = results.getCmdRef() ; 2390 Meta meta = results.getMeta() ; 2391 ArrayList targetRefs = results.getTargetRef(); 2392 ArrayList sourceRefs = results.getSourceRef(); 2393 ArrayList 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 2418 public static long getWBXMLSize(Results results) { 2419 String msgRef = results.getMsgRef() ; 2420 String cmdRef = results.getCmdRef() ; 2421 Meta meta = results.getMeta() ; 2422 ArrayList targetRefs = results.getTargetRef(); 2423 ArrayList sourceRefs = results.getSourceRef(); 2424 ArrayList 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 2456 public static long getXMLSize(TargetRef targetRef) { 2457 String 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 2470 public static long getWBXMLSize(TargetRef targetRef) { 2471 String 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 2508 public static long getXMLSize(Search search) { 2509 Target target = search.getTarget() ; 2510 ArrayList sources = search.getSources(); 2511 String 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 2534 public static long getWBXMLSize(Search search) { 2535 Target target = search.getTarget() ; 2536 ArrayList sources = search.getSources(); 2537 String 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 2573 public static long getXMLSize(Sequence sequence) { 2574 Meta meta = sequence.getMeta() ; 2575 ArrayList 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 2592 public static long getWBXMLSize(Sequence sequence) { 2593 Meta meta = sequence.getMeta() ; 2594 ArrayList 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 2640 public static long getXMLSize(Status status) { 2641 CmdID cmdID = status.getCmdID() ; 2642 String msgRef = status.getMsgRef() ; 2643 String cmdRef = status.getCmdRef() ; 2644 String cmd = status.getCmd() ; 2645 ArrayList targetRefs = status.getTargetRef(); 2646 ArrayList sourceRefs = status.getSourceRef(); 2647 Cred cred = status.getCred() ; 2648 Chal chal = status.getChal() ; 2649 Data data = status.getData() ; 2650 ArrayList 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 2678 public static long getWBXMLSize(Status status) { 2679 CmdID cmdID = status.getCmdID() ; 2680 String msgRef = status.getMsgRef() ; 2681 String cmdRef = status.getCmdRef() ; 2682 String cmd = status.getCmd() ; 2683 ArrayList targetRefs = status.getTargetRef(); 2684 ArrayList sourceRefs = status.getSourceRef(); 2685 Cred cred = status.getCred() ; 2686 Chal chal = status.getChal() ; 2687 Data data = status.getData() ; 2688 ArrayList 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 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 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 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 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 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 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 2816 public static long getXMLSize(ItemizedCommand itemCmd) { 2817 Meta meta = itemCmd.getMeta() ; 2818 ArrayList 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 2834 public static long getWBXMLSize(ItemizedCommand itemCmd) { 2835 Meta meta = itemCmd.getMeta() ; 2836 ArrayList 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 2855 public static long getXMLSize(ModificationCommand modCmd) { 2856 return getXMLSize((ItemizedCommand)modCmd); 2857 } 2858 2859 2864 public static long getWBXMLSize(ModificationCommand modCmd) { 2865 return getWBXMLSize((ItemizedCommand)modCmd); 2866 } 2867 2868 2874 public static long getXMLSize(ResponseCommand responseCmd) { 2875 String msgRef = responseCmd.getMsgRef() ; 2876 String cmdRef = responseCmd.getCmdRef() ; 2877 ArrayList targetRefs = responseCmd.getTargetRef(); 2878 ArrayList 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 2900 public static long getWBXMLSize(ResponseCommand responseCmd) { 2901 String msgRef = responseCmd.getMsgRef() ; 2902 String cmdRef = responseCmd.getCmdRef() ; 2903 ArrayList targetRefs = responseCmd.getTargetRef(); 2904 ArrayList 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 |