Home | History | Annotate | Download | only in format

Lines Matching refs:tuple

125         public String format(DataDrivenNumberFormatTestData tuple) {
126 DecimalFormat fmt = createDecimalFormat(tuple);
127 String actual = fmt.format(toNumber(tuple.format));
128 String expected = tuple.output;
136 public String toPattern(DataDrivenNumberFormatTestData tuple) {
137 DecimalFormat fmt = createDecimalFormat(tuple);
139 if (tuple.toPattern != null) {
140 String expected = tuple.toPattern;
146 if (tuple.toLocalizedPattern != null) {
147 String expected = tuple.toLocalizedPattern;
157 public String parse(DataDrivenNumberFormatTestData tuple) {
158 DecimalFormat fmt = createDecimalFormat(tuple);
160 Number actual = fmt.parse(tuple.parse, ppos);
161 return compareParseResult(tuple.output, actual, ppos);
165 public String parseCurrency(DataDrivenNumberFormatTestData tuple) {
166 DecimalFormat fmt = createDecimalFormat(tuple);
168 CurrencyAmount actual = fmt.parseCurrency(tuple.parse, ppos);
169 return compareParseCurrencyResult(tuple.output, tuple.outputCurrency, actual, ppos);
173 * @param tuple
176 private DecimalFormat createDecimalFormat(DataDrivenNumberFormatTestData tuple) {
177 DecimalFormat fmt = new DecimalFormat(tuple.pattern == null ? "0" : tuple.pattern,
178 new DecimalFormatSymbols(tuple.locale == null ? EN : tuple.locale));
179 adjustDecimalFormat(tuple, fmt);
184 * @param tuple
187 private void adjustDecimalFormat(DataDrivenNumberFormatTestData tuple, DecimalFormat fmt) {
188 if (tuple.minIntegerDigits != null) {
189 fmt.setMinimumIntegerDigits(tuple.minIntegerDigits);
191 if (tuple.maxIntegerDigits != null) {
192 fmt.setMaximumIntegerDigits(tuple.maxIntegerDigits);
194 if (tuple.minFractionDigits != null) {
195 fmt.setMinimumFractionDigits(tuple.minFractionDigits);
197 if (tuple.maxFractionDigits != null) {
198 fmt.setMaximumFractionDigits(tuple.maxFractionDigits);
200 if (tuple.currency != null) {
201 fmt.setCurrency(tuple.currency);
203 if (tuple.minGroupingDigits != null) {
204 fmt.setMinimumGroupingDigits(tuple.minGroupingDigits);
206 if (tuple.useSigDigits != null) {
207 fmt.setSignificantDigitsUsed(tuple.useSigDigits != 0);
209 if (tuple.minSigDigits != null) {
210 fmt.setMinimumSignificantDigits(tuple.minSigDigits);
212 if (tuple.maxSigDigits != null) {
213 fmt.setMaximumSignificantDigits(tuple.maxSigDigits);
215 if (tuple.useGrouping != null) {
216 fmt.setGroupingUsed(tuple.useGrouping != 0);
218 if (tuple.multiplier != null) {
219 fmt.setMultiplier(tuple.multiplier);
221 if (tuple.roundingIncrement != null) {
222 fmt.setRoundingIncrement(tuple.roundingIncrement.doubleValue());
224 if (tuple.formatWidth != null) {
225 fmt.setFormatWidth(tuple.formatWidth);
227 if (tuple.padCharacter != null && tuple.padCharacter.length() > 0) {
228 fmt.setPadCharacter(tuple.padCharacter.charAt(0));
230 if (tuple.useScientific != null) {
231 fmt.setScientificNotation(tuple.useScientific != 0);
233 if (tuple.grouping != null) {
234 fmt.setGroupingSize(tuple.grouping);
236 if (tuple.grouping2 != null) {
237 fmt.setSecondaryGroupingSize(tuple.grouping2);
239 if (tuple.roundingMode != null) {
240 fmt.setRoundingMode(tuple.roundingMode);
242 if (tuple.currencyUsage != null) {
243 fmt.setCurrencyUsage(tuple.currencyUsage);
245 if (tuple.minimumExponentDigits != null) {
246 fmt.setMinimumExponentDigits(tuple.minimumExponentDigits.byteValue());
248 if (tuple.exponentSignAlwaysShown != null) {
249 fmt.setExponentSignAlwaysShown(tuple.exponentSignAlwaysShown != 0);
251 if (tuple.decimalSeparatorAlwaysShown != null) {
252 fmt.setDecimalSeparatorAlwaysShown(tuple.decimalSeparatorAlwaysShown != 0);
254 if (tuple.padPosition != null) {
255 fmt.setPadPosition(tuple.padPosition);
257 if (tuple.positivePrefix != null) {
258 fmt.setPositivePrefix(tuple.positivePrefix);
260 if (tuple.positiveSuffix != null) {
261 fmt.setPositiveSuffix(tuple.positiveSuffix);
263 if (tuple.negativePrefix != null) {
264 fmt.setNegativePrefix(tuple.negativePrefix);
266 if (tuple.negativeSuffix != null) {
267 fmt.setNegativeSuffix(tuple.negativeSuffix);
269 if (tuple.signAlwaysShown != null) {
270 fmt.setSignAlwaysShown(tuple.signAlwaysShown != 0);
272 if (tuple.localizedPattern != null) {
273 fmt.applyLocalizedPattern(tuple.localizedPattern);
275 int lenient = tuple.lenient == null ? 1 : tuple.lenient.intValue();
277 if (tuple.parseIntegerOnly != null) {
278 fmt.setParseIntegerOnly(tuple.parseIntegerOnly != 0);
280 if (tuple.parseCaseSensitive != null) {
281 fmt.setParseCaseSensitive(tuple.parseCaseSensitive != 0);
283 if (tuple.decimalPatternMatchRequired != null) {
284 fmt.setDecimalPatternMatchRequired(tuple.decimalPatternMatchRequired != 0);
286 if (tuple.parseNoExponent != null) {
287 fmt.setParseNoExponent(tuple.parseNoExponent != 0);
309 public String format(DataDrivenNumberFormatTestData tuple) {
310 DecimalFormat_ICU58 fmt = createDecimalFormat(tuple);
311 String actual = fmt.format(toNumber(tuple.format));
312 String expected = tuple.output;
320 public String toPattern(DataDrivenNumberFormatTestData tuple) {
321 DecimalFormat_ICU58 fmt = createDecimalFormat(tuple);
323 if (tuple.toPattern != null) {
324 String expected = tuple.toPattern;
330 if (tuple.toLocalizedPattern != null) {
331 String expected = tuple.toLocalizedPattern;
341 public String parse(DataDrivenNumberFormatTestData tuple) {
342 DecimalFormat_ICU58 fmt = createDecimalFormat(tuple);
344 Number actual = fmt.parse(tuple.parse, ppos);
345 return compareParseResult(tuple.output, actual, ppos);
349 public String parseCurrency(DataDrivenNumberFormatTestData tuple) {
350 DecimalFormat_ICU58 fmt = createDecimalFormat(tuple);
352 CurrencyAmount actual = fmt.parseCurrency(tuple.parse, ppos);
353 return compareParseCurrencyResult(tuple.output, tuple.outputCurrency, actual, ppos);
357 * @param tuple
360 private DecimalFormat_ICU58 createDecimalFormat(DataDrivenNumberFormatTestData tuple) {
363 tuple.pattern == null ? "0" : tuple.pattern,
364 new DecimalFormatSymbols(tuple.locale == null ? EN : tuple.locale));
365 adjustDecimalFormat(tuple, fmt);
370 * @param tuple
373 private void adjustDecimalFormat(DataDrivenNumberFormatTestData tuple, DecimalFormat_ICU58 fmt) {
374 if (tuple.minIntegerDigits != null) {
375 fmt.setMinimumIntegerDigits(tuple.minIntegerDigits);
377 if (tuple.maxIntegerDigits != null) {
378 fmt.setMaximumIntegerDigits(tuple.maxIntegerDigits);
380 if (tuple.minFractionDigits != null) {
381 fmt.setMinimumFractionDigits(tuple.minFractionDigits);
383 if (tuple.maxFractionDigits != null) {
384 fmt.setMaximumFractionDigits(tuple.maxFractionDigits);
386 if (tuple.currency != null) {
387 fmt.setCurrency(tuple.currency);
389 if (tuple.minGroupingDigits != null) {
392 if (tuple.useSigDigits != null) {
393 fmt.setSignificantDigitsUsed(tuple.useSigDigits != 0);
395 if (tuple.minSigDigits != null) {
396 fmt.setMinimumSignificantDigits(tuple.minSigDigits);
398 if (tuple.maxSigDigits != null) {
399 fmt.setMaximumSignificantDigits(tuple.maxSigDigits);
401 if (tuple.useGrouping != null) {
402 fmt.setGroupingUsed(tuple.useGrouping != 0);
404 if (tuple.multiplier != null) {
405 fmt.setMultiplier(tuple.multiplier);
407 if (tuple.roundingIncrement != null) {
408 fmt.setRoundingIncrement(tuple.roundingIncrement.doubleValue());
410 if (tuple.formatWidth != null) {
411 fmt.setFormatWidth(tuple.formatWidth);
413 if (tuple.padCharacter != null && tuple.padCharacter.length() > 0) {
414 fmt.setPadCharacter(tuple.padCharacter.charAt(0));
416 if (tuple.useScientific != null) {
417 fmt.setScientificNotation(tuple.useScientific != 0);
419 if (tuple.grouping != null) {
420 fmt.setGroupingSize(tuple.grouping);
422 if (tuple.grouping2 != null) {
423 fmt.setSecondaryGroupingSize(tuple.grouping2);
425 if (tuple.roundingMode != null) {
426 fmt.setRoundingMode(tuple.roundingMode);
428 if (tuple.currencyUsage != null) {
429 fmt.setCurrencyUsage(tuple.currencyUsage);
431 if (tuple.minimumExponentDigits != null) {
432 fmt.setMinimumExponentDigits(tuple.minimumExponentDigits.byteValue());
434 if (tuple.exponentSignAlwaysShown != null) {
435 fmt.setExponentSignAlwaysShown(tuple.exponentSignAlwaysShown != 0);
437 if (tuple.decimalSeparatorAlwaysShown != null) {
438 fmt.setDecimalSeparatorAlwaysShown(tuple.decimalSeparatorAlwaysShown != 0);
440 if (tuple.padPosition != null) {
441 fmt.setPadPosition(tuple.padPosition);
443 if (tuple.positivePrefix != null) {
444 fmt.setPositivePrefix(tuple.positivePrefix);
446 if (tuple.positiveSuffix != null) {
447 fmt.setPositiveSuffix(tuple.positiveSuffix);
449 if (tuple.negativePrefix != null) {
450 fmt.setNegativePrefix(tuple.negativePrefix);
452 if (tuple.negativeSuffix != null) {
453 fmt.setNegativeSuffix(tuple.negativeSuffix);
455 if (tuple.signAlwaysShown != null) {
458 if (tuple.localizedPattern != null) {
459 fmt.applyLocalizedPattern(tuple.localizedPattern);
461 int lenient = tuple.lenient == null ? 1 : tuple.lenient.intValue();
463 if (tuple.parseIntegerOnly != null) {
464 fmt.setParseIntegerOnly(tuple.parseIntegerOnly != 0);
466 if (tuple.parseCaseSensitive != null) {
469 if (tuple.decimalPatternMatchRequired != null) {
470 fmt.setDecimalPatternMatchRequired(tuple.decimalPatternMatchRequired != 0);
472 if (tuple.parseNoExponent != null) {
490 public String format(DataDrivenNumberFormatTestData tuple) {
491 java.text.DecimalFormat fmt = createDecimalFormat(tuple);
492 String actual = fmt.format(toNumber(tuple.format));
493 String expected = tuple.output;
501 public String toPattern(DataDrivenNumberFormatTestData tuple) {
502 java.text.DecimalFormat fmt = createDecimalFormat(tuple);
504 if (tuple.toPattern != null) {
505 String expected = tuple.toPattern;
511 if (tuple.toLocalizedPattern != null) {
512 String expected = tuple.toLocalizedPattern;
522 public String parse(DataDrivenNumberFormatTestData tuple) {
523 java.text.DecimalFormat fmt = createDecimalFormat(tuple);
525 Number actual = fmt.parse(tuple.parse, ppos);
526 return compareParseResult(tuple.output, actual, ppos);
530 * @param tuple
533 private java.text.DecimalFormat createDecimalFormat(DataDrivenNumberFormatTestData tuple) {
535 tuple.pattern == null ? "0" : tuple.pattern,
537 (tuple.locale == null ? EN : tuple.locale).toLocale()));
538 adjustDecimalFormat(tuple, fmt);
543 * @param tuple
547 DataDrivenNumberFormatTestData tuple,
549 if (tuple.minIntegerDigits != null) {
550 fmt.setMinimumIntegerDigits(tuple.minIntegerDigits);
552 if (tuple.maxIntegerDigits != null) {
553 fmt.setMaximumIntegerDigits(tuple.maxIntegerDigits);
555 if (tuple.minFractionDigits != null) {
556 fmt.setMinimumFractionDigits(tuple.minFractionDigits);
558 if (tuple.maxFractionDigits != null) {
559 fmt.setMaximumFractionDigits(tuple.maxFractionDigits);
561 if (tuple.currency != null) {
562 fmt.setCurrency(java.util.Currency.getInstance(tuple.currency.toString()));
564 if (tuple.minGroupingDigits != null) {
567 if (tuple.useSigDigits != null) {
570 if (tuple.minSigDigits != null) {
573 if (tuple.maxSigDigits != null) {
576 if (tuple.useGrouping != null) {
577 fmt.setGroupingUsed(tuple.useGrouping != 0);
579 if (tuple.multiplier != null) {
580 fmt.setMultiplier(tuple.multiplier);
582 if (tuple.roundingIncrement != null) {
585 if (tuple.formatWidth != null) {
588 if (tuple.padCharacter != null && tuple.padCharacter.length() > 0) {
591 if (tuple.useScientific != null) {
594 if (tuple.grouping != null) {
595 fmt.setGroupingSize(tuple.grouping);
597 if (tuple.grouping2 != null) {
600 if (tuple.roundingMode != null) {
603 if (tuple.currencyUsage != null) {
606 if (tuple.minimumExponentDigits != null) {
609 if (tuple.exponentSignAlwaysShown != null) {
612 if (tuple.decimalSeparatorAlwaysShown != null) {
613 fmt.setDecimalSeparatorAlwaysShown(tuple.decimalSeparatorAlwaysShown != 0);
615 if (tuple.padPosition != null) {
618 if (tuple.positivePrefix != null) {
619 fmt.setPositivePrefix(tuple.positivePrefix);
621 if (tuple.positiveSuffix != null) {
622 fmt.setPositiveSuffix(tuple.positiveSuffix);
624 if (tuple.negativePrefix != null) {
625 fmt.setNegativePrefix(tuple.negativePrefix);
627 if (tuple.negativeSuffix != null) {
628 fmt.setNegativeSuffix(tuple.negativeSuffix);
630 if (tuple.signAlwaysShown != null) {
633 if (tuple.localizedPattern != null) {
634 fmt.applyLocalizedPattern(tuple.localizedPattern);
638 if (tuple.parseIntegerOnly != null) {
639 fmt.setParseIntegerOnly(tuple.parseIntegerOnly != 0);
641 if (tuple.parseCaseSensitive != null) {
644 if (tuple.decimalPatternMatchRequired != null) {
647 if (tuple.parseNoExponent != null) {
654 DataDrivenNumberFormatTestData tuple,
656 if (tuple.minIntegerDigits != null) {
657 properties.setMinimumIntegerDigits(tuple.minIntegerDigits);
659 if (tuple.maxIntegerDigits != null) {
660 properties.setMaximumIntegerDigits(tuple.maxIntegerDigits);
662 if (tuple.minFractionDigits != null) {
663 properties.setMinimumFractionDigits(tuple.minFractionDigits);
665 if (tuple.maxFractionDigits != null) {
666 properties.setMaximumFractionDigits(tuple.maxFractionDigits);
668 if (tuple.currency != null) {
669 properties.setCurrency(tuple.currency);
671 if (tuple.minGroupingDigits != null) {
672 properties.setMinimumGroupingDigits(tuple.minGroupingDigits);
674 if (tuple.useSigDigits != null) {
677 if (tuple.minSigDigits != null) {
678 properties.setMinimumSignificantDigits(tuple.minSigDigits);
680 if (tuple.maxSigDigits != null) {
681 properties.setMaximumSignificantDigits(tuple.maxSigDigits);
683 if (tuple.useGrouping != null) {
684 properties.setGroupingUsed(tuple.useGrouping > 0);
686 if (tuple.multiplier != null) {
687 properties.setMultiplier(new BigDecimal(tuple.multiplier));
689 if (tuple.roundingIncrement != null) {
690 properties.setRoundingIncrement(new BigDecimal(tuple.roundingIncrement.toString()));
692 if (tuple.formatWidth != null) {
693 properties.setFormatWidth(tuple.formatWidth);
695 if (tuple.padCharacter != null && tuple.padCharacter.length() > 0) {
696 properties.setPadString(tuple.padCharacter.toString());
698 if (tuple.useScientific != null) {
699 properties.setMinimumExponentDigits(tuple.useScientific != 0 ? 1 : -1);
701 if (tuple.grouping != null) {
702 properties.setGroupingSize(tuple.grouping);
704 if (tuple.grouping2 != null) {
705 properties.setSecondaryGroupingSize(tuple.grouping2);
707 if (tuple.roundingMode != null) {
708 properties.setRoundingMode(RoundingMode.valueOf(tuple.roundingMode));
710 if (tuple.currencyUsage != null) {
711 properties.setCurrencyUsage(tuple.currencyUsage);
713 if (tuple.minimumExponentDigits != null) {
714 properties.setMinimumExponentDigits(tuple.minimumExponentDigits.byteValue());
716 if (tuple.exponentSignAlwaysShown != null) {
717 properties.setExponentSignAlwaysShown(tuple.exponentSignAlwaysShown != 0);
719 if (tuple.decimalSeparatorAlwaysShown != null) {
720 properties.setDecimalSeparatorAlwaysShown(tuple.decimalSeparatorAlwaysShown != 0);
722 if (tuple.padPosition != null) {
723 properties.setPadPosition(PadPosition.fromOld(tuple.padPosition));
725 if (tuple.positivePrefix != null) {
726 properties.setPositivePrefix(tuple.positivePrefix);
728 if (tuple.positiveSuffix != null) {
729 properties.setPositiveSuffix(tuple.positiveSuffix);
731 if (tuple.negativePrefix != null) {
732 properties.setNegativePrefix(tuple.negativePrefix);
734 if (tuple.negativeSuffix != null) {
735 properties.setNegativeSuffix(tuple.negativeSuffix);
737 if (tuple.signAlwaysShown != null) {
738 properties.setSignAlwaysShown(tuple.signAlwaysShown != 0);
740 if (tuple.localizedPattern != null) {
741 DecimalFormatSymbols symbols = DecimalFormatSymbols.getInstance(tuple.locale);
743 .convertLocalized(tuple.localizedPattern, symbols, false);
746 if (tuple.lenient != null) {
747 properties.setParseMode(tuple.lenient == 0 ? ParseMode.STRICT : ParseMode.LENIENT);
749 if (tuple.parseIntegerOnly != null) {
750 properties.setParseIntegerOnly(tuple.parseIntegerOnly != 0);
752 if (tuple.parseCaseSensitive != null) {
753 properties.setParseCaseSensitive(tuple.parseCaseSensitive != 0);
755 if (tuple.decimalPatternMatchRequired != null) {
756 properties.setDecimalPatternMatchRequired(tuple.decimalPatternMatchRequired != 0);
758 if (tuple.parseNoExponent != null) {
759 properties.setParseNoExponent(tuple.parseNoExponent != 0);
778 * @param tuple
782 public String format(DataDrivenNumberFormatTestData tuple) {
783 String pattern = (tuple.pattern == null) ? "0" : tuple.pattern;
784 ULocale locale = (tuple.locale == null) ? ULocale.ENGLISH : tuple.locale;
786 tuple.currency != null ? PatternStringParser.IGNORE_ROUNDING_ALWAYS
788 propertiesFromTuple(tuple, properties);
792 Number number = toNumber(tuple.format);
793 String expected = tuple.output;
805 * @param tuple
809 public String toPattern(DataDrivenNumberFormatTestData tuple) {
810 String pattern = (tuple.pattern == null) ? "0" : tuple.pattern;
815 tuple.currency != null ? PatternStringParser.IGNORE_ROUNDING_ALWAYS
817 propertiesFromTuple(tuple, properties);
832 if (tuple.toPattern != null) {
833 String expected = tuple.toPattern;
839 if (tuple.toLocalizedPattern != null) {
840 String expected = tuple.toLocalizedPattern;
850 public String parse(DataDrivenNumberFormatTestData tuple) {
851 String pattern = (tuple.pattern == null) ? "0" : tuple.pattern;
857 tuple.currency != null ? PatternStringParser.IGNORE_ROUNDING_ALWAYS
859 propertiesFromTuple(tuple, properties);
860 actual = NumberParserImpl.parseStatic(tuple.parse,
863 DecimalFormatSymbols.getInstance(tuple.locale));
867 return compareParseResult(tuple.output, actual, ppos);
871 public String parseCurrency(DataDrivenNumberFormatTestData tuple) {
872 String pattern = (tuple.pattern == null) ? "0" : tuple.pattern;
878 tuple.currency != null ? PatternStringParser.IGNORE_ROUNDING_ALWAYS
880 propertiesFromTuple(tuple, properties);
881 actual = NumberParserImpl.parseStaticCurrency(tuple.parse,
884 DecimalFormatSymbols.getInstance(tuple.locale));
889 return compareParseCurrencyResult(tuple.output, tuple.outputCurrency, actual, ppos);