1 7 package com.ibm.icu.text; 8 9 import java.text.*; 10 11 15 21 abstract class NFSubstitution { 22 26 29 private static final String copyrightNotice 30 = "Copyright \u00a91997-2004 IBM Corp. All rights reserved."; 31 32 36 39 int pos; 40 41 45 NFRuleSet ruleSet = null; 46 47 51 DecimalFormat numberFormat = null; 52 53 57 75 public static NFSubstitution makeSubstitution(int pos, 76 NFRule rule, 77 NFRule rulePredecessor, 78 NFRuleSet ruleSet, 79 RuleBasedNumberFormat formatter, 80 String description) { 81 if (description.length() == 0) { 83 return new NullSubstitution(pos, ruleSet, formatter, description); 84 } 85 86 switch (description.charAt(0)) { 87 case '<': 89 if (rule.getBaseValue() == NFRule.NEGATIVE_NUMBER_RULE) { 92 throw new IllegalArgumentException ("<< not allowed in negative-number rule"); 93 } 94 95 else if (rule.getBaseValue() == NFRule.IMPROPER_FRACTION_RULE 98 || rule.getBaseValue() == NFRule.PROPER_FRACTION_RULE 99 || rule.getBaseValue() == NFRule.MASTER_RULE) { 100 return new IntegralPartSubstitution(pos, ruleSet, formatter, description); 101 } 102 103 else if (ruleSet.isFractionSet()) { 106 return new NumeratorSubstitution(pos, rule.getBaseValue(), 107 formatter.getDefaultRuleSet(), formatter, description); 108 } 109 110 else { 112 return new MultiplierSubstitution(pos, rule.getDivisor(), ruleSet, 113 formatter, description); 114 } 115 116 case '>': 118 if (rule.getBaseValue() == NFRule.NEGATIVE_NUMBER_RULE) { 121 return new AbsoluteValueSubstitution(pos, ruleSet, formatter, description); 122 } 123 124 else if (rule.getBaseValue() == NFRule.IMPROPER_FRACTION_RULE 127 || rule.getBaseValue() == NFRule.PROPER_FRACTION_RULE 128 || rule.getBaseValue() == NFRule.MASTER_RULE) { 129 return new FractionalPartSubstitution(pos, ruleSet, formatter, description); 130 } 131 132 else if (ruleSet.isFractionSet()) { 135 throw new IllegalArgumentException (">> not allowed in fraction rule set"); 136 } 137 138 else { 140 return new ModulusSubstitution(pos, rule.getDivisor(), rulePredecessor, 141 ruleSet, formatter, description); 142 } 143 144 case '=': 147 return new SameValueSubstitution(pos, ruleSet, formatter, description); 148 149 default: 151 throw new IllegalArgumentException ("Illegal substitution character"); 152 } 153 } 154 155 165 NFSubstitution(int pos, 166 NFRuleSet ruleSet, 167 RuleBasedNumberFormat formatter, 168 String description) { 169 this.pos = pos; 171 172 if (description.length() >= 2 && description.charAt(0) == description.charAt( 177 description.length() - 1)) { 178 description = description.substring(1, description.length() - 1); 179 } 180 else if (description.length() != 0) { 181 throw new IllegalArgumentException ("Illegal substitution syntax"); 182 } 183 184 if (description.length() == 0) { 188 this.ruleSet = ruleSet; 189 } 190 191 else if (description.charAt(0) == '%') { 195 this.ruleSet = formatter.findRuleSet(description); 196 } 197 198 else if (description.charAt(0) == '#' || description.charAt(0) == '0') { 203 this.numberFormat = new DecimalFormat(description); 204 this.numberFormat.setDecimalFormatSymbols(formatter.getDecimalFormatSymbols()); 205 } 206 207 else if (description.charAt(0) == '>') { 213 this.ruleSet = ruleSet; this.numberFormat = null; 215 } 216 217 else { 219 throw new IllegalArgumentException ("Illegal substitution syntax"); 220 } 221 } 222 223 230 public void setDivisor(int radix, int exponent) { 231 } 233 234 238 243 public boolean equals(Object that) { 244 if (this.getClass() == that.getClass()) { 247 NFSubstitution that2 = (NFSubstitution)that; 248 249 return pos == that2.pos 250 && (ruleSet == null ? that2.ruleSet == null : true) && (numberFormat == null ? (that2.numberFormat == null) : numberFormat.equals(that2.numberFormat)); 252 } 253 return false; 254 } 255 256 262 public String toString() { 263 if (ruleSet != null) { 268 return tokenChar() + ruleSet.getName() + tokenChar(); 269 } else { 270 return tokenChar() + numberFormat.toPattern() + tokenChar(); 271 } 272 } 273 274 278 288 public void doSubstitution(long number, StringBuffer toInsertInto, int pos) { 289 if (ruleSet != null) { 290 long numberToFormat = transformNumber(number); 294 295 ruleSet.format(numberToFormat, toInsertInto, pos + this.pos); 296 } else { 297 double numberToFormat = transformNumber((double)number); 302 if (numberFormat.getMaximumFractionDigits() == 0) { 303 numberToFormat = Math.floor(numberToFormat); 304 } 305 306 toInsertInto.insert(pos + this.pos, numberFormat.format(numberToFormat)); 307 } 308 } 309 310 320 public void doSubstitution(double number, StringBuffer toInsertInto, int pos) { 321 double numberToFormat = transformNumber(number); 324 325 if (numberToFormat == Math.floor(numberToFormat) && ruleSet != null) { 328 ruleSet.format((long)numberToFormat, toInsertInto, pos + this.pos); 329 330 } else { 334 if (ruleSet != null) { 335 ruleSet.format(numberToFormat, toInsertInto, pos + this.pos); 336 } else { 337 toInsertInto.insert(pos + this.pos, numberFormat.format(numberToFormat)); 338 } 339 } 340 } 341 342 351 public abstract long transformNumber(long number); 352 353 362 public abstract double transformNumber(double number); 363 364 368 397 public Number doParse(String text, ParsePosition parsePosition, double baseValue, 398 double upperBound, boolean lenientParse) { 399 Number tempResult; 400 401 upperBound = calcUpperBound(upperBound); 408 409 if (ruleSet != null) { 416 tempResult = ruleSet.parse(text, parsePosition, upperBound); 417 if (lenientParse && !ruleSet.isFractionSet() && parsePosition.getIndex() == 0) { 418 tempResult = NumberFormat.getInstance().parse(text, parsePosition); 419 } 420 421 } else { 423 tempResult = numberFormat.parse(text, parsePosition); 424 } 425 426 if (parsePosition.getIndex() != 0) { 431 double result = tempResult.doubleValue(); 432 433 result = composeRuleValue(result, baseValue); 456 if (result == (long)result) { 457 return new Long ((long)result); 458 } else { 459 return new Double (result); 460 } 461 462 } else { 464 return tempResult; 465 } 466 } 467 468 480 public abstract double composeRuleValue(double newRuleValue, double oldRuleValue); 481 482 489 public abstract double calcUpperBound(double oldUpperBound); 490 491 495 499 public final int getPos() { 500 return pos; 501 } 502 503 508 abstract char tokenChar(); 509 510 516 public boolean isNullSubstitution() { 517 return false; 518 } 519 520 526 public boolean isModulusSubstitution() { 527 return false; 528 } 529 } 530 531 535 539 class SameValueSubstitution extends NFSubstitution { 540 544 547 private static final String copyrightNotice 548 = "Copyright \u00a91997-1998 IBM Corp. All rights reserved."; 549 550 554 560 SameValueSubstitution(int pos, 561 NFRuleSet ruleSet, 562 RuleBasedNumberFormat formatter, 563 String description) { 564 super(pos, ruleSet, formatter, description); 565 if (description.equals("==")) { 566 throw new IllegalArgumentException ("== is not a legal token"); 567 } 568 } 569 570 574 578 public long transformNumber(long number) { 579 return number; 580 } 581 582 586 public double transformNumber(double number) { 587 return number; 588 } 589 590 594 603 public double composeRuleValue(double newRuleValue, double oldRuleValue) { 604 return newRuleValue; 605 } 606 607 612 public double calcUpperBound(double oldUpperBound) { 613 return oldUpperBound; 614 } 615 616 620 624 char tokenChar() { 625 return '='; 626 } 627 } 628 629 633 638 class MultiplierSubstitution extends NFSubstitution { 639 643 646 private static final String copyrightNotice 647 = "Copyright \u00a91997-1998 IBM Corp. All rights reserved."; 648 649 653 656 double divisor; 657 658 662 672 MultiplierSubstitution(int pos, 673 double divisor, 674 NFRuleSet ruleSet, 675 RuleBasedNumberFormat formatter, 676 String description) { 677 super(pos, ruleSet, formatter, description); 678 679 this.divisor = divisor; 683 684 if (divisor == 0) { throw new IllegalStateException ("Substitution with bad divisor (" + divisor + ") " + description.substring(0, pos) + 686 " | " + description.substring(pos)); 687 } 688 } 689 690 695 public void setDivisor(int radix, int exponent) { 696 divisor = Math.pow(radix, exponent); 697 698 if (divisor == 0) { 699 throw new IllegalStateException ("Substitution with divisor 0"); 700 } 701 } 702 703 707 712 public boolean equals(Object that) { 713 if (super.equals(that)) { 714 MultiplierSubstitution that2 = (MultiplierSubstitution)that; 715 716 return divisor == that2.divisor; 717 } else { 718 return false; 719 } 720 } 721 722 726 731 public long transformNumber(long number) { 732 return (long)Math.floor(number / divisor); 733 } 734 735 744 public double transformNumber(double number) { 745 if (ruleSet == null) { 746 return number / divisor; 747 } else { 748 return Math.floor(number / divisor); 749 } 750 } 751 752 756 765 public double composeRuleValue(double newRuleValue, double oldRuleValue) { 766 return newRuleValue * divisor; 767 } 768 769 774 public double calcUpperBound(double oldUpperBound) { 775 return divisor; 776 } 777 778 782 786 char tokenChar() { 787 return '<'; 788 } 789 } 790 791 795 800 class ModulusSubstitution extends NFSubstitution { 801 805 808 private static final String copyrightNotice 809 = "Copyright \u00a91997-1998 IBM Corp. All rights reserved."; 810 811 815 818 double divisor; 819 820 824 NFRule ruleToUse; 825 826 830 843 ModulusSubstitution(int pos, 844 double divisor, 845 NFRule rulePredecessor, 846 NFRuleSet ruleSet, 847 RuleBasedNumberFormat formatter, 848 String description) { 849 super(pos, ruleSet, formatter, description); 850 851 this.divisor = divisor; 855 856 if (divisor == 0) { throw new IllegalStateException ("Substitution with bad divisor (" + divisor + ") "+ description.substring(0, pos) + 858 " | " + description.substring(pos)); 859 } 860 861 if (description.equals(">>>")) { 867 ruleToUse = rulePredecessor; 868 } else { 869 ruleToUse = null; 870 } 871 } 872 873 879 public void setDivisor(int radix, int exponent) { 880 divisor = Math.pow(radix, exponent); 881 882 if (divisor == 0) { throw new IllegalStateException ("Substitution with bad divisor"); 884 } 885 } 886 887 891 897 public boolean equals(Object that) { 898 if (super.equals(that)) { 899 ModulusSubstitution that2 = (ModulusSubstitution)that; 900 901 return divisor == that2.divisor; 902 } else { 903 return false; 904 } 905 } 906 907 911 919 public void doSubstitution(long number, StringBuffer toInsertInto, int pos) { 920 if (ruleToUse == null) { 924 super.doSubstitution(number, toInsertInto, pos); 925 926 } else { 929 long numberToFormat = transformNumber(number); 930 ruleToUse.doFormat(numberToFormat, toInsertInto, pos + this.pos); 931 } 932 } 933 934 942 public void doSubstitution(double number, StringBuffer toInsertInto, int pos) { 943 if (ruleToUse == null) { 947 super.doSubstitution(number, toInsertInto, pos); 948 949 } else { 952 double numberToFormat = transformNumber(number); 953 954 ruleToUse.doFormat(numberToFormat, toInsertInto, pos + this.pos); 955 } 956 } 957 958 964 public long transformNumber(long number) { 965 return (long)Math.floor(number % divisor); 966 } 967 968 974 public double transformNumber(double number) { 975 return Math.floor(number % divisor); 976 } 977 978 982 991 public Number doParse(String text, ParsePosition parsePosition, double baseValue, 992 double upperBound, boolean lenientParse) { 993 if (ruleToUse == null) { 996 return super.doParse(text, parsePosition, baseValue, upperBound, lenientParse); 997 998 } else { 1002 Number tempResult = ruleToUse.doParse(text, parsePosition, false, upperBound); 1003 1004 if (parsePosition.getIndex() != 0) { 1005 double result = tempResult.doubleValue(); 1006 1007 result = composeRuleValue(result, baseValue); 1008 if (result == (long)result) { 1009 return new Long ((long)result); 1010 } else { 1011 return new Double (result); 1012 } 1013 } else { 1014 return tempResult; 1015 } 1016 } 1017 } 1018 1019 1032 public double composeRuleValue(double newRuleValue, double oldRuleValue) { 1033 return (oldRuleValue - (oldRuleValue % divisor)) + newRuleValue; 1034 } 1035 1036 1041 public double calcUpperBound(double oldUpperBound) { 1042 return divisor; 1043 } 1044 1045 1049 1053 public boolean isModulusSubstitution() { 1054 return true; 1055 } 1056 1057 1061 char tokenChar() { 1062 return '>'; 1063 } 1064} 1065 1066 1070 1074class IntegralPartSubstitution extends NFSubstitution { 1075 1079 1082 private static final String copyrightNotice 1083 = "Copyright \u00a91997-1998 IBM Corp. All rights reserved."; 1084 1085 1089 1093 IntegralPartSubstitution(int pos, 1094 NFRuleSet ruleSet, 1095 RuleBasedNumberFormat formatter, 1096 String description) { 1097 super(pos, ruleSet, formatter, description); 1098 } 1099 1100 1104 1110 public long transformNumber(long number) { 1111 return number; 1112 } 1113 1114 1119 public double transformNumber(double number) { 1120 return Math.floor(number); 1121 } 1122 1123 1127 1137 public double composeRuleValue(double newRuleValue, double oldRuleValue) { 1138 return newRuleValue + oldRuleValue; 1139 } 1140 1141 1147 public double calcUpperBound(double oldUpperBound) { 1148 return Double.MAX_VALUE; 1149 } 1150 1151 1155 1159 char tokenChar() { 1160 return '<'; 1161 } 1162} 1163 1164 1168 1172class FractionalPartSubstitution extends NFSubstitution { 1173 1177 1180 private static final String copyrightNotice 1181 = "Copyright \u00a91997-1998 IBM Corp. All rights reserved."; 1182 1183 1187 1191 private boolean byDigits = false; 1192 1193 1197 private boolean useSpaces = true; 1198 1199 1203 private static final int MAXDECIMALDIGITS = 18; 1205 1209 1214 FractionalPartSubstitution(int pos, 1215 NFRuleSet ruleSet, 1216 RuleBasedNumberFormat formatter, 1217 String description) { 1218 super(pos, ruleSet, formatter, description); 1219 1222 if (description.equals(">>") || description.equals(">>>") || ruleSet == this.ruleSet) { 1223 byDigits = true; 1224 if (description.equals(">>>")) { 1225 useSpaces = false; 1226 } 1227 } else { 1228 this.ruleSet.makeIntoFractionRuleSet(); 1229 } 1230 } 1231 1232 1236 1246 public void doSubstitution(double number, StringBuffer toInsertInto, int pos) { 1247 if (!byDigits) { 1250 super.doSubstitution(number, toInsertInto, pos); 1251 1252 } else { 1259 1263 DigitList dl = new DigitList(); 1265 dl.set(number, 20, true); 1266 1267 1287 boolean pad = false; 1288 while (dl.count > Math.max(0, dl.decimalAt)) { 1289 if (pad && useSpaces) { 1290 toInsertInto.insert(pos + this.pos, ' '); 1291 } else { 1292 pad = true; 1293 } 1294 ruleSet.format(dl.digits[--dl.count] - '0', toInsertInto, pos + this.pos); 1295 } 1296 while (dl.decimalAt < 0) { 1297 if (pad && useSpaces) { 1298 toInsertInto.insert(pos + this.pos, ' '); 1299 } else { 1300 pad = true; 1301 } 1302 ruleSet.format(0, toInsertInto, pos + this.pos); 1303 ++dl.decimalAt; 1304 } 1305 } 1306 } 1307 1308 1314 public long transformNumber(long number) { 1315 return 0; 1316 } 1317 1318 1323 public double transformNumber(double number) { 1324 return number - Math.floor(number); 1325 } 1326 1327 1331 1347 public Number doParse(String text, ParsePosition parsePosition, double baseValue, 1348 double upperBound, boolean lenientParse) { 1349 if (!byDigits) { 1352 return super.doParse(text, parsePosition, baseValue, 0, lenientParse); 1353 1354 } else { 1359 String workText = new String (text); 1360 ParsePosition workPos = new ParsePosition(1); 1361 double result = 0; 1362 int digit; 1363 1365 1372 1384 1385 DigitList dl = new DigitList(); 1386 while (workText.length() > 0 && workPos.getIndex() != 0) { 1387 workPos.setIndex(0); 1388 digit = ruleSet.parse(workText, workPos, 10).intValue(); 1389 if (lenientParse && workPos.getIndex() == 0) { 1390 digit = NumberFormat.getInstance().parse(workText, workPos).intValue(); 1391 } 1392 1393 if (workPos.getIndex() != 0) { 1394 dl.append('0'+digit); 1395 1396 parsePosition.setIndex(parsePosition.getIndex() + workPos.getIndex()); 1397 workText = workText.substring(workPos.getIndex()); 1398 while (workText.length() > 0 && workText.charAt(0) == ' ') { 1399 workText = workText.substring(1); 1400 parsePosition.setIndex(parsePosition.getIndex() + 1); 1401 } 1402 } 1403 } 1404 result = dl.count == 0 ? 0 : dl.getDouble(); 1405 1406 result = composeRuleValue(result, baseValue); 1407 return new Double (result); 1408 } 1409 } 1410 1411 1418 public double composeRuleValue(double newRuleValue, double oldRuleValue) { 1419 return newRuleValue + oldRuleValue; 1420 } 1421 1422 1425 public double calcUpperBound(double oldUpperBound) { 1426 return 0; } 1428 1429 1433 1437 char tokenChar() { 1438 return '>'; 1439 } 1440} 1441 1442 1446 1450class AbsoluteValueSubstitution extends NFSubstitution { 1451 1455 1458 private static final String copyrightNotice 1459 = "Copyright \u00a91997-1998 IBM Corp. All rights reserved."; 1460 1461 1465 1469 AbsoluteValueSubstitution(int pos, 1470 NFRuleSet ruleSet, 1471 RuleBasedNumberFormat formatter, 1472 String description) { 1473 super(pos, ruleSet, formatter, description); 1474 } 1475 1476 1480 1485 public long transformNumber(long number) { 1486 return Math.abs(number); 1487 } 1488 1489 1494 public double transformNumber(double number) { 1495 return Math.abs(number); 1496 } 1497 1498 1502 1510 public double composeRuleValue(double newRuleValue, double oldRuleValue) { 1511 return -newRuleValue; 1512 } 1513 1514 1519 public double calcUpperBound(double oldUpperBound) { 1520 return Double.MAX_VALUE; 1521 } 1522 1523 1527 1531 char tokenChar() { 1532 return '>'; 1533 } 1534} 1535 1536 1540 1546class NumeratorSubstitution extends NFSubstitution { 1547 1551 1554 private static final String copyrightNotice 1555 = "Copyright \u00a91997-1998 IBM Corp. All rights reserved."; 1556 1557 1561 1565 double denominator; 1566 1567 1570 boolean withZeros; 1571 1572 1576 1581 NumeratorSubstitution(int pos, 1582 double denominator, 1583 NFRuleSet ruleSet, 1584 RuleBasedNumberFormat formatter, 1585 String description) { 1586 super(pos, ruleSet, formatter, fixdesc(description)); 1587 1588 this.denominator = denominator; 1592 1593 this.withZeros = description.endsWith("<<"); 1594 } 1595 1596 static String fixdesc(String description) { 1597 return description.endsWith("<<") 1598 ? description.substring(0,description.length()-1) 1599 : description; 1600 } 1601 1602 1606 1611 public boolean equals(Object that) { 1612 if (super.equals(that)) { 1613 NumeratorSubstitution that2 = (NumeratorSubstitution)that; 1614 return denominator == that2.denominator; 1615 } else { 1616 return false; 1617 } 1618 } 1619 1620 1624 1634 public void doSubstitution(double number, StringBuffer toInsertInto, int pos) { 1635 String s = toInsertInto.toString(); 1638 double numberToFormat = transformNumber(number); 1639 1640 if (withZeros && ruleSet != null) { 1641 long nf = (long)numberToFormat; 1643 int len = toInsertInto.length(); 1644 while ((nf *= 10) < denominator) { 1645 toInsertInto.insert(pos + this.pos, ' '); 1646 ruleSet.format(0, toInsertInto, pos + this.pos); 1647 } 1648 pos += toInsertInto.length() - len; 1649 } 1650 1651 if (numberToFormat == Math.floor(numberToFormat) && ruleSet != null) { 1654 ruleSet.format((long)numberToFormat, toInsertInto, pos + this.pos); 1655 1656 } else { 1660 if (ruleSet != null) { 1661 ruleSet.format(numberToFormat, toInsertInto, pos + this.pos); 1662 } else { 1663 toInsertInto.insert(pos + this.pos, numberFormat.format(numberToFormat)); 1664 } 1665 } 1666 } 1667 1668 1673 public long transformNumber(long number) { 1674 return Math.round(number * denominator); 1675 } 1676 1677 1682 public double transformNumber(double number) { 1683 return Math.round(number * denominator); 1684 } 1685 1686 1690 1694 public Number doParse(String text, ParsePosition parsePosition, double baseValue, 1695 double upperBound, boolean lenientParse) { 1696 1700 int zeroCount = 0; 1703 if (withZeros) { 1704 String workText = new String (text); 1705 ParsePosition workPos = new ParsePosition(1); 1706 int digit; 1707 1708 while (workText.length() > 0 && workPos.getIndex() != 0) { 1709 workPos.setIndex(0); 1710 digit = ruleSet.parse(workText, workPos, 1).intValue(); if (workPos.getIndex() == 0) { 1712 break; 1715 } 1716 1717 ++zeroCount; 1718 parsePosition.setIndex(parsePosition.getIndex() + workPos.getIndex()); 1719 workText = workText.substring(workPos.getIndex()); 1720 while (workText.length() > 0 && workText.charAt(0) == ' ') { 1721 workText = workText.substring(1); 1722 parsePosition.setIndex(parsePosition.getIndex() + 1); 1723 } 1724 } 1725 1726 text = text.substring(parsePosition.getIndex()); parsePosition.setIndex(0); 1728 } 1729 1730 Number result = super.doParse(text, parsePosition, withZeros ? 1 : baseValue, upperBound, false); 1732 1733 if (withZeros) { 1734 1737 long n = result.longValue(); 1739 long d = 1; 1740 int pow = 0; 1741 while (d <= n) { 1742 d *= 10; 1743 ++pow; 1744 } 1745 while (zeroCount > 0) { 1747 d *= 10; 1748 --zeroCount; 1749 } 1750 result = new Double (n/(double)d); 1752 } 1753 1754 return result; 1755 } 1756 1757 1764 public double composeRuleValue(double newRuleValue, double oldRuleValue) { 1765 return newRuleValue / oldRuleValue; 1766 } 1767 1768 1773 public double calcUpperBound(double oldUpperBound) { 1774 return denominator; 1775 } 1776 1777 1781 1785 char tokenChar() { 1786 return '<'; 1787 } 1788} 1789 1790 1794 1799class NullSubstitution extends NFSubstitution { 1800 1804 1807 private static final String copyrightNotice 1808 = "Copyright \u00a91997-1998 IBM Corp. All rights reserved."; 1809 1810 1814 1818 NullSubstitution(int pos, 1819 NFRuleSet ruleSet, 1820 RuleBasedNumberFormat formatter, 1821 String description) { 1822 super(pos, ruleSet, formatter, description); 1823 } 1824 1825 1829 1832 public boolean equals(Object that) { 1833 return super.equals(that); 1834 } 1835 1836 1840 public String toString() { 1841 return ""; 1842 } 1843 1844 1848 1851 public void doSubstitution(long number, StringBuffer toInsertInto, int pos) { 1852 } 1853 1854 1857 public void doSubstitution(double number, StringBuffer toInsertInto, int pos) { 1858 } 1859 1860 1863 public long transformNumber(long number) { 1865 return 0; 1866 } 1867 1869 1872 public double transformNumber(double number) { 1874 return 0; 1875 } 1876 1878 1882 1885 public Number doParse(String text, ParsePosition parsePosition, double baseValue, 1886 double upperBound, boolean lenientParse) { 1887 if (baseValue == (long)baseValue) { 1888 return new Long ((long)baseValue); 1889 } else { 1890 return new Double (baseValue); 1891 } 1892 } 1893 1894 1897 public double composeRuleValue(double newRuleValue, double oldRuleValue) { 1899 return 0; 1900 } 1901 1903 1906 public double calcUpperBound(double oldUpperBound) { 1908 return 0; 1909 } 1910 1912 1916 1920 public boolean isNullSubstitution() { 1921 return true; 1922 } 1923 1924 1927 char tokenChar() { 1929 return ' '; 1930 } 1931 } 1933 1934 | Popular Tags |