Home | History | Annotate | Download | only in format

Lines Matching refs:tuple

128         public String format(DataDrivenNumberFormatTestData tuple) {
129 DecimalFormat fmt = createDecimalFormat(tuple);
130 String actual = fmt.format(toNumber(tuple.format));
131 String expected = tuple.output;
139 public String toPattern(DataDrivenNumberFormatTestData tuple) {
140 DecimalFormat fmt = createDecimalFormat(tuple);
142 if (tuple.toPattern != null) {
143 String expected = tuple.toPattern;
149 if (tuple.toLocalizedPattern != null) {
150 String expected = tuple.toLocalizedPattern;
160 public String parse(DataDrivenNumberFormatTestData tuple) {
161 DecimalFormat fmt = createDecimalFormat(tuple);
163 Number actual = fmt.parse(tuple.parse, ppos);
164 return compareParseResult(tuple.output, actual, ppos);
168 public String parseCurrency(DataDrivenNumberFormatTestData tuple) {
169 DecimalFormat fmt = createDecimalFormat(tuple);
171 CurrencyAmount actual = fmt.parseCurrency(tuple.parse, ppos);
172 return compareParseCurrencyResult(tuple.output, tuple.outputCurrency, actual, ppos);
176 * @param tuple
179 private DecimalFormat createDecimalFormat(DataDrivenNumberFormatTestData tuple) {
180 DecimalFormat fmt = new DecimalFormat(tuple.pattern == null ? "0" : tuple.pattern,
181 new DecimalFormatSymbols(tuple.locale == null ? EN : tuple.locale));
182 adjustDecimalFormat(tuple, fmt);
187 * @param tuple
190 private void adjustDecimalFormat(DataDrivenNumberFormatTestData tuple, DecimalFormat fmt) {
191 if (tuple.minIntegerDigits != null) {
192 fmt.setMinimumIntegerDigits(tuple.minIntegerDigits);
194 if (tuple.maxIntegerDigits != null) {
195 fmt.setMaximumIntegerDigits(tuple.maxIntegerDigits);
197 if (tuple.minFractionDigits != null) {
198 fmt.setMinimumFractionDigits(tuple.minFractionDigits);
200 if (tuple.maxFractionDigits != null) {
201 fmt.setMaximumFractionDigits(tuple.maxFractionDigits);
203 if (tuple.currency != null) {
204 fmt.setCurrency(tuple.currency);
206 if (tuple.minGroupingDigits != null) {
207 fmt.setMinimumGroupingDigits(tuple.minGroupingDigits);
209 if (tuple.useSigDigits != null) {
210 fmt.setSignificantDigitsUsed(tuple.useSigDigits != 0);
212 if (tuple.minSigDigits != null) {
213 fmt.setMinimumSignificantDigits(tuple.minSigDigits);
215 if (tuple.maxSigDigits != null) {
216 fmt.setMaximumSignificantDigits(tuple.maxSigDigits);
218 if (tuple.useGrouping != null) {
219 fmt.setGroupingUsed(tuple.useGrouping != 0);
221 if (tuple.multiplier != null) {
222 fmt.setMultiplier(tuple.multiplier);
224 if (tuple.roundingIncrement != null) {
225 fmt.setRoundingIncrement(tuple.roundingIncrement.doubleValue());
227 if (tuple.formatWidth != null) {
228 fmt.setFormatWidth(tuple.formatWidth);
230 if (tuple.padCharacter != null && tuple.padCharacter.length() > 0) {
231 fmt.setPadCharacter(tuple.padCharacter.charAt(0));
233 if (tuple.useScientific != null) {
234 fmt.setScientificNotation(tuple.useScientific != 0);
236 if (tuple.grouping != null) {
237 fmt.setGroupingSize(tuple.grouping);
239 if (tuple.grouping2 != null) {
240 fmt.setSecondaryGroupingSize(tuple.grouping2);
242 if (tuple.roundingMode != null) {
243 fmt.setRoundingMode(tuple.roundingMode);
245 if (tuple.currencyUsage != null) {
246 fmt.setCurrencyUsage(tuple.currencyUsage);
248 if (tuple.minimumExponentDigits != null) {
249 fmt.setMinimumExponentDigits(tuple.minimumExponentDigits.byteValue());
251 if (tuple.exponentSignAlwaysShown != null) {
252 fmt.setExponentSignAlwaysShown(tuple.exponentSignAlwaysShown != 0);
254 if (tuple.decimalSeparatorAlwaysShown != null) {
255 fmt.setDecimalSeparatorAlwaysShown(tuple.decimalSeparatorAlwaysShown != 0);
257 if (tuple.padPosition != null) {
258 fmt.setPadPosition(tuple.padPosition);
260 if (tuple.positivePrefix != null) {
261 fmt.setPositivePrefix(tuple.positivePrefix);
263 if (tuple.positiveSuffix != null) {
264 fmt.setPositiveSuffix(tuple.positiveSuffix);
266 if (tuple.negativePrefix != null) {
267 fmt.setNegativePrefix(tuple.negativePrefix);
269 if (tuple.negativeSuffix != null) {
270 fmt.setNegativeSuffix(tuple.negativeSuffix);
272 if (tuple.signAlwaysShown != null) {
273 fmt.setSignAlwaysShown(tuple.signAlwaysShown != 0);
275 if (tuple.localizedPattern != null) {
276 fmt.applyLocalizedPattern(tuple.localizedPattern);
278 int lenient = tuple.lenient == null ? 1 : tuple.lenient.intValue();
280 if (tuple.parseIntegerOnly != null) {
281 fmt.setParseIntegerOnly(tuple.parseIntegerOnly != 0);
283 if (tuple.parseCaseSensitive != null) {
284 fmt.setParseCaseSensitive(tuple.parseCaseSensitive != 0);
286 if (tuple.decimalPatternMatchRequired != null) {
287 fmt.setDecimalPatternMatchRequired(tuple.decimalPatternMatchRequired != 0);
289 if (tuple.parseNoExponent != null) {
290 fmt.setParseNoExponent(tuple.parseNoExponent != 0);
312 public String format(DataDrivenNumberFormatTestData tuple) {
313 DecimalFormat_ICU58 fmt = createDecimalFormat(tuple);
314 String actual = fmt.format(toNumber(tuple.format));
315 String expected = tuple.output;
323 public String toPattern(DataDrivenNumberFormatTestData tuple) {
324 DecimalFormat_ICU58 fmt = createDecimalFormat(tuple);
326 if (tuple.toPattern != null) {
327 String expected = tuple.toPattern;
333 if (tuple.toLocalizedPattern != null) {
334 String expected = tuple.toLocalizedPattern;
344 public String parse(DataDrivenNumberFormatTestData tuple) {
345 DecimalFormat_ICU58 fmt = createDecimalFormat(tuple);
347 Number actual = fmt.parse(tuple.parse, ppos);
348 return compareParseResult(tuple.output, actual, ppos);
352 public String parseCurrency(DataDrivenNumberFormatTestData tuple) {
353 DecimalFormat_ICU58 fmt = createDecimalFormat(tuple);
355 CurrencyAmount actual = fmt.parseCurrency(tuple.parse, ppos);
356 return compareParseCurrencyResult(tuple.output, tuple.outputCurrency, actual, ppos);
360 * @param tuple
363 private DecimalFormat_ICU58 createDecimalFormat(DataDrivenNumberFormatTestData tuple) {
366 tuple.pattern == null ? "0" : tuple.pattern,
367 new DecimalFormatSymbols(tuple.locale == null ? EN : tuple.locale));
368 adjustDecimalFormat(tuple, fmt);
373 * @param tuple
376 private void adjustDecimalFormat(DataDrivenNumberFormatTestData tuple, DecimalFormat_ICU58 fmt) {
377 if (tuple.minIntegerDigits != null) {
378 fmt.setMinimumIntegerDigits(tuple.minIntegerDigits);
380 if (tuple.maxIntegerDigits != null) {
381 fmt.setMaximumIntegerDigits(tuple.maxIntegerDigits);
383 if (tuple.minFractionDigits != null) {
384 fmt.setMinimumFractionDigits(tuple.minFractionDigits);
386 if (tuple.maxFractionDigits != null) {
387 fmt.setMaximumFractionDigits(tuple.maxFractionDigits);
389 if (tuple.currency != null) {
390 fmt.setCurrency(tuple.currency);
392 if (tuple.minGroupingDigits != null) {
395 if (tuple
396 fmt.setSignificantDigitsUsed(tuple.useSigDigits != 0);
398 if (tuple.minSigDigits != null) {
399 fmt.setMinimumSignificantDigits(tuple.minSigDigits);
401 if (tuple.maxSigDigits != null) {
402 fmt.setMaximumSignificantDigits(tuple.maxSigDigits);
404 if (tuple.useGrouping != null) {
405 fmt.setGroupingUsed(tuple.useGrouping != 0);
407 if (tuple.multiplier != null) {
408 fmt.setMultiplier(tuple.multiplier);
410 if (tuple.roundingIncrement != null) {
411 fmt.setRoundingIncrement(tuple.roundingIncrement.doubleValue());
413 if (tuple.formatWidth != null) {
414 fmt.setFormatWidth(tuple.formatWidth);
416 if (tuple.padCharacter != null && tuple.padCharacter.length() > 0) {
417 fmt.setPadCharacter(tuple.padCharacter.charAt(0));
419 if (tuple.useScientific != null) {
420 fmt.setScientificNotation(tuple.useScientific != 0);
422 if (tuple.grouping != null) {
423 fmt.setGroupingSize(tuple.grouping);
425 if (tuple.grouping2 != null) {
426 fmt.setSecondaryGroupingSize(tuple.grouping2);
428 if (tuple.roundingMode != null) {
429 fmt.setRoundingMode(tuple.roundingMode);
431 if (tuple.currencyUsage != null) {
432 fmt.setCurrencyUsage(tuple.currencyUsage);
434 if (tuple.minimumExponentDigits != null) {
435 fmt.setMinimumExponentDigits(tuple.minimumExponentDigits.byteValue());
437 if (tuple.exponentSignAlwaysShown != null) {
438 fmt.setExponentSignAlwaysShown(tuple.exponentSignAlwaysShown != 0);
440 if (tuple.decimalSeparatorAlwaysShown != null) {
441 fmt.setDecimalSeparatorAlwaysShown(tuple.decimalSeparatorAlwaysShown != 0);
443 if (tuple.padPosition != null) {
444 fmt.setPadPosition(tuple.padPosition);
446 if (tuple.positivePrefix != null) {
447 fmt.setPositivePrefix(tuple.positivePrefix);
449 if (tuple.positiveSuffix != null) {
450 fmt.setPositiveSuffix(tuple.positiveSuffix);
452 if (tuple.negativePrefix != null) {
453 fmt.setNegativePrefix(tuple.negativePrefix);
455 if (tuple.negativeSuffix != null) {
456 fmt.setNegativeSuffix(tuple.negativeSuffix);
458 if (tuple.signAlwaysShown != null) {
461 if (tuple.localizedPattern != null) {
462 fmt.applyLocalizedPattern(tuple.localizedPattern);
464 int lenient = tuple.lenient == null ? 1 : tuple.lenient.intValue();
466 if (tuple.parseIntegerOnly != null) {
467 fmt.setParseIntegerOnly(tuple.parseIntegerOnly != 0);
469 if (tuple.parseCaseSensitive != null) {
472 if (tuple.decimalPatternMatchRequired != null) {
473 fmt.setDecimalPatternMatchRequired(tuple.decimalPatternMatchRequired != 0);
475 if (tuple.parseNoExponent != null) {
493 public String format(DataDrivenNumberFormatTestData tuple) {
494 java.text.DecimalFormat fmt = createDecimalFormat(tuple);
495 String actual = fmt.format(toNumber(tuple.format));
496 String expected = tuple.output;
504 public String toPattern(DataDrivenNumberFormatTestData tuple) {
505 java.text.DecimalFormat fmt = createDecimalFormat(tuple);
507 if (tuple.toPattern != null) {
508 String expected = tuple.toPattern;
514 if (tuple.toLocalizedPattern != null) {
515 String expected = tuple.toLocalizedPattern;
525 public String parse(DataDrivenNumberFormatTestData tuple) {
526 java.text.DecimalFormat fmt = createDecimalFormat(tuple);
528 Number actual = fmt.parse(tuple.parse, ppos);
529 return compareParseResult(tuple.output, actual, ppos);
533 * @param tuple
536 private java.text.DecimalFormat createDecimalFormat(DataDrivenNumberFormatTestData tuple) {
538 tuple.pattern == null ? "0" : tuple.pattern,
540 (tuple.locale == null ? EN : tuple.locale).toLocale()));
541 adjustDecimalFormat(tuple, fmt);
546 * @param tuple
550 DataDrivenNumberFormatTestData tuple,
552 if (tuple.minIntegerDigits != null) {
553 fmt.setMinimumIntegerDigits(tuple.minIntegerDigits);
555 if (tuple.maxIntegerDigits != null) {
556 fmt.setMaximumIntegerDigits(tuple.maxIntegerDigits);
558 if (tuple.minFractionDigits != null) {
559 fmt.setMinimumFractionDigits(tuple.minFractionDigits);
561 if (tuple.maxFractionDigits != null) {
562 fmt.setMaximumFractionDigits(tuple.maxFractionDigits);
564 if (tuple.currency != null) {
565 fmt.setCurrency(java.util.Currency.getInstance(tuple.currency.toString()));
567 if (tuple.minGroupingDigits != null) {
570 if (tuple.useSigDigits != null) {
573 if (tuple.minSigDigits != null) {
576 if (tuple.maxSigDigits != null) {
579 if (tuple.useGrouping != null) {
580 fmt.setGroupingUsed(tuple.useGrouping != 0);
582 if (tuple.multiplier != null) {
583 fmt.setMultiplier(tuple.multiplier);
585 if (tuple.roundingIncrement != null) {
588 if (tuple.formatWidth != null) {
591 if (tuple.padCharacter != null && tuple.padCharacter.length() > 0) {
594 if (tuple.useScientific != null) {
597 if (tuple.grouping != null) {
598 fmt.setGroupingSize(tuple.grouping);
600 if (tuple.grouping2 != null) {
603 if (tuple.roundingMode != null) {
606 if (tuple.currencyUsage != null) {
609 if (tuple.minimumExponentDigits != null) {
612 if (tuple.exponentSignAlwaysShown != null) {
615 if (tuple.decimalSeparatorAlwaysShown != null) {
616 fmt.setDecimalSeparatorAlwaysShown(tuple.decimalSeparatorAlwaysShown != 0);
618 if (tuple.padPosition != null) {
621 if (tuple.positivePrefix != null) {
622 fmt.setPositivePrefix(tuple.positivePrefix);
624 if (tuple.positiveSuffix != null) {
625 fmt.setPositiveSuffix(tuple.positiveSuffix);
627 if (tuple.negativePrefix != null) {
628 fmt.setNegativePrefix(tuple.negativePrefix);
630 if (tuple.negativeSuffix != null) {
631 fmt.setNegativeSuffix(tuple.negativeSuffix);
633 if (tuple.signAlwaysShown != null) {
636 if (tuple.localizedPattern != null) {
637 fmt.applyLocalizedPattern(tuple.localizedPattern);
641 if (tuple.parseIntegerOnly != null) {
642 fmt.setParseIntegerOnly(tuple.parseIntegerOnly != 0);
644 if (tuple.parseCaseSensitive != null) {
647 if (tuple.decimalPatternMatchRequired != null) {
650 if (tuple.parseNoExponent != null) {
657 DataDrivenNumberFormatTestData tuple,
659 if (tuple.minIntegerDigits != null) {
660 properties.setMinimumIntegerDigits(tuple.minIntegerDigits);
662 if (tuple.maxIntegerDigits != null) {
663 properties.setMaximumIntegerDigits(tuple.maxIntegerDigits);
665 if (tuple.minFractionDigits != null) {
666 properties.setMinimumFractionDigits(tuple.minFractionDigits);
668 if (tuple.maxFractionDigits != null) {
669 properties.setMaximumFractionDigits(tuple.maxFractionDigits);
671 if (tuple.currency != null) {
672 properties.setCurrency(tuple.currency);
674 if (tuple.minGroupingDigits != null) {
675 properties.setMinimumGroupingDigits(tuple.minGroupingDigits);
677 if (tuple.useSigDigits != null) {
680 if (tuple.minSigDigits != null) {
681 properties.setMinimumSignificantDigits(tuple.minSigDigits);
683 if (tuple.maxSigDigits != null) {
684 properties.setMaximumSignificantDigits(tuple.maxSigDigits);
686 if (tuple.useGrouping != null) {
687 properties.setGroupingUsed(tuple.useGrouping > 0);
689 if (tuple.multiplier != null) {
690 properties.setMultiplier(new BigDecimal(tuple.multiplier));
692 if (tuple.roundingIncrement != null) {
693 properties.setRoundingIncrement(new BigDecimal(tuple.roundingIncrement.toString()));
695 if (tuple.formatWidth != null) {
696 properties.setFormatWidth(tuple.formatWidth);
698 if (tuple.padCharacter != null && tuple.padCharacter.length() > 0) {
699 properties.setPadString(tuple.padCharacter.toString());
701 if (tuple.useScientific != null) {
702 properties.setMinimumExponentDigits(tuple.useScientific != 0 ? 1 : -1);
704 if (tuple.grouping != null) {
705 properties.setGroupingSize(tuple.grouping);
707 if (tuple.grouping2 != null) {
708 properties.setSecondaryGroupingSize(tuple.grouping2);
710 if (tuple.roundingMode != null) {
711 properties.setRoundingMode(RoundingMode.valueOf(tuple.roundingMode));
713 if (tuple.currencyUsage != null) {
714 properties.setCurrencyUsage(tuple.currencyUsage);
716 if (tuple.minimumExponentDigits != null) {
717 properties.setMinimumExponentDigits(tuple.minimumExponentDigits.byteValue());
719 if (tuple.exponentSignAlwaysShown != null) {
720 properties.setExponentSignAlwaysShown(tuple.exponentSignAlwaysShown != 0);
722 if (tuple.decimalSeparatorAlwaysShown != null) {
723 properties.setDecimalSeparatorAlwaysShown(tuple.decimalSeparatorAlwaysShown != 0);
725 if (tuple.padPosition != null) {
726 properties.setPadPosition(PadPosition.fromOld(tuple.padPosition));
728 if (tuple.positivePrefix != null) {
729 properties.setPositivePrefix(tuple.positivePrefix);
731 if (tuple.positiveSuffix != null) {
732 properties.setPositiveSuffix(tuple.positiveSuffix);
734 if (tuple.negativePrefix != null) {
735 properties.setNegativePrefix(tuple.negativePrefix);
737 if (tuple.negativeSuffix != null) {
738 properties.setNegativeSuffix(tuple.negativeSuffix);
740 if (tuple.signAlwaysShown != null) {
741 properties.setSignAlwaysShown(tuple.signAlwaysShown != 0);
743 if (tuple.localizedPattern != null) {
744 DecimalFormatSymbols symbols = DecimalFormatSymbols.getInstance(tuple.locale);
746 .convertLocalized(tuple.localizedPattern, symbols, false);
749 if (tuple.lenient != null) {
750 properties.setParseMode(tuple.lenient == 0 ? ParseMode.STRICT : ParseMode.LENIENT);
752 if (tuple.parseIntegerOnly != null) {
753 properties.setParseIntegerOnly(tuple.parseIntegerOnly != 0);
755 if (tuple.parseCaseSensitive != null) {
756 properties.setParseCaseSensitive(tuple.parseCaseSensitive != 0);
758 if (tuple.decimalPatternMatchRequired != null) {
759 properties.setDecimalPatternMatchRequired(tuple.decimalPatternMatchRequired != 0);
761 if (tuple.parseNoExponent != null) {
762 properties.setParseNoExponent(tuple.parseNoExponent != 0);
781 * @param tuple
785 public String format(DataDrivenNumberFormatTestData tuple) {
786 String pattern = (tuple.pattern == null) ? "0" : tuple.pattern;
787 ULocale locale = (tuple.locale == null) ? ULocale.ENGLISH : tuple.locale;
789 tuple.currency != null ? PatternStringParser.IGNORE_ROUNDING_ALWAYS
791 propertiesFromTuple(tuple, properties);
795 tuple.format);
796 String expected = tuple.output;
808 * @param tuple
812 public String toPattern(DataDrivenNumberFormatTestData tuple) {
813 String pattern = (tuple.pattern == null) ? "0" : tuple.pattern;
818 tuple.currency != null ? PatternStringParser.IGNORE_ROUNDING_ALWAYS
820 propertiesFromTuple(tuple, properties);
835 if (tuple.toPattern != null) {
836 String expected = tuple.toPattern;
842 if (tuple.toLocalizedPattern != null) {
843 String expected = tuple.toLocalizedPattern;
853 public String parse(DataDrivenNumberFormatTestData tuple) {
854 String pattern = (tuple.pattern == null) ? "0" : tuple.pattern;
860 tuple.currency != null ? PatternStringParser.IGNORE_ROUNDING_ALWAYS
862 propertiesFromTuple(tuple, properties);
863 actual = NumberParserImpl.parseStatic(tuple.parse,
866 DecimalFormatSymbols.getInstance(tuple.locale));
870 return compareParseResult(tuple.output, actual, ppos);
874 public String parseCurrency(DataDrivenNumberFormatTestData tuple) {
875 String pattern = (tuple.pattern == null) ? "0" : tuple.pattern;
881 tuple.currency != null ? PatternStringParser.IGNORE_ROUNDING_ALWAYS
883 propertiesFromTuple(tuple, properties);
884 actual = NumberParserImpl.parseStaticCurrency(tuple.parse,
887 DecimalFormatSymbols.getInstance(tuple.locale));
892 return compareParseCurrencyResult(tuple.output, tuple.outputCurrency, actual, ppos);