1 31 32 59 package org.opencms.util; 60 61 import org.opencms.main.CmsIllegalArgumentException; 62 63 import java.text.DecimalFormatSymbols ; 64 import java.util.Enumeration ; 65 import java.util.Locale ; 66 import java.util.Vector ; 67 68 469 public class PrintfFormat { 470 471 504 private final class ConversionSpecification { 505 506 507 private static final int DEFAULT_DIGITS = 6; 508 509 520 private boolean m_alternateForm; 521 522 523 private int m_argumentPosition; 524 525 526 private int m_argumentPositionForFieldWidth; 527 528 529 private int m_argumentPositionForPrecision; 530 531 532 private char m_conversionCharacter; 533 534 539 private int m_fieldWidth; 540 541 545 private boolean m_fieldWidthSet; 546 547 548 private String m_fmt; 549 550 554 private boolean m_leadingSign; 555 556 560 private boolean m_leadingSpace; 561 562 566 private boolean m_leadingZeros; 567 568 572 private boolean m_leftJustify; 573 574 579 private boolean m_optionalh; 580 581 586 private boolean m_optionall; 587 588 593 private boolean m_optionalL; 594 595 599 private int m_pos; 600 601 602 private boolean m_positionalFieldWidth; 603 604 605 private boolean m_positionalPrecision; 606 607 608 private boolean m_positionalSpecification; 609 610 619 private int m_precision; 620 621 625 private boolean m_precisionSet; 626 627 633 private boolean m_thousands; 634 635 638 private boolean m_variableFieldWidth; 639 640 643 private boolean m_variablePrecision; 644 645 649 private ConversionSpecification() { 650 651 } 653 654 665 private ConversionSpecification(String fmtArg) 666 throws CmsIllegalArgumentException { 667 668 if (fmtArg == null) { 669 throw new NullPointerException (); 670 } 671 if (fmtArg.length() == 0) { 672 throw new CmsIllegalArgumentException(Messages.get().container(Messages.ERR_CONTROL_STRING_LENGTH_0)); 673 } 674 if (fmtArg.charAt(0) == '%') { 675 m_fmt = fmtArg; 676 m_pos = 1; 677 setArgPosition(); 678 setFlagCharacters(); 679 setFieldWidth(); 680 setPrecision(); 681 setOptionalHL(); 682 if (setConversionCharacter()) { 683 if (m_pos == fmtArg.length()) { 684 if (m_leadingZeros && m_leftJustify) { 685 m_leadingZeros = false; 686 } 687 if (m_precisionSet && m_leadingZeros) { 688 if (m_conversionCharacter == 'd' 689 || m_conversionCharacter == 'i' 690 || m_conversionCharacter == 'o' 691 || m_conversionCharacter == 'x') { 692 m_leadingZeros = false; 693 } 694 } 695 } else { 696 throw new CmsIllegalArgumentException(Messages.get().container( 697 Messages.ERR_INVALID_CONVERSION_SPEC_1, 698 fmtArg)); 699 } 700 } else { 701 throw new CmsIllegalArgumentException(Messages.get().container( 702 Messages.ERR_INVALID_CONVERSION_SPEC_1, 703 fmtArg)); 704 } 705 } else { 706 throw new CmsIllegalArgumentException(Messages.get().container(Messages.ERR_CONTROL_STRING_START_0)); 707 } 708 } 709 710 715 int getArgumentPosition() { 716 717 return m_argumentPosition; 718 } 719 720 725 int getArgumentPositionForFieldWidth() { 726 727 return m_argumentPositionForFieldWidth; 728 } 729 730 735 int getArgumentPositionForPrecision() { 736 737 return m_argumentPositionForPrecision; 738 } 739 740 746 char getConversionCharacter() { 747 748 return m_conversionCharacter; 749 } 750 751 757 String getLiteral() { 758 759 StringBuffer sb = new StringBuffer (); 760 int i = 0; 761 while (i < m_fmt.length()) { 762 if (m_fmt.charAt(i) == '\\') { 763 i++; 764 if (i < m_fmt.length()) { 765 char c = m_fmt.charAt(i); 766 switch (c) { 767 case 'a': 768 sb.append((char)0x07); 769 break; 770 case 'b': 771 sb.append('\b'); 772 break; 773 case 'f': 774 sb.append('\f'); 775 break; 776 case 'n': 777 sb.append(System.getProperty("line.separator")); 778 break; 779 case 'r': 780 sb.append('\r'); 781 break; 782 case 't': 783 sb.append('\t'); 784 break; 785 case 'v': 786 sb.append((char)0x0b); 787 break; 788 case '\\': 789 sb.append('\\'); 790 break; 791 default: 792 } 794 i++; 795 } else { 796 sb.append('\\'); 797 } 798 } else { 799 i++; 800 } 801 } 802 return m_fmt; 803 } 804 805 814 String internalsprintf(double s) throws CmsIllegalArgumentException { 815 816 String s2 = ""; 817 switch (m_conversionCharacter) { 818 case 'f': 819 s2 = printFFormat(s); 820 break; 821 case 'E': 822 case 'e': 823 s2 = printEFormat(s); 824 break; 825 case 'G': 826 case 'g': 827 s2 = printGFormat(s); 828 break; 829 default: 830 throw new CmsIllegalArgumentException(Messages.get().container( 831 Messages.ERR_INVALID_DOUBLE_FMT_CHAR_2, 832 "double", 833 new Character (m_conversionCharacter))); 834 } 835 return s2; 836 } 837 838 846 String internalsprintf(int s) throws CmsIllegalArgumentException { 847 848 String s2 = ""; 849 switch (m_conversionCharacter) { 850 case 'd': 851 case 'i': 852 if (m_optionalh) { 853 s2 = printDFormat((short)s); 854 } else if (m_optionall) { 855 s2 = printDFormat((long)s); 856 } else { 857 s2 = printDFormat(s); 858 } 859 break; 860 case 'x': 861 case 'X': 862 if (m_optionalh) { 863 s2 = printXFormat((short)s); 864 } else if (m_optionall) { 865 s2 = printXFormat((long)s); 866 } else { 867 s2 = printXFormat(s); 868 } 869 break; 870 case 'o': 871 if (m_optionalh) { 872 s2 = printOFormat((short)s); 873 } else if (m_optionall) { 874 s2 = printOFormat((long)s); 875 } else { 876 s2 = printOFormat(s); 877 } 878 break; 879 case 'c': 880 case 'C': 881 s2 = printCFormat((char)s); 882 break; 883 default: 884 throw new CmsIllegalArgumentException(Messages.get().container( 885 Messages.ERR_INVALID_DOUBLE_FMT_CHAR_2, 886 "int", 887 new Character (m_conversionCharacter))); 888 } 889 return s2; 890 } 891 892 900 String internalsprintf(long s) throws CmsIllegalArgumentException { 901 902 String s2 = ""; 903 switch (m_conversionCharacter) { 904 case 'd': 905 case 'i': 906 if (m_optionalh) { 907 s2 = printDFormat((short)s); 908 } else if (m_optionall) { 909 s2 = printDFormat(s); 910 } else { 911 s2 = printDFormat((int)s); 912 } 913 break; 914 case 'x': 915 case 'X': 916 if (m_optionalh) { 917 s2 = printXFormat((short)s); 918 } else if (m_optionall) { 919 s2 = printXFormat(s); 920 } else { 921 s2 = printXFormat((int)s); 922 } 923 break; 924 case 'o': 925 if (m_optionalh) { 926 s2 = printOFormat((short)s); 927 } else if (m_optionall) { 928 s2 = printOFormat(s); 929 } else { 930 s2 = printOFormat((int)s); 931 } 932 break; 933 case 'c': 934 case 'C': 935 s2 = printCFormat((char)s); 936 break; 937 default: 938 throw new CmsIllegalArgumentException(Messages.get().container( 939 Messages.ERR_INVALID_DOUBLE_FMT_CHAR_2, 940 "long", 941 new Character (m_conversionCharacter))); 942 } 943 return s2; 944 } 945 946 954 String internalsprintf(Object s) throws CmsIllegalArgumentException { 955 956 String s2 = ""; 957 if (m_conversionCharacter == 's' || m_conversionCharacter == 'S') { 958 s2 = printSFormat(s.toString()); 959 } else { 960 throw new CmsIllegalArgumentException(Messages.get().container( 961 Messages.ERR_INVALID_DOUBLE_FMT_CHAR_2, 962 "String", 963 new Character (m_conversionCharacter))); 964 } 965 return s2; 966 } 967 968 976 String internalsprintf(String s) throws CmsIllegalArgumentException { 977 978 String s2 = ""; 979 if (m_conversionCharacter == 's' || m_conversionCharacter == 'S') { 980 s2 = printSFormat(s); 981 } else { 982 throw new CmsIllegalArgumentException(Messages.get().container( 983 Messages.ERR_INVALID_DOUBLE_FMT_CHAR_2, 984 "String", 985 new Character (m_conversionCharacter))); 986 } 987 return s2; 988 } 989 990 995 boolean isPositionalFieldWidth() { 996 997 return m_positionalFieldWidth; 998 } 999 1000 1005 boolean isPositionalPrecision() { 1006 1007 return m_positionalPrecision; 1008 } 1009 1010 1015 boolean isPositionalSpecification() { 1016 1017 return m_positionalSpecification; 1018 } 1019 1020 1028 boolean isVariableFieldWidth() { 1029 1030 return m_variableFieldWidth; 1031 } 1032 1033 1041 boolean isVariablePrecision() { 1042 1043 return m_variablePrecision; 1044 } 1045 1046 1052 void setFieldWidthWithArg(int fw) { 1053 1054 if (fw < 0) { 1055 m_leftJustify = true; 1056 } 1057 m_fieldWidthSet = true; 1058 m_fieldWidth = Math.abs(fw); 1059 } 1060 1061 1065 void setLiteral(String s) { 1066 1067 m_fmt = s; 1068 } 1069 1070 1075 void setPrecisionWithArg(int pr) { 1076 1077 m_precisionSet = true; 1078 m_precision = Math.max(pr, 0); 1079 } 1080 1081 1088 private char[] applyFloatPadding(char[] ca4, boolean noDigits) { 1089 1090 char[] ca5 = ca4; 1091 if (m_fieldWidthSet) { 1092 int i, j, nBlanks; 1093 if (m_leftJustify) { 1094 nBlanks = m_fieldWidth - ca4.length; 1095 if (nBlanks > 0) { 1096 ca5 = new char[ca4.length + nBlanks]; 1097 for (i = 0; i < ca4.length; i++) { 1098 ca5[i] = ca4[i]; 1099 } 1100 for (j = 0; j < nBlanks; j++, i++) { 1101 ca5[i] = ' '; 1102 } 1103 } 1104 } else if (!m_leadingZeros || noDigits) { 1105 nBlanks = m_fieldWidth - ca4.length; 1106 if (nBlanks > 0) { 1107 ca5 = new char[ca4.length + nBlanks]; 1108 for (i = 0; i < nBlanks; i++) { 1109 ca5[i] = ' '; 1110 } 1111 for (j = 0; j < ca4.length; i++, j++) { 1112 ca5[i] = ca4[j]; 1113 } 1114 } 1115 } else if (m_leadingZeros) { 1116 nBlanks = m_fieldWidth - ca4.length; 1117 if (nBlanks > 0) { 1118 ca5 = new char[ca4.length + nBlanks]; 1119 i = 0; 1120 j = 0; 1121 if (ca4[0] == '-') { 1122 ca5[0] = '-'; 1123 i++; 1124 j++; 1125 } 1126 for (int k = 0; k < nBlanks; i++, k++) { 1127 ca5[i] = '0'; 1128 } 1129 for (; j < ca4.length; i++, j++) { 1130 ca5[i] = ca4[j]; 1131 } 1132 } 1133 } 1134 } 1135 return ca5; 1136 } 1137 1138 1148 private boolean checkForCarry(char[] ca1, int icarry) { 1149 1150 boolean carry = false; 1151 if (icarry < ca1.length) { 1152 if (ca1[icarry] == '6' || ca1[icarry] == '7' || ca1[icarry] == '8' || ca1[icarry] == '9') { 1153 carry = true; 1154 } else if (ca1[icarry] == '5') { 1155 int ii = icarry + 1; 1156 for (; ii < ca1.length; ii++) { 1157 if (ca1[ii] != '0') { 1158 break; 1159 } 1160 } 1161 carry = ii < ca1.length; 1162 if (!carry && icarry > 0) { 1163 carry = (ca1[icarry - 1] == '1' 1164 || ca1[icarry - 1] == '3' 1165 || ca1[icarry - 1] == '5' 1166 || ca1[icarry - 1] == '7' || ca1[icarry - 1] == '9'); 1167 } 1168 } 1169 } 1170 return carry; 1171 } 1172 1173 1207 private char[] eFormatDigits(double x, char eChar) { 1208 1209 char[] ca1, ca2, ca3; 1210 String sx; 1212 int i, j, k, p; 1213 int expon = 0; 1214 int ePos, rPos, eSize; 1215 boolean minusSign = false; 1216 if (x > 0.0) { 1217 sx = Double.toString(x); 1218 } else if (x < 0.0) { 1219 sx = Double.toString(-x); 1220 minusSign = true; 1221 } else { 1222 sx = Double.toString(x); 1223 if (sx.charAt(0) == '-') { 1224 minusSign = true; 1225 sx = sx.substring(1); 1226 } 1227 } 1228 ePos = sx.indexOf('E'); 1229 if (ePos == -1) { 1230 ePos = sx.indexOf('e'); 1231 } 1232 rPos = sx.indexOf('.'); 1233 if (ePos != -1) { 1234 int ie = ePos + 1; 1235 expon = 0; 1236 if (sx.charAt(ie) == '-') { 1237 for (++ie; ie < sx.length(); ie++) { 1238 if (sx.charAt(ie) != '0') { 1239 break; 1240 } 1241 } 1242 if (ie < sx.length()) { 1243 expon = -Integer.parseInt(sx.substring(ie)); 1244 } 1245 } else { 1246 if (sx.charAt(ie) == '+') { 1247 ++ie; 1248 } 1249 for (; ie < sx.length(); ie++) { 1250 if (sx.charAt(ie) != '0') { 1251 break; 1252 } 1253 } 1254 if (ie < sx.length()) { 1255 expon = Integer.parseInt(sx.substring(ie)); 1256 } 1257 } 1258 } 1259 if (rPos != -1) { 1260 expon += rPos - 1; 1261 } 1262 if (m_precisionSet) { 1263 p = m_precision; 1264 } else { 1265 p = DEFAULT_DIGITS - 1; 1266 } 1267 if (rPos != -1 && ePos != -1) { 1268 ca1 = (sx.substring(0, rPos) + sx.substring(rPos + 1, ePos)).toCharArray(); 1269 } else if (rPos != -1) { 1270 ca1 = (sx.substring(0, rPos) + sx.substring(rPos + 1)).toCharArray(); 1271 } else if (ePos != -1) { 1272 ca1 = sx.substring(0, ePos).toCharArray(); 1273 } else { 1274 ca1 = sx.toCharArray(); 1275 } 1276 boolean carry = false; 1277 int i0 = 0; 1278 if (ca1[0] != '0') { 1279 i0 = 0; 1280 } else { 1281 for (i0 = 0; i0 < ca1.length; i0++) { 1282 if (ca1[i0] != '0') { 1283 break; 1284 } 1285 } 1286 } 1287 if (i0 + p < ca1.length - 1) { 1288 carry = checkForCarry(ca1, i0 + p + 1); 1289 if (carry) { 1290 carry = startSymbolicCarry(ca1, i0 + p, i0); 1291 } 1292 if (carry) { 1293 ca2 = new char[i0 + p + 1]; 1294 ca2[i0] = '1'; 1295 for (j = 0; j < i0; j++) { 1296 ca2[j] = '0'; 1297 } 1298 for (i = i0, j = i0 + 1; j < p + 1; i++, j++) { 1299 ca2[j] = ca1[i]; 1300 } 1301 expon++; 1302 ca1 = ca2; 1303 } 1304 } 1305 if (Math.abs(expon) < 100 && !m_optionalL) { 1306 eSize = 4; 1307 } else { 1308 eSize = 5; 1309 } 1310 if (m_alternateForm || !m_precisionSet || m_precision != 0) { 1311 ca2 = new char[2 + p + eSize]; 1312 } else { 1313 ca2 = new char[1 + eSize]; 1314 } 1315 if (ca1[0] != '0') { 1316 ca2[0] = ca1[0]; 1317 j = 1; 1318 } else { 1319 for (j = 1; j < (ePos == -1 ? ca1.length : ePos); j++) { 1320 if (ca1[j] != '0') { 1321 break; 1322 } 1323 } 1324 if ((ePos != -1 && j < ePos) || (ePos == -1 && j < ca1.length)) { 1325 ca2[0] = ca1[j]; 1326 expon -= j; 1327 j++; 1328 } else { 1329 ca2[0] = '0'; 1330 j = 2; 1331 } 1332 } 1333 if (m_alternateForm || !m_precisionSet || m_precision != 0) { 1334 ca2[1] = '.'; 1335 i = 2; 1336 } else { 1337 i = 1; 1338 } 1339 for (k = 0; k < p && j < ca1.length; j++, i++, k++) { 1340 ca2[i] = ca1[j]; 1341 } 1342 for (; i < ca2.length - eSize; i++) { 1343 ca2[i] = '0'; 1344 } 1345 ca2[i++] = eChar; 1346 if (expon < 0) { 1347 ca2[i++] = '-'; 1348 } else { 1349 ca2[i++] = '+'; 1350 } 1351 expon = Math.abs(expon); 1352 if (expon >= 100) { 1353 switch (expon / 100) { 1354 case 1: 1355 ca2[i] = '1'; 1356 break; 1357 case 2: 1358 ca2[i] = '2'; 1359 break; 1360 case 3: 1361 ca2[i] = '3'; 1362 break; 1363 case 4: 1364 ca2[i] = '4'; 1365 break; 1366 case 5: 1367 ca2[i] = '5'; 1368 break; 1369 case 6: 1370 ca2[i] = '6'; 1371 break; 1372 case 7: 1373 ca2[i] = '7'; 1374 break; 1375 case 8: 1376 ca2[i] = '8'; 1377 break; 1378 case 9: 1379 ca2[i] = '9'; 1380 break; 1381 default: 1382 } 1384 i++; 1385 } 1386 switch ((expon % 100) / 10) { 1387 case 0: 1388 ca2[i] = '0'; 1389 break; 1390 case 1: 1391 ca2[i] = '1'; 1392 break; 1393 case 2: 1394 ca2[i] = '2'; 1395 break; 1396 case 3: 1397 ca2[i] = '3'; 1398 break; 1399 case 4: 1400 ca2[i] = '4'; 1401 break; 1402 case 5: 1403 ca2[i] = '5'; 1404 break; 1405 case 6: 1406 ca2[i] = '6'; 1407 break; 1408 case 7: 1409 ca2[i] = '7'; 1410 break; 1411 case 8: 1412 ca2[i] = '8'; 1413 break; 1414 case 9: 1415 ca2[i] = '9'; 1416 break; 1417 default: 1418 } 1420 i++; 1421 switch (expon % 10) { 1422 case 0: 1423 ca2[i] = '0'; 1424 break; 1425 case 1: 1426 ca2[i] = '1'; 1427 break; 1428 case 2: 1429 ca2[i] = '2'; 1430 break; 1431 case 3: 1432 ca2[i] = '3'; 1433 break; 1434 case 4: 1435 ca2[i] = '4'; 1436 break; 1437 case 5: 1438 ca2[i] = '5'; 1439 break; 1440 case 6: 1441 ca2[i] = '6'; 1442 break; 1443 case 7: 1444 ca2[i] = '7'; 1445 break; 1446 case 8: 1447 ca2[i] = '8'; 1448 break; 1449 case 9: 1450 ca2[i] = '9'; 1451 break; 1452 default: 1453 } 1455 int nZeros = 0; 1456 if (!m_leftJustify && m_leadingZeros) { 1457 int xThousands = 0; 1458 if (m_thousands) { 1459 int xlead = 0; 1460 if (ca2[0] == '+' || ca2[0] == '-' || ca2[0] == ' ') { 1461 xlead = 1; 1462 } 1463 int xdp = xlead; 1464 for (; xdp < ca2.length; xdp++) { 1465 if (ca2[xdp] == '.') { 1466 break; 1467 } 1468 } 1469 xThousands = (xdp - xlead) / 3; 1470 } 1471 if (m_fieldWidthSet) { 1472 nZeros = m_fieldWidth - ca2.length; 1473 } 1474 if ((!minusSign && (m_leadingSign || m_leadingSpace)) || minusSign) { 1475 nZeros--; 1476 } 1477 nZeros -= xThousands; 1478 if (nZeros < 0) { 1479 nZeros = 0; 1480 } 1481 } 1482 j = 0; 1483 if ((!minusSign && (m_leadingSign || m_leadingSpace)) || minusSign) { 1484 ca3 = new char[ca2.length + nZeros + 1]; 1485 j++; 1486 } else { 1487 ca3 = new char[ca2.length + nZeros]; 1488 } 1489 if (!minusSign) { 1490 if (m_leadingSign) { 1491 ca3[0] = '+'; 1492 } 1493 if (m_leadingSpace) { 1494 ca3[0] = ' '; 1495 } 1496 } else { 1497 ca3[0] = '-'; 1498 } 1499 for (k = 0; k < nZeros; j++, k++) { 1500 ca3[j] = '0'; 1501 } 1502 for (i = 0; i < ca2.length && j < ca3.length; i++, j++) { 1503 ca3[j] = ca2[i]; 1504 } 1505 1506 int lead = 0; 1507 if (ca3[0] == '+' || ca3[0] == '-' || ca3[0] == ' ') { 1508 lead = 1; 1509 } 1510 int dp = lead; 1511 for (; dp < ca3.length; dp++) { 1512 if (ca3[dp] == '.') { 1513 break; 1514 } 1515 } 1516 int nThousands = dp / 3; 1517 if (dp < ca3.length) { 1519 ca3[dp] = m_dfs.getDecimalSeparator(); 1520 } 1521 char[] ca4 = ca3; 1522 if (m_thousands && nThousands > 0) { 1523 ca4 = new char[ca3.length + nThousands + lead]; 1524 ca4[0] = ca3[0]; 1525 for (i = lead, k = lead; i < dp; i++) { 1526 if (i > 0 && (dp - i) % 3 == 0) { 1527 ca4[k] = m_dfs.getGroupingSeparator(); 1529 ca4[k + 1] = ca3[i]; 1530 k += 2; 1531 } else { 1532 ca4[k] = ca3[i]; 1533 k++; 1534 } 1535 } 1536 for (; i < ca3.length; i++, k++) { 1537 ca4[k] = ca3[i]; 1538 } 1539 } 1540 return ca4; 1541 } 1542 1543 1554 private String eFormatString(double x, char eChar) { 1555 1556 char[] ca4, ca5; 1557 if (Double.isInfinite(x)) { 1558 if (x == Double.POSITIVE_INFINITY) { 1559 if (m_leadingSign) { 1560 ca4 = "+Inf".toCharArray(); 1561 } else if (m_leadingSpace) { 1562 ca4 = " Inf".toCharArray(); 1563 } else { 1564 ca4 = "Inf".toCharArray(); 1565 } 1566 } else { 1567 ca4 = "-Inf".toCharArray(); 1568 } 1569 } else if (Double.isNaN(x)) { 1570 if (m_leadingSign) { 1571 ca4 = "+NaN".toCharArray(); 1572 } else if (m_leadingSpace) { 1573 ca4 = " NaN".toCharArray(); 1574 } else { 1575 ca4 = "NaN".toCharArray(); 1576 } 1577 } else { 1578 ca4 = eFormatDigits(x, eChar); 1579 } 1580 ca5 = applyFloatPadding(ca4, false); 1581 return new String (ca5); 1582 } 1583 1584 1609 private char[] fFormatDigits(double x) { 1610 1611 String sx; 1613 int i, j, k; 1614 int n1In, n2In; 1615 int expon = 0; 1616 boolean minusSign = false; 1617 if (x > 0.0) { 1618 sx = Double.toString(x); 1619 } else if (x < 0.0) { 1620 sx = Double.toString(-x); 1621 minusSign = true; 1622 } else { 1623 sx = Double.toString(x); 1624 if (sx.charAt(0) == '-') { 1625 minusSign = true; 1626 sx = sx.substring(1); 1627 } 1628 } 1629 int ePos = sx.indexOf('E'); 1630 int rPos = sx.indexOf('.'); 1631 if (rPos != -1) { 1632 n1In = rPos; 1633 } else if (ePos != -1) { 1634 n1In = ePos; 1635 } else { 1636 n1In = sx.length(); 1637 } 1638 if (rPos != -1) { 1639 if (ePos != -1) { 1640 n2In = ePos - rPos - 1; 1641 } else { 1642 n2In = sx.length() - rPos - 1; 1643 } 1644 } else { 1645 n2In = 0; 1646 } 1647 if (ePos != -1) { 1648 int ie = ePos + 1; 1649 expon = 0; 1650 if (sx.charAt(ie) == '-') { 1651 for (++ie; ie < sx.length(); ie++) { 1652 if (sx.charAt(ie) != '0') { 1653 break; 1654 } 1655 } 1656 if (ie < sx.length()) { 1657 expon = -Integer.parseInt(sx.substring(ie)); 1658 } 1659 } else { 1660 if (sx.charAt(ie) == '+') { 1661 ++ie; 1662 } 1663 for (; ie < sx.length(); ie++) { 1664 if (sx.charAt(ie) != '0') { 1665 break; 1666 } 1667 } 1668 if (ie < sx.length()) { 1669 expon = Integer.parseInt(sx.substring(ie)); 1670 } 1671 } 1672 } 1673 int p; 1674 if (m_precisionSet) { 1675 p = m_precision; 1676 } else { 1677 p = DEFAULT_DIGITS - 1; 1678 } 1679 char[] ca1 = sx.toCharArray(); 1680 char[] ca2 = new char[n1In + n2In]; 1681 char[] ca3, ca4, ca5; 1682 for (j = 0; j < n1In; j++) { 1683 ca2[j] = ca1[j]; 1684 } 1685 i = j + 1; 1686 for (k = 0; k < n2In; j++, i++, k++) { 1687 ca2[j] = ca1[i]; 1688 } 1689 if (n1In + expon <= 0) { 1690 ca3 = new char[-expon + n2In]; 1691 for (j = 0, k = 0; k < (-n1In - expon); k++, j++) { 1692 ca3[j] = '0'; 1693 } 1694 for (i = 0; i < (n1In + n2In); i++, j++) { 1695 ca3[j] = ca2[i]; 1696 } 1697 } else { 1698 ca3 = ca2; 1699 } 1700 boolean carry = false; 1701 if (p < -expon + n2In) { 1702 if (expon < 0) { 1703 i = p; 1704 } else { 1705 i = p + n1In; 1706 } 1707 carry = checkForCarry(ca3, i); 1708 if (carry) { 1709 carry = startSymbolicCarry(ca3, i - 1, 0); 1710 } 1711 } 1712 if (n1In + expon <= 0) { 1713 ca4 = new char[2 + p]; 1714 if (!carry) { 1715 ca4[0] = '0'; 1716 } else { 1717 ca4[0] = '1'; 1718 } 1719 if (m_alternateForm || !m_precisionSet || m_precision != 0) { 1720 ca4[1] = '.'; 1721 for (i = 0, j = 2; i < Math.min(p, ca3.length); i++, j++) { 1722 ca4[j] = ca3[i]; 1723 } 1724 for (; j < ca4.length; j++) { 1725 ca4[j] = '0'; 1726 } 1727 } 1728 } else { 1729 if (!carry) { 1730 if (m_alternateForm || !m_precisionSet || m_precision != 0) { 1731 ca4 = new char[n1In + expon + p + 1]; 1732 } else { 1733 ca4 = new char[n1In + expon]; 1734 } 1735 j = 0; 1736 } else { 1737 if (m_alternateForm || !m_precisionSet || m_precision != 0) { 1738 ca4 = new char[n1In + expon + p + 2]; 1739 } else { 1740 ca4 = new char[n1In + expon + 1]; 1741 } 1742 ca4[0] = '1'; 1743 j = 1; 1744 } 1745 for (i = 0; i < Math.min(n1In + expon, ca3.length); i++, j++) { 1746 ca4[j] = ca3[i]; 1747 } 1748 for (; i < n1In + expon; i++, j++) { 1749 ca4[j] = '0'; 1750 } 1751 if (m_alternateForm || !m_precisionSet || m_precision != 0) { 1752 ca4[j] = '.'; 1753 j++; 1754 for (k = 0; i < ca3.length && k < p; i++, j++, k++) { 1755 ca4[j] = ca3[i]; 1756 } 1757 for (; j < ca4.length; j++) { 1758 ca4[j] = '0'; 1759 } 1760 } 1761 } 1762 int nZeros = 0; 1763 if (!m_leftJustify && m_leadingZeros) { 1764 int xThousands = 0; 1765 if (m_thousands) { 1766 int xlead = 0; 1767 if (ca4[0] == '+' || ca4[0] == '-' || ca4[0] == ' ') { 1768 xlead = 1; 1769 } 1770 int xdp = xlead; 1771 for (; xdp < ca4.length; xdp++) { 1772 if (ca4[xdp] == '.') { 1773 break; 1774 } 1775 } 1776 xThousands = (xdp - xlead) / 3; 1777 } 1778 if (m_fieldWidthSet) { 1779 nZeros = m_fieldWidth - ca4.length; 1780 } 1781 if ((!minusSign && (m_leadingSign || m_leadingSpace)) || minusSign) { 1782 nZeros--; 1783 } 1784 nZeros -= xThousands; 1785 if (nZeros < 0) { 1786 nZeros = 0; 1787 } 1788 } 1789 j = 0; 1790 if ((!minusSign && (m_leadingSign || m_leadingSpace)) || minusSign) { 1791 ca5 = new char[ca4.length + nZeros + 1]; 1792 j++; 1793 } else { 1794 ca5 = new char[ca4.length + nZeros]; 1795 } 1796 if (!minusSign) { 1797 if (m_leadingSign) { 1798 ca5[0] = '+'; 1799 } 1800 if (m_leadingSpace) { 1801 ca5[0] = ' '; 1802 } 1803 } else { 1804 ca5[0] = '-'; 1805 } 1806 for (i = 0; i < nZeros; i++, j++) { 1807 ca5[j] = '0'; 1808 } 1809 for (i = 0; i < ca4.length; i++, j++) { 1810 ca5[j] = ca4[i]; 1811 } 1812 int lead = 0; 1813 if (ca5[0] == '+' || ca5[0] == '-' || ca5[0] == ' ') { 1814 lead = 1; 1815 } 1816 int dp = lead; 1817 for (; dp < ca5.length; dp++) { 1818 if (ca5[dp] == '.') { 1819 break; 1820 } 1821 } 1822 int nThousands = (dp - lead) / 3; 1823 if (dp < ca5.length) { 1825 ca5[dp] = m_dfs.getDecimalSeparator(); 1826 } 1827 char[] ca6 = ca5; 1828 if (m_thousands && nThousands > 0) { 1829 ca6 = new char[ca5.length + nThousands + lead]; 1830 ca6[0] = ca5[0]; 1831 for (i = lead, k = lead; i < dp; i++) { 1832 if (i > 0 && (dp - i) % 3 == 0) { 1833 ca6[k] = m_dfs.getGroupingSeparator(); 1835 ca6[k + 1] = ca5[i]; 1836 k += 2; 1837 } else { 1838 ca6[k] = ca5[i]; 1839 k++; 1840 } 1841 } 1842 for (; i < ca5.length; i++, k++) { 1843 ca6[k] = ca5[i]; 1844 } 1845 } 1846 return ca6; 1847 } 1848 1849 1858 private String fFormatString(double x) { 1859 1860 char[] ca6, ca7; 1861 if (Double.isInfinite(x)) { 1862 if (x == Double.POSITIVE_INFINITY) { 1863 if (m_leadingSign) { 1864 ca6 = "+Inf".toCharArray(); 1865 } else if (m_leadingSpace) { 1866 ca6 = " Inf".toCharArray(); 1867 } else { 1868 ca6 = "Inf".toCharArray(); 1869 } 1870 } else { 1871 ca6 = "-Inf".toCharArray(); 1872 } 1873 } else if (Double.isNaN(x)) { 1874 if (m_leadingSign) { 1875 ca6 = "+NaN".toCharArray(); 1876 } else if (m_leadingSpace) { 1877 ca6 = " NaN".toCharArray(); 1878 } else { 1879 ca6 = "NaN".toCharArray(); 1880 } 1881 } else { 1882 ca6 = fFormatDigits(x); 1883 } 1884 ca7 = applyFloatPadding(ca6, false); 1885 return new String (ca7); 1886 } 1887 1888 1905 private String printCFormat(char x) { 1906 1907 int nPrint = 1; 1908 int width = m_fieldWidth; 1909 if (!m_fieldWidthSet) { 1910 width = nPrint; 1911 } 1912 char[] ca = new char[width]; 1913 int i = 0; 1914 if (m_leftJustify) { 1915 ca[0] = x; 1916 for (i = 1; i <= width - nPrint; i++) { 1917 ca[i] = ' '; 1918 } 1919 } else { 1920 for (i = 0; i < width - nPrint; i++) { 1921 ca[i] = ' '; 1922 } 1923 ca[i] = x; 1924 } 1925 return new String (ca); 1926 } 1927 1928 1954 private String printDFormat(int x) { 1955 1956 return printDFormat(Integer.toString(x)); 1957 } 1958 1959 1985 private String printDFormat(long x) { 1986 1987 return printDFormat(Long.toString(x)); 1988 } 1989 1990 2016 private String printDFormat(short x) { 2017 2018 return printDFormat(Short.toString(x)); 2019 } 2020 2021 2029 private String printDFormat(String sx) { 2030 2031 int nLeadingZeros = 0; 2032 int nBlanks = 0, n = 0; 2033 int i = 0, jFirst = 0; 2034 boolean neg = sx.charAt(0) == '-'; 2035 if (sx.equals("0") && m_precisionSet && m_precision == 0) { 2036 sx = ""; 2037 } 2038 if (!neg) { 2039 if (m_precisionSet && sx.length() < m_precision) { 2040 nLeadingZeros = m_precision - sx.length(); 2041 } 2042 } else { 2043 if (m_precisionSet && (sx.length() - 1) < m_precision) { 2044 nLeadingZeros = m_precision - sx.length() + 1; 2045 } 2046 } 2047 if (nLeadingZeros < 0) { 2048 nLeadingZeros = 0; 2049 } 2050 if (m_fieldWidthSet) { 2051 nBlanks = m_fieldWidth - nLeadingZeros - sx.length(); 2052 if (!neg && (m_leadingSign || m_leadingSpace)) { 2053 nBlanks--; 2054 } 2055 } 2056 if (nBlanks < 0) { 2057 nBlanks = 0; 2058 } 2059 if (m_leadingSign) { 2060 n++; 2061 } else if (m_leadingSpace) { 2062 n++; 2063 } 2064 n += nBlanks; 2065 n += nLeadingZeros; 2066 n += sx.length(); 2067 char[] ca = new char[n]; 2068 if (m_leftJustify) { 2069 if (neg) { 2070 ca[i++] = '-'; 2071 } else if (m_leadingSign) { 2072 ca[i++] = '+'; 2073 } else if (m_leadingSpace) { 2074 ca[i++] = ' '; 2075 } 2076 char[] csx = sx.toCharArray(); 2077 jFirst = neg ? 1 : 0; 2078 for (int j = 0; j < nLeadingZeros; i++, j++) { 2079 ca[i] = '0'; 2080 } 2081 for (int j = jFirst; j < csx.length; j++, i++) { 2082 ca[i] = csx[j]; 2083 } 2084 for (int j = 0; j < nBlanks; i++, j++) { 2085 ca[i] = ' '; 2086 } 2087 } else { 2088 if (!m_leadingZeros) { 2089 for (i = 0; i < nBlanks; i++) { 2090 ca[i] = ' '; 2091 } 2092 if (neg) { 2093 ca[i++] = '-'; 2094 } else if (m_leadingSign) { 2095 ca[i++] = '+'; 2096 } else if (m_leadingSpace) { 2097 ca[i++] = ' '; 2098 } 2099 } else { 2100 if (neg) { 2101 ca[i++] = '-'; 2102 } else if (m_leadingSign) { 2103 ca[i++] = '+'; 2104 } else if (m_leadingSpace) { 2105 ca[i++] = ' '; 2106 } 2107 for (int j = 0; j < nBlanks; j++, i++) { 2108 ca[i] = '0'; 2109 } 2110 } 2111 for (int j = 0; j < nLeadingZeros; j++, i++) { 2112 ca[i] = '0'; 2113 } 2114 char[] csx = sx.toCharArray(); 2115 jFirst = neg ? 1 : 0; 2116 for (int j = jFirst; j < csx.length; j++, i++) { 2117 ca[i] = csx[j]; 2118 } 2119 } 2120 return new String (ca); 2121 } 2122 2123 2129 private String printEFormat(double x) { 2130 2131 if (m_conversionCharacter == 'e') { 2132 return eFormatString(x, 'e'); 2133 } else { 2134 return eFormatString(x, 'E'); 2135 } 2136 } 2137 2138 2143 private String printFFormat(double x) { 2144 2145 return fFormatString(x); 2146 } 2147 2148 2174 private String printGFormat(double x) { 2175 2176 String sx, sy, sz, ret; 2177 int savePrecision = m_precision; 2178 int i; 2179 char[] ca4, ca5; 2180 if (Double.isInfinite(x)) { 2181 if (x == Double.POSITIVE_INFINITY) { 2182 if (m_leadingSign) { 2183 ca4 = "+Inf".toCharArray(); 2184 } else if (m_leadingSpace) { 2185 ca4 = " Inf".toCharArray(); 2186 } else { 2187 ca4 = "Inf".toCharArray(); 2188 } 2189 } else { 2190 ca4 = "-Inf".toCharArray(); 2191 } 2192 } else if (Double.isNaN(x)) { 2193 if (m_leadingSign) { 2194 ca4 = "+NaN".toCharArray(); 2195 } else if (m_leadingSpace) { 2196 ca4 = " NaN".toCharArray(); 2197 } else { 2198 ca4 = "NaN".toCharArray(); 2199 } 2200 } else { 2201 if (!m_precisionSet) { 2202 m_precision = DEFAULT_DIGITS; 2203 } 2204 if (m_precision == 0) { 2205 m_precision = 1; 2206 } 2207 int ePos = -1; 2208 if (m_conversionCharacter == 'g') { 2209 sx = eFormatString(x, 'e').trim(); 2210 ePos = sx.indexOf('e'); 2211 } else { 2212 sx = eFormatString(x, 'E').trim(); 2213 ePos = sx.indexOf('E'); 2214 } 2215 i = ePos + 1; 2216 int expon = 0; 2217 if (sx.charAt(i) == '-') { 2218 for (++i; i < sx.length(); i++) { 2219 if (sx.charAt(i) != '0') { 2220 break; 2221 } 2222 } 2223 if (i < sx.length()) { 2224 expon = -Integer.parseInt(sx.substring(i)); 2225 } 2226 } else { 2227 if (sx.charAt(i) == '+') { 2228 ++i; 2229 } 2230 for (; i < sx.length(); i++) { 2231 if (sx.charAt(i) != '0') { 2232 break; 2233 } 2234 } 2235 if (i < sx.length()) { 2236 expon = Integer.parseInt(sx.substring(i)); 2237 } 2238 } 2239 if (!m_alternateForm) { 2243 if (expon >= -4 && expon < m_precision) { 2244 sy = fFormatString(x).trim(); 2245 } else { 2246 sy = sx.substring(0, ePos); 2247 } 2248 i = sy.length() - 1; 2249 for (; i >= 0; i--) { 2250 if (sy.charAt(i) != '0') { 2251 break; 2252 } 2253 } 2254 if (i >= 0 && sy.charAt(i) == '.') { 2255 i--; 2256 } 2257 if (i == -1) { 2258 sz = "0"; 2259 } else if (!Character.isDigit(sy.charAt(i))) { 2260 sz = sy.substring(0, i + 1) + "0"; 2261 } else { 2262 sz = sy.substring(0, i + 1); 2263 } 2264 if (expon >= -4 && expon < m_precision) { 2265 ret = sz; 2266 } else { 2267 ret = sz + sx.substring(ePos); 2268 } 2269 } else { 2270 if (expon >= -4 && expon < m_precision) { 2271 ret = fFormatString(x).trim(); 2272 } else { 2273 ret = sx; 2274 } 2275 } 2276 if (m_leadingSpace) { 2279 if (x >= 0) { 2280 ret = " " + ret; 2281 } 2282 } 2283 ca4 = ret.toCharArray(); 2284 } 2285 ca5 = applyFloatPadding(ca4, false); 2287 m_precision = savePrecision; 2288 return new String (ca5); 2289 } 2290 2291 2312 private String printOFormat(int x) { 2313 2314 String sx = null; 2315 if (x == Integer.MIN_VALUE) { 2316 sx = "20000000000"; 2317 } else if (x < 0) { 2318 String t = Integer.toString((~(-x - 1)) ^ Integer.MIN_VALUE, 8); 2319 switch (t.length()) { 2320 case 1: 2321 sx = "2000000000" + t; 2322 break; 2323 case 2: 2324 sx = "200000000" + t; 2325 break; 2326 case 3: 2327 sx = "20000000" + t; 2328 break; 2329 case 4: 2330 sx = "2000000" + t; 2331 break; 2332 case 5: 2333 sx = "200000" + t; 2334 break; 2335 case 6: 2336 sx = "20000" + t; 2337 break; 2338 case 7: 2339 sx = "2000" + t; 2340 break; 2341 case 8: 2342 sx = "200" + t; 2343 break; 2344 case 9: 2345 sx = "20" + t; 2346 break; 2347 case 10: 2348 sx = "2" + t; 2349 break; 2350 case 11: 2351 sx = "3" + t.substring(1); 2352 break; 2353 default: 2354 } 2356 } else { 2357 sx = Integer.toString(x, 8); 2358 } 2359 return printOFormat(sx); 2360 } 2361 2362 2383 private String printOFormat(long x) { 2384 2385 String sx = null; 2386 if (x == Long.MIN_VALUE) { 2387 sx = "1000000000000000000000"; 2388 } else if (x < 0) { 2389 String t = Long.toString((~(-x - 1)) ^ Long.MIN_VALUE, 8); 2390 switch (t.length()) { 2391 case 1: 2392 sx = "100000000000000000000" + t; 2393 break; 2394 case 2: 2395 sx = "10000000000000000000" + t; 2396 break; 2397 case 3: 2398 sx = "1000000000000000000" + t; 2399 break; 2400 case 4: 2401 sx = "100000000000000000" + t; 2402 break; 2403 case 5: 2404 sx = "10000000000000000" + t; 2405 break; 2406 case 6: 2407 sx = "1000000000000000" + t; 2408 break; 2409 case 7: 2410 sx = "100000000000000" + t; 2411 break; 2412 case 8: 2413 sx = "10000000000000" + t; 2414 break; 2415 case 9: 2416 sx = "1000000000000" + t; 2417 break; 2418 case 10: 2419 sx = "100000000000" + t; 2420 break; 2421 case 11: 2422 sx = "10000000000" + t; 2423 break; 2424 case 12: 2425 sx = "1000000000" + t; 2426 break; 2427 case 13: 2428 sx = "100000000" + t; 2429 break; 2430 case 14: 2431 sx = "10000000" + t; 2432 break; 2433 case 15: 2434 sx = "1000000" + t; 2435 break; 2436 case 16: 2437 sx = "100000" + t; 2438 break; 2439 case 17: 2440 sx = "10000" + t; 2441 break; 2442 case 18: 2443 sx = "1000" + t; 2444 break; 2445 case 19: 2446 sx = "100" + t; 2447 break; 2448 case 20: 2449 sx = "10" + t; 2450 break; 2451 case 21: 2452 sx = "1" + t; 2453 break; 2454 default: 2455 } 2457 } else { 2458 sx = Long.toString(x, 8); 2459 } 2460 return printOFormat(sx); 2461 } 2462 2463 2484 private String printOFormat(short x) { 2485 2486 String sx = null; 2487 if (x == Short.MIN_VALUE) { 2488 sx = "100000"; 2489 } else if (x < 0) { 2490 String t = Integer.toString((~(-x - 1)) ^ Short.MIN_VALUE, 8); 2491 switch (t.length()) { 2492 case 1: 2493 sx = "10000" + t; 2494 break; 2495 case 2: 2496 sx = "1000" + t; 2497 break; 2498 case 3: 2499 sx = "100" + t; 2500 break; 2501 case 4: 2502 sx = "10" + t; 2503 break; 2504 case 5: 2505 sx = "1" + t; 2506 break; 2507 default: 2508 } 2510 } else { 2511 sx = Integer.toString(x, 8); 2512 } 2513 return printOFormat(sx); 2514 } 2515 2516 2524 private String printOFormat(String sx) { 2525 2526 int nLeadingZeros = 0; 2527 int nBlanks = 0; 2528 if (sx.equals("0") && m_precisionSet && m_precision == 0) { 2529 sx = ""; 2530 } 2531 if (m_precisionSet) { 2532 nLeadingZeros = m_precision - sx.length(); 2533 } 2534 if (m_alternateForm) { 2535 nLeadingZeros++; 2536 } 2537 if (nLeadingZeros < 0) { 2538 nLeadingZeros = 0; 2539 } 2540 if (m_fieldWidthSet) { 2541 nBlanks = m_fieldWidth - nLeadingZeros - sx.length(); 2542 } 2543 if (nBlanks < 0) { 2544 nBlanks = 0; 2545 } 2546 int n = nLeadingZeros + sx.length() + nBlanks; 2547 char[] ca = new char[n]; 2548 int i; 2549 if (m_leftJustify) { 2550 for (i = 0; i < nLeadingZeros; i++) { 2551 ca[i] = '0'; 2552 } 2553 char[] csx = sx.toCharArray(); 2554 for (int j = 0; j < csx.length; j++, i++) { 2555 ca[i] = csx[j]; 2556 } 2557 for (int j = 0; j < nBlanks; j++, i++) { 2558 ca[i] = ' '; 2559 } 2560 } else { 2561 if (m_leadingZeros) { 2562 for (i = 0; i < nBlanks; i++) { 2563 ca[i] = '0'; 2564 } 2565 } else { 2566 for (i = 0; i < nBlanks; i++) { 2567 ca[i] = ' '; 2568 } 2569 } 2570 for (int j = 0; j < nLeadingZeros; j++, i++) { 2571 ca[i] = '0'; 2572 } 2573 char[] csx = sx.toCharArray(); 2574 for (int j = 0; j < csx.length; j++, i++) { 2575 ca[i] = csx[j]; 2576 } 2577 } 2578 return new String (ca); 2579 } 2580 2581 2604 private String printSFormat(String x) { 2605 2606 int nPrint = x.length(); 2607 int width = m_fieldWidth; 2608 if (m_precisionSet && nPrint > m_precision) { 2609 nPrint = m_precision; 2610 } 2611 if (!m_fieldWidthSet) { 2612 width = nPrint; 2613 } 2614 int n = 0; 2615 if (width > nPrint) { 2616 n += width - nPrint; 2617 } 2618 if (nPrint >= x.length()) { 2619 n += x.length(); 2620 } else { 2621 n += nPrint; 2622 } 2623 char[] ca = new char[n]; 2624 int i = 0; 2625 if (m_leftJustify) { 2626 if (nPrint >= x.length()) { 2627 char[] csx = x.toCharArray(); 2628 for (i = 0; i < x.length(); i++) { 2629 ca[i] = csx[i]; 2630 } 2631 } else { 2632 char[] csx = x.substring(0, nPrint).toCharArray(); 2633 for (i = 0; i < nPrint; i++) { 2634 ca[i] = csx[i]; 2635 } 2636 } 2637 for (int j = 0; j < width - nPrint; j++, i++) { 2638 ca[i] = ' '; 2639 } 2640 } else { 2641 for (i = 0; i < width - nPrint; i++) { 2642 ca[i] = ' '; 2643 } 2644 if (nPrint >= x.length()) { 2645 char[] csx = x.toCharArray(); 2646 for (int j = 0; j < x.length(); i++, j++) { 2647 ca[i] = csx[j]; 2648 } 2649 } else { 2650 char[] csx = x.substring(0, nPrint).toCharArray(); 2651 for (int j = 0; j < nPrint; i++, j++) { 2652 ca[i] = csx[j]; 2653 } 2654 } 2655 } 2656 return new String (ca); 2657 } 2658 2659 2679 private String printXFormat(int x) { 2680 2681 String sx = null; 2682 if (x == Integer.MIN_VALUE) { 2683 sx = "80000000"; 2684 } else if (x < 0) { 2685 String t = Integer.toString((~(-x - 1)) ^ Integer.MIN_VALUE, 16); 2686 switch (t.length()) { 2687 case 1: 2688 sx = "8000000" + t; 2689 break; 2690 case 2: 2691 sx = "800000" + t; 2692 break; 2693 case 3: 2694 sx = "80000" + t; 2695 break; 2696 case 4: 2697 sx = "8000" + t; 2698 break; 2699 case 5: 2700 sx = "800" + t; 2701 break; 2702 case 6: 2703 sx = "80" + t; 2704 break; 2705 case 7: 2706 sx = "8" + t; 2707 break; 2708 case 8: 2709 switch (t.charAt(0)) { 2710 case '1': 2711 sx = "9" + t.substring(1, 8); 2712 break; 2713 case '2': 2714 sx = "a" + t.substring(1, 8); 2715 break; 2716 case '3': 2717 sx = "b" + t.substring(1, 8); 2718 break; 2719 case '4': 2720 sx = "c" + t.substring(1, 8); 2721 break; 2722 case '5': 2723 sx = "d" + t.substring(1, 8); 2724 break; 2725 case '6': 2726 sx = "e" + t.substring(1, 8); 2727 break; 2728 case '7': 2729 sx = "f" + t.substring(1, 8); 2730 break; 2731 default: 2732 } 2734 break; 2735 default: 2736 } 2738 } else { 2739 sx = Integer.toString(x, 16); 2740 } 2741 return printXFormat(sx); 2742 } 2743 2744 2764 private String printXFormat(long x) { 2765 2766 String sx = null; 2767 if (x == Long.MIN_VALUE) { 2768 sx = "8000000000000000"; 2769 } else if (x < 0) { 2770 String t = Long.toString((~(-x - 1)) ^ Long.MIN_VALUE, 16); 2771 switch (t.length()) { 2772 case 1: 2773 sx = "800000000000000" + t; 2774 break; 2775 case 2: 2776 sx = "80000000000000" + t; 2777 break; 2778 case 3: 2779 sx = "8000000000000" + t; 2780 break; 2781 case 4: 2782 sx = "800000000000" + t; 2783 break; 2784 case 5: 2785 sx = "80000000000" + t; 2786 break; 2787 case 6: 2788 sx = "8000000000" + t; 2789 break; 2790 case 7: 2791 sx = "800000000" + t; 2792 break; 2793 case 8: 2794 sx = "80000000" + t; 2795 break; 2796 case 9: 2797 sx = "8000000" + t; 2798 break; 2799 case 10: 2800 sx = "800000" + t; 2801 break; 2802 case 11: 2803 sx = "80000" + t; 2804 break; 2805 case 12: 2806 sx = "8000" + t; 2807 break; 2808 case 13: 2809 sx = "800" + t; 2810 break; 2811 case 14: 2812 sx = "80" + t; 2813 break; 2814 case 15: 2815 sx = "8" + t; 2816 break; 2817 case 16: 2818 switch (t.charAt(0)) { 2819 case '1': 2820 sx = "9" + t.substring(1, 16); 2821 break; 2822 case '2': 2823 sx = "a" + t.substring(1, 16); 2824 break; 2825 case '3': 2826 sx = "b" + t.substring(1, 16); 2827 break; 2828 case '4': 2829 sx = "c" + t.substring(1, 16); 2830 break; 2831 case '5': 2832 sx = "d" + t.substring(1, 16); 2833 break; 2834 case '6': 2835 sx = "e" + t.substring(1, 16); 2836 break; 2837 case '7': 2838 sx = "f" + t.substring(1, 16); 2839 break; 2840 default: 2841 } 2843 break; 2844 default: 2845 } 2847 } else { 2848 sx = Long.toString(x, 16); 2849 } 2850 return printXFormat(sx); 2851 } 2852 2853 2873 private String printXFormat(short x) { 2874 2875 String sx = null; 2876 if (x == Short.MIN_VALUE) { 2877 sx = "8000"; 2878 } else if (x < 0) { 2879 String t; 2880 if (x == Short.MIN_VALUE) { 2881 t = "0"; 2882 } else { 2883 t = Integer.toString((~(-x - 1)) ^ Short.MIN_VALUE, 16); 2884 if (t.charAt(0) == 'F' || t.charAt(0) == 'f') { 2885 t = t.substring(16, 32); 2886 } 2887 } 2888 switch (t.length()) { 2889 case 1: 2890 sx = "800" + t; 2891 break; 2892 case 2: 2893 sx = "80" + t; 2894 break; 2895 case 3: 2896 sx = "8" + t; 2897 break; 2898 case 4: 2899 switch (t.charAt(0)) { 2900 case '1': 2901 sx = "9" + t.substring(1, 4); 2902 break; 2903 case '2': 2904 sx = "a" + t.substring(1, 4); 2905 break; 2906 case '3': 2907 sx = "b" + t.substring(1, 4); 2908 break; 2909 case '4': 2910 sx = "c" + t.substring(1, 4); 2911 break; 2912 case '5': 2913 sx = "d" + t.substring(1, 4); 2914 break; 2915 case '6': 2916 sx = "e" + t.substring(1, 4); 2917 break; 2918 case '7': 2919 sx = "f" + t.substring(1, 4); 2920 break; 2921 default: 2922 } 2924 break; 2925 default: 2926 } 2928 } else { 2929 sx = Integer.toString(x, 16); 2930 } 2931 return printXFormat(sx); 2932 } 2933 2934 2942 private String printXFormat(String sx) { 2943 2944 int nLeadingZeros = 0; 2945 int nBlanks = 0; 2946 if (sx.equals("0") && m_precisionSet && m_precision == 0) { 2947 sx = ""; 2948 } 2949 if (m_precisionSet) { 2950 nLeadingZeros = m_precision - sx.length(); 2951 } 2952 if (nLeadingZeros < 0) { 2953 nLeadingZeros = 0; 2954 } 2955 if (m_fieldWidthSet) { 2956 nBlanks = m_fieldWidth - nLeadingZeros - sx.length(); 2957 if (m_alternateForm) { 2958 nBlanks = nBlanks - 2; 2959 } 2960 } 2961 if (nBlanks < 0) { 2962 nBlanks = 0; 2963 } 2964 int n = 0; 2965 if (m_alternateForm) { 2966 n += 2; 2967 } 2968 n += nLeadingZeros; 2969 n += sx.length(); 2970 n += nBlanks; 2971 char[] ca = new char[n]; 2972 int i = 0; 2973 if (m_leftJustify) { 2974 if (m_alternateForm) { 2975 ca[i++] = '0'; 2976 ca[i++] = 'x'; 2977 } 2978 for (int j = 0; j < nLeadingZeros; j++, i++) { 2979 ca[i] = '0'; 2980 } 2981 char[] csx = sx.toCharArray(); 2982 for (int j = 0; j < csx.length; j++, i++) { 2983 ca[i] = csx[j]; 2984 } 2985 for (int j = 0; j < nBlanks; j++, i++) { 2986 ca[i] = ' '; 2987 } 2988 } else { 2989 if (!m_leadingZeros) { 2990 for (int j = 0; j < nBlanks; j++, i++) { 2991 ca[i] = ' '; 2992 } 2993 } 2994 if (m_alternateForm) { 2995 ca[i++] = '0'; 2996 ca[i++] = 'x'; 2997 } 2998 if (m_leadingZeros) { 2999 for (int j = 0; j < nBlanks; j++, i++) { 3000 ca[i] = '0'; 3001 } 3002 } 3003 for (int j = 0; j < nLeadingZeros; j++, i++) { 3004 ca[i] = '0'; 3005 } 3006 char[] csx = sx.toCharArray(); 3007 for (int j = 0; j < csx.length; j++, i++) { 3008 ca[i] = csx[j]; 3009 } 3010 } 3011 String caReturn = new String (ca); 3012 if (m_conversionCharacter == 'X') { 3013 caReturn = caReturn.toUpperCase(); 3014 } 3015 return caReturn; 3016 } 3017 3018 3021 private void setArgPosition() { 3022 3023 int xPos; 3024 for (xPos = m_pos; xPos < m_fmt.length(); xPos++) { 3025 if (!Character.isDigit(m_fmt.charAt(xPos))) { 3026 break; 3027 } 3028 } 3029 if (xPos > m_pos && xPos < m_fmt.length()) { 3030 if (m_fmt.charAt(xPos) == '$') { 3031 m_positionalSpecification = true; 3032 m_argumentPosition = Integer.parseInt(m_fmt.substring(m_pos, xPos)); 3033 m_pos = xPos + 1; 3034 } 3035 } 3036 } 3037 3038 3045 private boolean setConversionCharacter() { 3046 3047 3048 boolean ret = false; 3049 m_conversionCharacter = '\0'; 3050 if (m_pos < m_fmt.length()) { 3051 char c = m_fmt.charAt(m_pos); 3052 if (c == 'i' 3053 || c == 'd' 3054 || c == 'f' 3055 || c == 'g' 3056 || c == 'G' 3057 || c == 'o' 3058 || c == 'x' 3059 || c == 'X' 3060 || c == 'e' 3061 || c == 'E' 3062 || c == 'c' 3063 || c == 's' 3064 || c == '%') { 3065 m_conversionCharacter = c; 3066 m_pos++; 3067 ret = true; 3068 } 3069 } 3070 return ret; 3071 } 3072 3073 3076 private void setFieldWidth() { 3077 3078 int firstPos = m_pos; 3079 m_fieldWidth = 0; 3080 m_fieldWidthSet = false; 3081 if ((m_pos < m_fmt.length()) && (m_fmt.charAt(m_pos) == '*')) { 3082 m_pos++; 3083 if (!setFieldWidthArgPosition()) { 3084 m_variableFieldWidth = true; 3085 m_fieldWidthSet = true; 3086 } 3087 } else { 3088 while (m_pos < m_fmt.length()) { 3089 char c = m_fmt.charAt(m_pos); 3090 if (Character.isDigit(c)) { 3091 m_pos++; 3092 } else { 3093 break; 3094 } 3095 } 3096 if (firstPos < m_pos && firstPos < m_fmt.length()) { 3097 String sz = m_fmt.substring(firstPos, m_pos); 3098 m_fieldWidth = Integer.parseInt(sz); 3099 m_fieldWidthSet = true; 3100 } 3101 } 3102 } 3103 3104 3109 private boolean setFieldWidthArgPosition() { 3110 3111 boolean ret = false; 3112 int xPos; 3113 for (xPos = m_pos; xPos < m_fmt.length(); xPos++) { 3114 if (!Character.isDigit(m_fmt.charAt(xPos))) { 3115 break; 3116 } 3117 } 3118 if (xPos > m_pos && xPos < m_fmt.length()) { 3119 if (m_fmt.charAt(xPos) == '$') { 3120 m_positionalFieldWidth = true; 3121 m_argumentPositionForFieldWidth = Integer.parseInt(m_fmt.substring(m_pos, xPos)); 3122 m_pos = xPos + 1; 3123 ret = true; 3124 } 3125 } 3126 return ret; 3127 } 3128 3129 3132 private void setFlagCharacters() { 3133 3134 3135 m_thousands = false; 3136 m_leftJustify = false; 3137 m_leadingSign = false; 3138 m_leadingSpace = false; 3139 m_alternateForm = false; 3140 m_leadingZeros = false; 3141 for (; m_pos < m_fmt.length(); m_pos++) { 3142 char c = m_fmt.charAt(m_pos); 3143 if (c == '\'') { 3144 m_thousands = true; 3145 } else if (c == '-') { 3146 m_leftJustify = true; 3147 m_leadingZeros = false; 3148 } else if (c == '+') { 3149 m_leadingSign = true; 3150 m_leadingSpace = false; 3151 } else if (c == ' ') { 3152 if (!m_leadingSign) { 3153 m_leadingSpace = true; 3154 } 3155 } else if (c == '#') { 3156 m_alternateForm = true; 3157 } else if (c == '0') { 3158 if (!m_leftJustify) { 3159 m_leadingZeros = true; 3160 } 3161 } else { 3162 break; 3163 } 3164 } 3165 } 3166 3167 3176 private void setOptionalHL() { 3177 3178 m_optionalh = false; 3179 m_optionall = false; 3180 m_optionalL = false; 3181 if (m_pos < m_fmt.length()) { 3182 char c = m_fmt.charAt(m_pos); 3183 if (c == 'h') { 3184 m_optionalh = true; 3185 m_pos++; 3186 } else if (c == 'l') { 3187 m_optionall = true; 3188 m_pos++; 3189 } else if (c == 'L') { 3190 m_optionalL = true; 3191 m_pos++; 3192 } 3193 } 3194 } 3195 3196 3199 private void setPrecision() { 3200 3201 int firstPos = m_pos; 3202 m_precisionSet = false; 3203 if (m_pos < m_fmt.length() && m_fmt.charAt(m_pos) == '.') { 3204 m_pos++; 3205 if ((m_pos < m_fmt.length()) && (m_fmt.charAt(m_pos) == '*')) { 3206 m_pos++; 3207 if (!setPrecisionArgPosition()) { 3208 m_variablePrecision = true; 3209 m_precisionSet = true; 3210 } 3211 return; 3212 } else { 3213 while (m_pos < m_fmt.length()) { 3214 char c = m_fmt.charAt(m_pos); 3215 if (Character.isDigit(c)) { 3216 m_pos++; 3217 } else { 3218 break; 3219 } 3220 } 3221 if (m_pos > firstPos + 1) { 3222 String sz = m_fmt.substring(firstPos + 1, m_pos); 3223 m_precision = Integer.parseInt(sz); 3224 m_precisionSet = true; 3225 } 3226 } 3227 } 3228 } 3229 3230 3235 private boolean setPrecisionArgPosition() { 3236 3237 boolean ret = false; 3238 int xPos; 3239 for (xPos = m_pos; xPos < m_fmt.length(); xPos++) { 3240 if (!Character.isDigit(m_fmt.charAt(xPos))) { 3241 break; 3242 } 3243 } 3244 if (xPos > m_pos && xPos < m_fmt.length()) { 3245 if (m_fmt.charAt(xPos) == '$') { 3246 m_positionalPrecision = true; 3247 m_argumentPositionForPrecision = Integer.parseInt(m_fmt.substring(m_pos, xPos)); 3248 m_pos = xPos + 1; 3249 ret = true; 3250 } 3251 } 3252 return ret; 3253 } 3254 3255 3269 private boolean startSymbolicCarry(char[] ca, int cLast, int cFirst) { 3270 3271 boolean carry = true; 3272 for (int i = cLast; carry && i >= cFirst; i--) { 3273 carry = false; 3274 switch (ca[i]) { 3275 case '0': 3276 ca[i] = '1'; 3277 break; 3278 case '1': 3279 ca[i] = '2'; 3280 break; 3281 case '2': 3282 ca[i] = '3'; 3283 break; 3284 case '3': 3285 ca[i] = '4'; 3286 break; 3287 case '4': 3288 ca[i] = '5'; 3289 break; 3290 case '5': 3291 ca[i] = '6'; 3292 break; 3293 case '6': 3294 ca[i] = '7'; 3295 break; 3296 case '7': 3297 ca[i] = '8'; 3298 break; 3299 case '8': 3300 ca[i] = '9'; 3301 break; 3302 case '9': 3303 ca[i] = '0'; 3304 carry = true; 3305 break; 3306 default: 3307 } 3309 } 3310 return carry; 3311 } 3312 } 3313 3314 3315 DecimalFormatSymbols m_dfs; 3316 3317 3318 private int m_cPos; 3319 3320 3321 private Vector m_vFmt = new Vector (); 3322 3323 3336 public PrintfFormat(Locale locale, String fmtArg) 3337 throws CmsIllegalArgumentException { 3338 3339 m_dfs = new DecimalFormatSymbols (locale); 3340 int ePos = 0; 3341 ConversionSpecification sFmt = null; 3342 String unCS = this.nonControl(fmtArg, 0); 3343 if (unCS != null) { 3344 sFmt = new ConversionSpecification(); 3345 sFmt.setLiteral(unCS); 3346 m_vFmt.addElement(sFmt); 3347 } 3348 while (m_cPos != -1 && m_cPos < fmtArg.length()) { 3349 for (ePos = m_cPos + 1; ePos < fmtArg.length(); ePos++) { 3350 char c = 0; 3351 c = fmtArg.charAt(ePos); 3352 if (c == 'i') { 3353 break; 3354 } 3355 if (c == 'd') { 3356 break; 3357 } 3358 if (c == 'f') { 3359 break; 3360 } 3361 if (c == 'g') { 3362 break; 3363 } 3364 if (c == 'G') { 3365 break; 3366 } 3367 if (c == 'o') { 3368 break; 3369 } 3370 if (c == 'x') { 3371 break; 3372 } 3373 if (c == 'X') { 3374 break; 3375 } 3376 if (c == 'e') { 3377 break; 3378 } 3379 if (c == 'E') { 3380 break; 3381 } 3382 if (c == 'c') { 3383 break; 3384 } 3385 if (c == 's') { 3386 break; 3387 } 3388 if (c == '%') { 3389 break; 3390 } 3391 } 3392 ePos = Math.min(ePos + 1, fmtArg.length()); 3393 sFmt = new ConversionSpecification(fmtArg.substring(m_cPos, ePos)); 3394 m_vFmt.addElement(sFmt); 3395 unCS = this.nonControl(fmtArg, ePos); 3396 if (unCS != null) { 3397 sFmt = new ConversionSpecification(); 3398 sFmt.setLiteral(unCS); 3399 m_vFmt.addElement(sFmt); 3400 } 3401 } 3402 } 3403 3404 3416 public PrintfFormat(String fmtArg) 3417 throws IllegalArgumentException { 3418 3419 this(Locale.getDefault(), fmtArg); 3420 } 3421 3422 3426 public String sprintf() { 3427 3428 Enumeration e = m_vFmt.elements(); 3429 ConversionSpecification cs = null; 3430 char c = 0; 3431 StringBuffer sb = new StringBuffer (); 3432 while (e.hasMoreElements()) { 3433 cs = (ConversionSpecification)e.nextElement(); 3434 c = cs.getConversionCharacter(); 3435 if (c == '\0') { 3436 sb.append(cs.getLiteral()); 3437 } else if (c == '%') { 3438 sb.append("%"); 3439 } 3440 } 3441 return sb.toString(); 3442 } 3443 3444 3452 public String sprintf(double x) throws CmsIllegalArgumentException { 3453 3454 Enumeration e = m_vFmt.elements(); 3455 ConversionSpecification cs = null; 3456 char c = 0; 3457 StringBuffer sb = new StringBuffer (); 3458 while (e.hasMoreElements()) { 3459 cs = (ConversionSpecification)e.nextElement(); 3460 c = cs.getConversionCharacter(); 3461 if (c == '\0') { 3462 sb.append(cs.getLiteral()); 3463 } else if (c == '%') { 3464 sb.append("%"); 3465 } else { 3466 sb.append(cs.internalsprintf(x)); 3467 } 3468 } 3469 return sb.toString(); 3470 } 3471 3472 3480 public String sprintf(int x) throws CmsIllegalArgumentException { 3481 3482 Enumeration e = m_vFmt.elements(); 3483 ConversionSpecification cs = null; 3484 char c = 0; 3485 StringBuffer sb = new StringBuffer (); 3486 while (e.hasMoreElements()) { 3487 cs = (ConversionSpecification)e.nextElement(); 3488 c = cs.getConversionCharacter(); 3489 if (c == '\0') { 3490 sb.append(cs.getLiteral()); 3491 } else if (c == '%') { 3492 sb.append("%"); 3493 } else { 3494 sb.append(cs.internalsprintf(x)); 3495 } 3496 } 3497 return sb.toString(); 3498 } 3499 3500 3508 public String sprintf(long x) throws CmsIllegalArgumentException { 3509 3510 Enumeration e = m_vFmt.elements(); 3511 ConversionSpecification cs = null; 3512 char c = 0; 3513 StringBuffer sb = new StringBuffer (); 3514 while (e.hasMoreElements()) { 3515 cs = (ConversionSpecification)e.nextElement(); 3516 c = cs.getConversionCharacter(); 3517 if (c == '\0') { 3518 sb.append(cs.getLiteral()); 3519 } else if (c == '%') { 3520 sb.append("%"); 3521 } else { 3522 sb.append(cs.internalsprintf(x)); 3523 } 3524 } 3525 return sb.toString(); 3526 } 3527 3528 3541 public String sprintf(Object x) throws CmsIllegalArgumentException { 3542 3543 Enumeration e = m_vFmt.elements(); 3544 ConversionSpecification cs = null; 3545 char c = 0; 3546 StringBuffer sb = new StringBuffer (); 3547 while (e.hasMoreElements()) { 3548 cs = (ConversionSpecification)e.nextElement(); 3549 c = cs.getConversionCharacter(); 3550 if (c == '\0') { 3551 sb.append(cs.getLiteral()); 3552 } else if (c == '%') { 3553 sb.append("%"); 3554 } else { 3555 if (x instanceof Byte ) { 3556 sb.append(cs.internalsprintf(((Byte )x).byteValue())); 3557 } else if (x instanceof Short ) { 3558 sb.append(cs.internalsprintf(((Short )x).shortValue())); 3559 } else if (x instanceof Integer ) { 3560 sb.append(cs.internalsprintf(((Integer )x).intValue())); 3561 } else if (x instanceof Long ) { 3562 sb.append(cs.internalsprintf(((Long )x).longValue())); 3563 } else if (x instanceof Float ) { 3564 sb.append(cs.internalsprintf(((Float )x).floatValue())); 3565 } else if (x instanceof Double ) { 3566 sb.append(cs.internalsprintf(((Double )x).doubleValue())); 3567 } else if (x instanceof Character ) { 3568 sb.append(cs.internalsprintf(((Character )x).charValue())); 3569 } else if (x instanceof String ) { 3570 sb.append(cs.internalsprintf((String )x)); 3571 } else { 3572 sb.append(cs.internalsprintf(x)); 3573 } 3574 } 3575 } 3576 return sb.toString(); 3577 } 3578 3579 3587 public String sprintf(Object [] o) { 3588 3589 Enumeration e = m_vFmt.elements(); 3590 ConversionSpecification cs = null; 3591 char c = 0; 3592 int i = 0; 3593 StringBuffer sb = new StringBuffer (); 3594 while (e.hasMoreElements()) { 3595 cs = (ConversionSpecification)e.nextElement(); 3596 c = cs.getConversionCharacter(); 3597 if (c == '\0') { 3598 sb.append(cs.getLiteral()); 3599 } else if (c == '%') { 3600 sb.append("%"); 3601 } else { 3602 if (cs.isPositionalSpecification()) { 3603 i = cs.getArgumentPosition() - 1; 3604 if (cs.isPositionalFieldWidth()) { 3605 int ifw = cs.getArgumentPositionForFieldWidth() - 1; 3606 cs.setFieldWidthWithArg(((Integer )o[ifw]).intValue()); 3607 } 3608 if (cs.isPositionalPrecision()) { 3609 int ipr = cs.getArgumentPositionForPrecision() - 1; 3610 cs.setPrecisionWithArg(((Integer )o[ipr]).intValue()); 3611 } 3612 } else { 3613 if (cs.isVariableFieldWidth()) { 3614 cs.setFieldWidthWithArg(((Integer )o[i]).intValue()); 3615 i++; 3616 } 3617 if (cs.isVariablePrecision()) { 3618 cs.setPrecisionWithArg(((Integer )o[i]).intValue()); 3619 i++; 3620 } 3621 } 3622 if (o[i] instanceof Byte ) { 3623 sb.append(cs.internalsprintf(((Byte )o[i]).byteValue())); 3624 } else if (o[i] instanceof Short ) { 3625 sb.append(cs.internalsprintf(((Short )o[i]).shortValue())); 3626 } else if (o[i] instanceof Integer ) { 3627 sb.append(cs.internalsprintf(((Integer )o[i]).intValue())); 3628 } else if (o[i] instanceof Long ) { 3629 sb.append(cs.internalsprintf(((Long )o[i]).longValue())); 3630 } else if (o[i] instanceof Float ) { 3631 sb.append(cs.internalsprintf(((Float )o[i]).floatValue())); 3632 } else if (o[i] instanceof Double ) { 3633 sb.append(cs.internalsprintf(((Double )o[i]).doubleValue())); 3634 } else if (o[i] instanceof Character ) { 3635 sb.append(cs.internalsprintf(((Character )o[i]).charValue())); 3636 } else if (o[i] instanceof String ) { 3637 sb.append(cs.internalsprintf((String )o[i])); 3638 } else { 3639 sb.append(cs.internalsprintf(o[i])); 3640 } 3641 if (!cs.isPositionalSpecification()) { 3642 i++; 3643 } 3644 } 3645 } 3646 return sb.toString(); 3647 } 3648 3649 3656 public String sprintf(String x) throws CmsIllegalArgumentException { 3657 3658 Enumeration e = m_vFmt.elements(); 3659 ConversionSpecification cs = null; 3660 char c = 0; 3661 StringBuffer sb = new StringBuffer (); 3662 while (e.hasMoreElements()) { 3663 cs = (ConversionSpecification)e.nextElement(); 3664 c = cs.getConversionCharacter(); 3665 if (c == '\0') { 3666 sb.append(cs.getLiteral()); 3667 } else if (c == '%') { 3668 sb.append("%"); 3669 } else { 3670 sb.append(cs.internalsprintf(x)); 3671 } 3672 } 3673 return sb.toString(); 3674 } 3675 3676 3689 private String nonControl(String s, int start) { 3690 3691 m_cPos = s.indexOf("%", start); 3692 if (m_cPos == -1) { 3693 m_cPos = s.length(); 3694 } 3695 return s.substring(start, m_cPos); 3696 } 3697} 3698 | Popular Tags |