@Test public void test_simple() { assertThat(format( 0, null, -1, -1), is("n")); assertThat(format( 3, null, -1, -1), is("iii")); assertThat(format(5915, null, -1, -1), is("mmmmmcmxv")); }
@Override protected int format(Appendable a, Object value, Locale locale, String flags, int precision, String formatString, int position) throws IOException { if (precision > 2) { throw FormatException.precisionTooHigh(getFormatName(), precision, 2); } int i = cast(value, Number.class).intValue(); while (i > maxVal) { a.append(maxL); i -= maxVal; } final StringBuilder sb = (a instanceof StringBuilder) ? (StringBuilder) a : new StringBuilder(); switch (precision) { case 0: if (r0 == null) throw FormatException.illegalPrecision( getFormatName() + "(zero-precision not configured)", 0, 1, 2); r0.toRoman(sb, i); break; case 2: r.toRoman2(sb, i); break; default: r.toRoman(sb, i); } if (sb != a) a.append(sb); return 0; }
RomansConversion extends FormatAlignmentBase { @Override protected int format(Appendable a, Object value, Locale locale, String flags, int precision, String formatString, int position) throws IOException { if (precision > 2) { throw FormatException.precisionTooHigh(getFormatName(), precision, 2); } int i = cast(value, Number.class).intValue(); while (i > maxVal) { a.append(maxL); i -= maxVal; } final StringBuilder sb = (a instanceof StringBuilder) ? (StringBuilder) a : new StringBuilder(); switch (precision) { case 0: if (r0 == null) throw FormatException.illegalPrecision( getFormatName() + "(zero-precision not configured)", 0, 1, 2); r0.toRoman(sb, i); break; case 2: r.toRoman2(sb, i); break; default: r.toRoman(sb, i); } if (sb != a) a.append(sb); return 0; } }
RomansConversion extends FormatAlignmentBase { @Override protected int format(Appendable a, Object value, Locale locale, String flags, int precision, String formatString, int position) throws IOException { if (precision > 2) { throw FormatException.precisionTooHigh(getFormatName(), precision, 2); } int i = cast(value, Number.class).intValue(); while (i > maxVal) { a.append(maxL); i -= maxVal; } final StringBuilder sb = (a instanceof StringBuilder) ? (StringBuilder) a : new StringBuilder(); switch (precision) { case 0: if (r0 == null) throw FormatException.illegalPrecision( getFormatName() + "(zero-precision not configured)", 0, 1, 2); r0.toRoman(sb, i); break; case 2: r.toRoman2(sb, i); break; default: r.toRoman(sb, i); } if (sb != a) a.append(sb); return 0; } RomansConversion();  RomansConversion(Romans r);  RomansConversion(Romans r, Romans r0); }
RomansConversion extends FormatAlignmentBase { @Override protected int format(Appendable a, Object value, Locale locale, String flags, int precision, String formatString, int position) throws IOException { if (precision > 2) { throw FormatException.precisionTooHigh(getFormatName(), precision, 2); } int i = cast(value, Number.class).intValue(); while (i > maxVal) { a.append(maxL); i -= maxVal; } final StringBuilder sb = (a instanceof StringBuilder) ? (StringBuilder) a : new StringBuilder(); switch (precision) { case 0: if (r0 == null) throw FormatException.illegalPrecision( getFormatName() + "(zero-precision not configured)", 0, 1, 2); r0.toRoman(sb, i); break; case 2: r.toRoman2(sb, i); break; default: r.toRoman(sb, i); } if (sb != a) a.append(sb); return 0; } RomansConversion();  RomansConversion(Romans r);  RomansConversion(Romans r, Romans r0); void register(FormatterConfiguration conf); }
RomansConversion extends FormatAlignmentBase { @Override protected int format(Appendable a, Object value, Locale locale, String flags, int precision, String formatString, int position) throws IOException { if (precision > 2) { throw FormatException.precisionTooHigh(getFormatName(), precision, 2); } int i = cast(value, Number.class).intValue(); while (i > maxVal) { a.append(maxL); i -= maxVal; } final StringBuilder sb = (a instanceof StringBuilder) ? (StringBuilder) a : new StringBuilder(); switch (precision) { case 0: if (r0 == null) throw FormatException.illegalPrecision( getFormatName() + "(zero-precision not configured)", 0, 1, 2); r0.toRoman(sb, i); break; case 2: r.toRoman2(sb, i); break; default: r.toRoman(sb, i); } if (sb != a) a.append(sb); return 0; } RomansConversion();  RomansConversion(Romans r);  RomansConversion(Romans r, Romans r0); void register(FormatterConfiguration conf); static final RomansConversion INSTANCE; }