Advertisement
Guest User

Untitled

a guest
Apr 28th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.62 KB | None | 0 0
  1. switch (type) {
  2.             case V_LIST:
  3.             case V_SPACED:
  4.                 char sep = type == V_LIST ? ';' : ' ';
  5.                 int cnt = 0;
  6.                 for (int i = 0; i < value.length(); i++)
  7.                     if (value.charAt(i) == sep)
  8.                         cnt++;
  9.                 assert cnt >= 1;
  10.                 int addToCode = 0;
  11.                 switch (cnt) {
  12.                 case 1:
  13.                     cld.addCode(out, name, type);
  14.                     addToCode = 1;
  15.                     break;
  16.                 case 2:
  17.                     cld.addCode(out, name, type - 1);
  18.                     addToCode = 1;
  19.                     break;
  20.                 default: // 3+
  21.                     cld.addCode(out, name, type - 2);
  22.                     cld.addCode(out, name, cnt - 3);
  23.                     addToCode = 2;
  24.                 }
  25.                 for (int i = 0; i <= value.length();) {
  26.                     int j = value.indexOf(sep, i);
  27.                     if (j < 0)
  28.                         j = value.length();
  29.                     long res = writeValueItem(out, name, value.substring(i, j), deltasListForField, deltaIndex, cld, false);
  30.                     deltaIndex = (int) (res >> 32);
  31.                     int addCodes = (int) (res << 32 >> 32);
  32.                     addToCode += addCodes;
  33.                     i = j + 1;
  34.                 }
  35.                 currentFieldCodes += addToCode;
  36.                 cld.addFieldSizeInCodes(addFieldSize, addToCode);
  37.                 break;
  38.  
  39.             case V_STR_DECIMAL:
  40.                 int ofs = ((int)typeCode) >>> OFS_SHIFT;
  41.                 String s = value.substring(0, ofs);
  42.                 cld.addCode(out, name, type);
  43.                 long res = writeValueItem(out, name, s, deltasListForField, deltaIndex, cld, false);
  44.                 deltaIndex = (int) (res >> 32);
  45.                 int addCodes = (int) (res << 32 >> 32);
  46.                 addToCode = addCodes + 1;
  47.                 if (Decimal.toDouble(num) - decimalToDouble(delta.prevNum) < 0) {
  48.                     addToCode += 2;
  49.                 } else {
  50.                     addToCode++;
  51.                 }
  52.                 currentFieldCodes += addToCode;
  53.                 cld.addFieldSizeInCodes(addFieldSize, addToCode);
  54.                 // FALLS THOUGH TO DECIMAL-DELTA WRITING !
  55.             case V_DECIMAL:
  56.                 double beforeCompose = Decimal.toDouble(num) - decimalToDouble(delta.prevNum);
  57.                 d = Decimal.compose(beforeCompose);
  58.                 delta.prevNum = num;
  59.                 int addToCodeDecimal = 1;
  60.                 if (type == V_DECIMAL) {
  61.                     cld.addCode(out, name, type);
  62.                 }
  63.                 if (beforeCompose < 0) {
  64.                     cld.addCode(out, name, BinaryIPF.NOT_DELTA_FOR_DECIMAL);
  65.                     addToCodeDecimal++;
  66.                     d = num;
  67.                 }
  68.                 cld.addCode(out, name, d);
  69.                 addToCodeDecimal++;
  70.                 if (type == V_DECIMAL) {
  71.                     currentFieldCodes += addToCodeDecimal;
  72.                     cld.addFieldSizeInCodes(addFieldSize, addToCodeDecimal);
  73.                 }
  74.                 break;
  75.             case V_DATE_COMPACT:
  76.             case V_DATE_FULL:
  77.                 d = num - delta.prevDateNum;
  78.                 delta.prevDateNum = num;
  79.                 cld.addCode(out, name, type);
  80.                 cld.addCode(out, name, d);
  81.                 currentFieldCodes += 2;
  82.                 cld.addFieldSizeInCodes(addFieldSize, 2);
  83.                 break;
  84.             default:
  85.                 throw new AssertionError();
  86.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement