freemarker-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ddek...@apache.org
Subject [15/16] incubator-freemarker git commit: The extended decimal format options don't use abbreviations anymore. Like instead of rnd=hu, now there's roundingMode=halfUp.
Date Sun, 04 Oct 2015 19:17:19 GMT
The extended decimal format options don't use abbreviations anymore. Like instead of rnd=hu,
now there's roundingMode=halfUp.


Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/8adee326
Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/8adee326
Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/8adee326

Branch: refs/heads/2.3
Commit: 8adee326161c928aaa02525bc84b7293d86262cd
Parents: 1e905a4
Author: ddekany <ddekany@apache.org>
Authored: Sun Oct 4 16:44:42 2015 +0200
Committer: ddekany <ddekany@apache.org>
Committed: Sun Oct 4 21:14:09 2015 +0200

----------------------------------------------------------------------
 .../core/ExtendedDecimalFormatParser.java       |  44 +++---
 src/manual/book.xml                             | 150 +++++++++++--------
 .../core/ExtendedDecimalFormatTest.java         | 139 +++++++++--------
 3 files changed, 188 insertions(+), 145 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/8adee326/src/main/java/freemarker/core/ExtendedDecimalFormatParser.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/ExtendedDecimalFormatParser.java b/src/main/java/freemarker/core/ExtendedDecimalFormatParser.java
index 76484cf..8824531 100644
--- a/src/main/java/freemarker/core/ExtendedDecimalFormatParser.java
+++ b/src/main/java/freemarker/core/ExtendedDecimalFormatParser.java
@@ -32,29 +32,29 @@ import freemarker.template.utility.StringUtil;
 
 class ExtendedDecimalFormatParser {
     
-    private static final String PARAM_ROUNDING_MODE = "rnd";
-    private static final String PARAM_MULTIPIER = "mul";
-    private static final String PARAM_DECIMAL_SEPARATOR = "dec";
-    private static final String PARAM_MONETARY_DECIMAL_SEPARATOR = "mdec";
-    private static final String PARAM_GROUP_SEPARATOR = "grp";
-    private static final String PARAM_EXPONENT_SEPARATOR = "exp";
-    private static final String PARAM_MINUS_SIGN = "min";
-    private static final String PARAM_INFINITY = "inf";
+    private static final String PARAM_ROUNDING_MODE = "roundingMode";
+    private static final String PARAM_MULTIPIER = "multipier";
+    private static final String PARAM_DECIMAL_SEPARATOR = "decimalSeparator";
+    private static final String PARAM_MONETARY_DECIMAL_SEPARATOR = "monetaryDecimalSeparator";
+    private static final String PARAM_GROUP_SEPARATOR = "groupingSeparator";
+    private static final String PARAM_EXPONENT_SEPARATOR = "exponentSeparator";
+    private static final String PARAM_MINUS_SIGN = "minusSign";
+    private static final String PARAM_INFINITY = "infinity";
     private static final String PARAM_NAN = "nan";
-    private static final String PARAM_PERCENT = "prc";
-    private static final String PARAM_PER_MILL = "prm";
-    private static final String PARAM_ZERO_DIGIT = "zero";
-    private static final String PARAM_CURRENCY_CODE = "curc";
-    private static final String PARAM_CURRENCY_SYMBOL = "curs";
-
-    private static final String PARAM_VALUE_RND_UP = "u";
-    private static final String PARAM_VALUE_RND_DOWN = "d";
-    private static final String PARAM_VALUE_RND_CEILING = "c";
-    private static final String PARAM_VALUE_RND_FLOOR = "f";
-    private static final String PARAM_VALUE_RND_HALF_DOWN = "hd";
-    private static final String PARAM_VALUE_RND_HALF_EVEN = "he";
-    private static final String PARAM_VALUE_RND_HALF_UP = "hu";
-    private static final String PARAM_VALUE_RND_UNNECESSARY = "un";
+    private static final String PARAM_PERCENT = "percent";
+    private static final String PARAM_PER_MILL = "perMill";
+    private static final String PARAM_ZERO_DIGIT = "zeroDigit";
+    private static final String PARAM_CURRENCY_CODE = "currencyCode";
+    private static final String PARAM_CURRENCY_SYMBOL = "currencySymbol";
+
+    private static final String PARAM_VALUE_RND_UP = "up";
+    private static final String PARAM_VALUE_RND_DOWN = "down";
+    private static final String PARAM_VALUE_RND_CEILING = "ceiling";
+    private static final String PARAM_VALUE_RND_FLOOR = "floor";
+    private static final String PARAM_VALUE_RND_HALF_DOWN = "halfDown";
+    private static final String PARAM_VALUE_RND_HALF_EVEN = "halfEven";
+    private static final String PARAM_VALUE_RND_HALF_UP = "halfUp";
+    private static final String PARAM_VALUE_RND_UNNECESSARY = "unnecessary";
     
     private static final HashMap<String, ? extends ParameterHandler> PARAM_HANDLERS;
     static {

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/8adee326/src/manual/book.xml
----------------------------------------------------------------------
diff --git a/src/manual/book.xml b/src/manual/book.xml
index 75aa34d..da26c70 100644
--- a/src/manual/book.xml
+++ b/src/manual/book.xml
@@ -14550,15 +14550,17 @@ German people write: 12.345.678,00</programlisting>
             0.0"</literal>), the after only one semicolon. For example:</para>
 
             <programlisting role="template">Standard decimal format: ${10002.5?string[",000"]}
-Extended decimal format: ${10002.5?string[",000<emphasis>;; rnd=hu grp=_</emphasis>"]}</programlisting>
+Extended decimal format: ${10002.5?string[",000<emphasis>;; roundingMode=halfUp groupingSeparator=_</emphasis>"]}</programlisting>
 
             <programlisting role="output">Standard decimal format: 10,002
 Extended decimal format: 10<emphasis>_</emphasis>00<emphasis>3</emphasis></programlisting>
 
             <para>Above, in the extended decimal format, we have specified
-            half-up rounding mode (<literal>rnd=hu</literal>), and group
-            separator <literal>"_"</literal> (<literal>grp=_</literal>).
The
-            table of all options:</para>
+            half-up rounding mode and group separator <literal>"_"</literal>.
+            The table of all options follows (note that these are defined by
+            <literal>java.text.DecimalFormat</literal> and
+            <literal>java.text.DecimalFormatSymbols</literal>, not by
+            FreeMarker):</para>
 
             <informaltable border="1">
               <thead>
@@ -14571,101 +14573,120 @@ Extended decimal format: 10<emphasis>_</emphasis>00<emphasis>3</emphasis></progr
 
               <tbody>
                 <tr>
-                  <td><literal>rnd</literal></td>
-
-                  <td>Rounding mode. The value is one of <literal>u</literal>
-                  for up, <literal>d</literal> for down, <literal>c</literal>
-                  for ceiling, <literal>f</literal> for floor,
-                  <literal>hu</literal> for half-up, <literal>hd</literal>
for
-                  half-down, <literal>he</literal> for half-even, and
-                  <literal>un</literal> for unused. (See <link
+                  <td><literal>roundingMode</literal></td>
+
+                  <td>The value is one of <literal>up</literal>,
+                  <literal>down</literal>, <literal>ceiling</literal>,
+                  <literal>floor</literal>, <literal>halfUp</literal>,
+                  <literal>halfDown</literal>, <literal>halfEven</literal>,
+                  and <literal>unnecessary</literal>. The behavior that most
+                  people learns in school is <literal>halfUp</literal>, but
+                  the Java default is <literal>halfEven</literal> (also called
+                  bankers' rounding). (See <link
                   xlink:href="http://docs.oracle.com/javase/7/docs/api/java/math/RoundingMode.html">the
                   <literal>java.math.RoundingMode</literal> API</link>
for
                   explanations.)</td>
                 </tr>
 
                 <tr>
-                  <td><literal>mul</literal></td>
+                  <td><literal>multipier</literal></td>
 
-                  <td>Multiplier. The number will be shown after multiplied
-                  with this integer number.</td>
+                  <td>The number will be shown after multiplied with this
+                  integer number.</td>
                 </tr>
 
                 <tr>
-                  <td><literal>dec</literal></td>
+                  <td><literal>decimalSeparator</literal></td>
 
-                  <td>Decimal separator character (like <literal>"."</literal>
-                  in <literal>3.14</literal>).</td>
+                  <td>The character separating the integer part from the
+                  fraction part (like <literal>"."</literal> in
+                  <literal>3.14</literal>).</td>
                 </tr>
 
                 <tr>
-                  <td><literal>mdec</literal></td>
+                  <td><literal>monetaryDecimalSeparator</literal></td>
 
-                  <td>Monetary decimal separator character. This is used
-                  instead of <literal>dec</literal> when the pattern contains
-                  parts that make it a monetary format. (See the <link
+                  <td>This is used instead of
+                  <literal>decimalSeparator</literal> when the pattern
+                  contains parts that make it a monetary format. (See the
+                  <link
                   xlink:href="http://docs.oracle.com/javase/7/docs/api/java/text/DecimalFormat.html">Java
                   decimal number format documentation</link> for more.)</td>
                 </tr>
 
                 <tr>
-                  <td><literal>grp</literal></td>
-
-                  <td>Grouping separator character. Note that grouping is
-                  turned on by using <literal>","</literal> in the pattern, as
-                  shown in the earlier example. If it's not turned on, this
-                  option won't have visible effect.</td>
+                  <td><literal>groupingSeparator</literal></td>
+
+                  <td>The single character used for grouping the integer part
+                  (like <literal>","</literal> in
+                  <literal>1,000,000</literal>) Note that grouping is turned
+                  on by using <literal>","</literal> in the pattern, as shown
+                  in the earlier example. If it's not turned on, this option
+                  won't have visible effect.</td>
                 </tr>
 
                 <tr>
-                  <td><literal>exp</literal></td>
+                  <td><literal>exponentSeparator</literal></td>
 
-                  <td>Exponent separator string. Only has visible effect if
-                  the pattern specifies exponential form, like
+                  <td>This string (of arbitrary length) is used to separate
+                  the exponent from the part before it. (like
+                  <literal>"E"</literal> in <literal>1.23E6</literal>).
Only
+                  has visible effect if the pattern specifies exponential
+                  (also known as scientific) format, like
                   <literal>"0.##E0"</literal>.</td>
                 </tr>
 
                 <tr>
-                  <td><literal>min</literal></td>
+                  <td><literal>minusSign</literal></td>
 
-                  <td>Minus sign character.</td>
+                  <td>The single character used as minus sign (like
+                  <literal>"-"</literal> in <literal>-1</literal>).</td>
                 </tr>
 
                 <tr>
-                  <td><literal>inf</literal></td>
+                  <td><literal>infinity</literal></td>
 
-                  <td>The string used to show infinity.</td>
+                  <td>The string (of arbitrary length) used to show
+                  infinity.</td>
                 </tr>
 
                 <tr>
                   <td><literal>nan</literal></td>
 
-                  <td>The string used to show not-a-number (NaN).</td>
+                  <td>The string (of arbitrary length) used to show
+                  not-a-number (NaN).</td>
                 </tr>
 
                 <tr>
-                  <td><literal>prc</literal></td>
+                  <td><literal>percent</literal></td>
 
-                  <td>Percent character.</td>
+                  <td>The single character used as the percent symbol (like
+                  <literal>"%"</literal> in <literal>50%</literal>).
Only has
+                  visible effect if the pattern contains
+                  <literal>%</literal>.</td>
                 </tr>
 
                 <tr>
-                  <td><literal>prm</literal></td>
+                  <td><literal>perMill</literal></td>
 
-                  <td>Per-mill character.</td>
+                  <td>The single character used as the per-mill symbol (like
+                  <literal>"‰"</literal> in <literal>50021‰</literal>).
Only
+                  has visible effect if the pattern contains
+                  <literal>‰</literal>.</td>
                 </tr>
 
                 <tr>
-                  <td><literal>zero</literal></td>
+                  <td><literal>zeroDigit</literal></td>
 
-                  <td>Zero character. This modifies the other digits too, for
-                  example, if zero is <literal>A</literal>, then 1 will
+                  <td>The first character in the 10 character range (of
+                  character codes) that contains the digits to be used. For
+                  example, if this is <literal>A</literal>, then 1 will
                   <literal>B</literal>, 2 will be <literal>C</literal>,
and so
                   on.</td>
                 </tr>
 
                 <tr>
-                  <td><literal>curc</literal></td>
+                  <td><literal>currencyCode</literal></td>
 
                   <td>Currency ISO 4217 code. Only has effect when the pattern
                   contains parts that make it a monetary format. It's an error
@@ -14674,11 +14695,11 @@ Extended decimal format: 10<emphasis>_</emphasis>00<emphasis>3</emphasis></progr
                 </tr>
 
                 <tr>
-                  <td><literal>curs</literal></td>
+                  <td><literal>currencySymbol</literal></td>
 
                   <td>Currency symbol; shown where the localized currency name
                   is present in the pattern. Overrides the symbol determined
-                  from <literal>curc</literal>.</td>
+                  based on the <literal>currencyCode</literal>.</td>
                 </tr>
               </tbody>
             </informaltable>
@@ -14699,19 +14720,23 @@ Extended decimal format: 10<emphasis>_</emphasis>00<emphasis>3</emphasis></progr
               <listitem>
                 <para>The option value can be quoted with apostrophe
                 (<literal>'</literal>) or normal quotation mark
-                (<literal>"</literal>) , like <literal>exp='*10^'</literal>
or
-                <literal>exp="*10^"</literal>. If the value itself has to
-                contain the character used for quotation, then it has to be
-                entered twice (like <literal>inf='It''s infinite'</literal>,
-                but you could also write <literal>inf="It's
-                infinite"</literal>). Backslash has no special meaning.</para>
+                (<literal>"</literal>) , like
+                <literal>exponentSeparator='*10^'</literal> or
+                <literal>exponentSeparator="*10^"</literal>. If the value
+                itself has to contain the character used for quotation, then
+                it has to be entered twice (like <literal>infinity='It''s
+                infinite'</literal>, but you could also write
+                <literal>infinity="It's infinite"</literal>). Backslash has no
+                special meaning.</para>
               </listitem>
 
               <listitem>
                 <para>Non-string values must not be quoted. Strings only has
                 to be quoted if they contain punctuation or whitespace, or any
                 other non-letter non-digit non-<literal>"_"</literal>
-                non-<literal>"$"</literal> characters.</para>
+                non-<literal>"$"</literal> characters. Thus, for example, both
+                <literal>roundingMode=down</literal> and
+                <literal>roundingMode="down"</literal> are legal.</para>
               </listitem>
             </itemizedlist>
           </simplesect>
@@ -25822,12 +25847,12 @@ TemplateModel x = env.getVariable("x");  // get variable x</programlisting>
             </listitem>
 
             <listitem>
-              <para><emphasis>Attention!</emphasis> FreeMarker's JSP support
-              (if it's used) now requires at least JSP 2.0. Earlier it only
-              required JSP 1.1. (Reason: The <literal>jsp-api</literal>
-              dependency for JSP 1.x, which was needed for building, can't be
-              legally present in the Maven Central Repository, nor be provided
-              by freemarker.org.)</para>
+              <para><emphasis role="strong">Attention!</emphasis> FreeMarker's
+              JSP support (if it's used) now requires at least JSP 2.0.
+              Earlier it only required JSP 1.1. (Reason: The
+              <literal>jsp-api</literal> dependency for JSP 1.x, which was
+              needed for building, can't be legally present in the Maven
+              Central Repository, nor be provided by freemarker.org.)</para>
             </listitem>
 
             <listitem>
@@ -26277,6 +26302,13 @@ TemplateModel x = env.getVariable("x");  // get variable x</programlisting>
             </listitem>
 
             <listitem>
+              <para>The extended decimal format options don't use
+              abbreviations anymore. Like instead of
+              <literal>rnd=hu</literal>, now there's
+              <literal>roundingMode=halfUp</literal>.</para>
+            </listitem>
+
+            <listitem>
               <para>Added <literal>XHTMLOutputFormat</literal> and
               <literal>TemplateXHTMLOutputModel</literal>.</para>
             </listitem>

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/8adee326/src/test/java/freemarker/core/ExtendedDecimalFormatTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/freemarker/core/ExtendedDecimalFormatTest.java b/src/test/java/freemarker/core/ExtendedDecimalFormatTest.java
index d53fc84..264c1ea 100644
--- a/src/test/java/freemarker/core/ExtendedDecimalFormatTest.java
+++ b/src/test/java/freemarker/core/ExtendedDecimalFormatTest.java
@@ -107,84 +107,89 @@ public class ExtendedDecimalFormatTest extends TemplateTest {
     @Test
     public void testExtendedParamsParsing() throws ParseException {
         for (String fs : new String[] {
-                "00.##;; dec='D'", "00.##;;dec=D", "00.##;;  dec  =  D ", "00.##;; dec =
'D' " }) {
+                "00.##;; decimalSeparator='D'",
+                "00.##;;decimalSeparator=D",
+                "00.##;;  decimalSeparator  =  D ", "00.##;; decimalSeparator = 'D' " })
{
             assertFormatted(fs, 1.125, "01D12");
         }
         for (String fs : new String[] {
-                ",#0.0;; dec=D, grp=_", ",#0.0;;dec=D,grp=_", ",#0.0;; dec = D , grp = _
", ",#0.0;; dec='D', grp='_'"
+                ",#0.0;; decimalSeparator=D, groupingSeparator=_",
+                ",#0.0;;decimalSeparator=D,groupingSeparator=_",
+                ",#0.0;; decimalSeparator = D , groupingSeparator = _ ",
+                ",#0.0;; decimalSeparator='D', groupingSeparator='_'"
                 }) {
             assertFormatted(fs, 12345, "1_23_45D0");
         }
         
-        assertFormatted("0.0;;inf=infinity", Double.POSITIVE_INFINITY, "infinity");
-        assertFormatted("0.0;;inf='infinity'", Double.POSITIVE_INFINITY, "infinity");
-        assertFormatted("0.0;;inf=\"infinity\"", Double.POSITIVE_INFINITY, "infinity");
-        assertFormatted("0.0;;inf=''", Double.POSITIVE_INFINITY, "");
-        assertFormatted("0.0;;inf=\"\"", Double.POSITIVE_INFINITY, "");
-        assertFormatted("0.0;;inf='x''y'", Double.POSITIVE_INFINITY, "x'y");
-        assertFormatted("0.0;;inf=\"x'y\"", Double.POSITIVE_INFINITY, "x'y");
-        assertFormatted("0.0;;inf='x\"\"y'", Double.POSITIVE_INFINITY, "x\"\"y");
-        assertFormatted("0.0;;inf=\"x''y\"", Double.POSITIVE_INFINITY, "x''y");
-        assertFormatted("0.0;;dec=''''", 1, "1'0");
-        assertFormatted("0.0;;dec=\"'\"", 1, "1'0");
-        assertFormatted("0.0;;dec='\"'", 1, "1\"0");
-        assertFormatted("0.0;;dec=\"\"\"\"", 1, "1\"0");
+        assertFormatted("0.0;;infinity=infinity", Double.POSITIVE_INFINITY, "infinity");
+        assertFormatted("0.0;;infinity='infinity'", Double.POSITIVE_INFINITY, "infinity");
+        assertFormatted("0.0;;infinity=\"infinity\"", Double.POSITIVE_INFINITY, "infinity");
+        assertFormatted("0.0;;infinity=''", Double.POSITIVE_INFINITY, "");
+        assertFormatted("0.0;;infinity=\"\"", Double.POSITIVE_INFINITY, "");
+        assertFormatted("0.0;;infinity='x''y'", Double.POSITIVE_INFINITY, "x'y");
+        assertFormatted("0.0;;infinity=\"x'y\"", Double.POSITIVE_INFINITY, "x'y");
+        assertFormatted("0.0;;infinity='x\"\"y'", Double.POSITIVE_INFINITY, "x\"\"y");
+        assertFormatted("0.0;;infinity=\"x''y\"", Double.POSITIVE_INFINITY, "x''y");
+        assertFormatted("0.0;;decimalSeparator=''''", 1, "1'0");
+        assertFormatted("0.0;;decimalSeparator=\"'\"", 1, "1'0");
+        assertFormatted("0.0;;decimalSeparator='\"'", 1, "1\"0");
+        assertFormatted("0.0;;decimalSeparator=\"\"\"\"", 1, "1\"0");
         
         try {
-            ExtendedDecimalFormatParser.parse(";;dec=D,", LOC);
+            ExtendedDecimalFormatParser.parse(";;decimalSeparator=D,", LOC);
             fail();
         } catch (java.text.ParseException e) {
             assertThat(e.getMessage(),
                     allOf(containsStringIgnoringCase("expected a(n) name"), containsString("
end of ")));
         }
         try {
-            ExtendedDecimalFormatParser.parse(";;xdec=D,", LOC);
+            ExtendedDecimalFormatParser.parse(";;foo=D,", LOC);
             fail();
         } catch (java.text.ParseException e) {
             assertThat(e.getMessage(),
-                    allOf(containsString("\"xdec\""), containsString("name")));
+                    allOf(containsString("\"foo\""), containsString("name")));
         }
         try {
-            ExtendedDecimalFormatParser.parse(";;dec='D", LOC);
+            ExtendedDecimalFormatParser.parse(";;decimalSeparator='D", LOC);
             fail();
         } catch (java.text.ParseException e) {
             assertThat(e.getMessage(),
                     allOf(containsString("quotation"), containsString("closed")));
         }
         try {
-            ExtendedDecimalFormatParser.parse(";;dec=\"D", LOC);
+            ExtendedDecimalFormatParser.parse(";;decimalSeparator=\"D", LOC);
             fail();
         } catch (java.text.ParseException e) {
             assertThat(e.getMessage(),
                     allOf(containsString("quotation"), containsString("closed")));
         }
         try {
-            ExtendedDecimalFormatParser.parse(";;dec='D'grp=G", LOC);
+            ExtendedDecimalFormatParser.parse(";;decimalSeparator='D'groupingSeparator=G",
LOC);
             fail();
         } catch (java.text.ParseException e) {
             assertThat(e.getMessage(), allOf(
                     containsString("separator"), containsString("whitespace"), containsString("comma")));
         }
         try {
-            ExtendedDecimalFormatParser.parse(";;dec=., grp=G", LOC);
+            ExtendedDecimalFormatParser.parse(";;decimalSeparator=., groupingSeparator=G",
LOC);
             fail();
         } catch (java.text.ParseException e) {
             assertThat(e.getMessage(), allOf(
-                    containsStringIgnoringCase("expected a(n) value"), containsString(".,
grp")));
+                    containsStringIgnoringCase("expected a(n) value"), containsString(".,
gr[...]")));
         }
         try {
-            ExtendedDecimalFormatParser.parse("0.0;;dec=''", LOC);
+            ExtendedDecimalFormatParser.parse("0.0;;decimalSeparator=''", LOC);
             fail();
         } catch (java.text.ParseException e) {
             assertThat(e.getMessage(), allOf(
-                    containsStringIgnoringCase("\"dec\""), containsString("exactly 1 char")));
+                    containsStringIgnoringCase("\"decimalSeparator\""), containsString("exactly
1 char")));
         }
         try {
-            ExtendedDecimalFormatParser.parse("0.0;;mul=ten", LOC);
+            ExtendedDecimalFormatParser.parse("0.0;;multipier=ten", LOC);
             fail();
         } catch (java.text.ParseException e) {
             assertThat(e.getMessage(), allOf(
-                    containsString("\"mul\""), containsString("\"ten\""), containsString("integer")));
+                    containsString("\"multipier\""), containsString("\"ten\""), containsString("integer")));
         }
     }
     
@@ -193,71 +198,77 @@ public class ExtendedDecimalFormatTest extends TemplateTest {
     public void testExtendedParamsEffect() throws ParseException {
         assertFormatted("0",
                 1.5, "2", 2.5, "2", 3.5, "4", 1.4, "1", 1.6, "2", -1.4, "-1", -1.5, "-2",
-2.5, "-2", -1.6, "-2");
-        assertFormatted("0;; rnd=he",
+        assertFormatted("0;; roundingMode=halfEven",
                 1.5, "2", 2.5, "2", 3.5, "4", 1.4, "1", 1.6, "2", -1.4, "-1", -1.5, "-2",
-2.5, "-2", -1.6, "-2");
-        assertFormatted("0;; rnd=hu",
+        assertFormatted("0;; roundingMode=halfUp",
                 1.5, "2", 2.5, "3", 3.5, "4", 1.4, "1", 1.6, "2", -1.4, "-1", -1.5, "-2",
-2.5, "-3", -1.6, "-2");
-        assertFormatted("0;; rnd=hd",
+        assertFormatted("0;; roundingMode=halfDown",
                 1.5, "1", 2.5, "2", 3.5, "3", 1.4, "1", 1.6, "2", -1.4, "-1", -1.5, "-1",
-2.5, "-2", -1.6, "-2");
-        assertFormatted("0;; rnd=f",
+        assertFormatted("0;; roundingMode=floor",
                 1.5, "1", 2.5, "2", 3.5, "3", 1.4, "1", 1.6, "1", -1.4, "-2", -1.5, "-2",
-2.5, "-3", -1.6, "-2");
-        assertFormatted("0;; rnd=c",
+        assertFormatted("0;; roundingMode=ceiling",
                 1.5, "2", 2.5, "3", 3.5, "4", 1.4, "2", 1.6, "2", -1.4, "-1", -1.5, "-1",
-2.5, "-2", -1.6, "-1");
-        assertFormatted("0;; rnd=un", 2, "2");
+        assertFormatted("0;; roundingMode=up",
+                1.5, "2", 2.5, "3", 3.5, "4", 1.4, "2", 1.6, "2", -1.4, "-2", -1.5, "-2",
-2.5, "-3", -1.6, "-2");
+        assertFormatted("0;; roundingMode=down",
+                1.5, "1", 2.5, "2", 3.5, "3", 1.4, "1", 1.6, "1", -1.4, "-1", -1.5, "-1",
-2.5, "-2", -1.6, "-1");
+        assertFormatted("0;; roundingMode=unnecessary", 2, "2");
         try {
-            assertFormatted("0;; rnd=un", 2.5, "2");
+            assertFormatted("0;; roundingMode=unnecessary", 2.5, "2");
             fail();
         } catch (ArithmeticException e) {
             // Expected
         }
 
-        assertFormatted("0.##;; mul=100", 12.345, "1234.5");
-        assertFormatted("0.##;; mul=1000", 12.345, "12345");
+        assertFormatted("0.##;; multipier=100", 12.345, "1234.5");
+        assertFormatted("0.##;; multipier=1000", 12.345, "12345");
         
-        assertFormatted(",##0.##;; grp=_ dec=D", 12345.1, "12_345D1", 1, "1");
+        assertFormatted(",##0.##;; groupingSeparator=_ decimalSeparator=D", 12345.1, "12_345D1",
1, "1");
         
-        assertFormatted("0.##E0;; exp='*10^'", 12345.1, "1.23*10^4");
+        assertFormatted("0.##E0;; exponentSeparator='*10^'", 12345.1, "1.23*10^4");
         
-        assertFormatted("0.##;; min=m", -1, "m1", 1, "1");
+        assertFormatted("0.##;; minusSign=m", -1, "m1", 1, "1");
         
-        assertFormatted("0.##;; inf=foo", Double.POSITIVE_INFINITY, "foo", Double.NEGATIVE_INFINITY,
"-foo");
+        assertFormatted("0.##;; infinity=foo", Double.POSITIVE_INFINITY, "foo", Double.NEGATIVE_INFINITY,
"-foo");
         
         assertFormatted("0.##;; nan=foo", Double.NaN, "foo");
         
-        assertFormatted("0%;; prc='c'", 0.75, "75c");
+        assertFormatted("0%;; percent='c'", 0.75, "75c");
         
-        assertFormatted("0\u2030;; prm='m'", 0.75, "750m");
+        assertFormatted("0\u2030;; perMill='m'", 0.75, "750m");
         
-        assertFormatted("0.00;; zero='@'", 10.5, "A@.E@");
+        assertFormatted("0.00;; zeroDigit='@'", 10.5, "A@.E@");
         
-        assertFormatted("0;; curc=USD", 10, "10");
-        assertFormatted("0 \u00A4;; curc=USD", 10, "10 $");
-        assertFormatted("0 \u00A4\u00A4;; curc=USD", 10, "10 USD");
-        assertFormatted(Locale.GERMANY, "0 \u00A4;; curc=EUR", 10, "10 \u20AC");
-        assertFormatted(Locale.GERMANY, "0 \u00A4\u00A4;; curc=EUR", 10, "10 EUR");
+        assertFormatted("0;; currencyCode=USD", 10, "10");
+        assertFormatted("0 \u00A4;; currencyCode=USD", 10, "10 $");
+        assertFormatted("0 \u00A4\u00A4;; currencyCode=USD", 10, "10 USD");
+        assertFormatted(Locale.GERMANY, "0 \u00A4;; currencyCode=EUR", 10, "10 \u20AC");
+        assertFormatted(Locale.GERMANY, "0 \u00A4\u00A4;; currencyCode=EUR", 10, "10 EUR");
         try {
-            assertFormatted("0;; curc=USDX", 10, "10");
+            assertFormatted("0;; currencyCode=USDX", 10, "10");
         } catch (ParseException e) {
             assertThat(e.getMessage(), containsString("ISO 4217"));
         }
-        assertFormatted("0 \u00A4;; curc=USD curs=bucks", 10, "10 bucks");
-        assertFormatted("0 \u00A4;; curs=bucks curc=USD", 10, "10 bucks"); // Order doesn't
mater
-        assertFormatted("0 \u00A4\u00A4;; curc=USD curs=bucks", 10, "10 USD"); // International
symbol isn't affected
+        assertFormatted("0 \u00A4;; currencyCode=USD currencySymbol=bucks", 10, "10 bucks");
+     // Order doesn't mater:
+        assertFormatted("0 \u00A4;; currencySymbol=bucks currencyCode=USD", 10, "10 bucks");
+        // International symbol isn't affected:
+        assertFormatted("0 \u00A4\u00A4;; currencyCode=USD currencySymbol=bucks", 10, "10
USD");
         
-        assertFormatted("0.0 \u00A4;; mdec=m", 10.5, "10m5 $");
-        assertFormatted("0.0 kg;; mdec=m", 10.5, "10.5 kg");
-        assertFormatted("0.0 \u00A4;; dec=d", 10.5, "10.5 $");
-        assertFormatted("0.0 kg;; dec=d", 10.5, "10d5 kg");
-        assertFormatted("0.0 \u00A4;; mdec=m dec=d", 10.5, "10m5 $");
-        assertFormatted("0.0 kg;; mdec=m dec=d", 10.5, "10d5 kg");
+        assertFormatted("0.0 \u00A4;; monetaryDecimalSeparator=m", 10.5, "10m5 $");
+        assertFormatted("0.0 kg;; monetaryDecimalSeparator=m", 10.5, "10.5 kg");
+        assertFormatted("0.0 \u00A4;; decimalSeparator=d", 10.5, "10.5 $");
+        assertFormatted("0.0 kg;; decimalSeparator=d", 10.5, "10d5 kg");
+        assertFormatted("0.0 \u00A4;; monetaryDecimalSeparator=m decimalSeparator=d", 10.5,
"10m5 $");
+        assertFormatted("0.0 kg;; monetaryDecimalSeparator=m decimalSeparator=d", 10.5, "10d5
kg");
     }
     
     @Test
     public void testLocale() throws ParseException {
         assertEquals("1000.0", ExtendedDecimalFormatParser.parse("0.0", Locale.US).format(1000));
         assertEquals("1000,0", ExtendedDecimalFormatParser.parse("0.0", Locale.FRANCE).format(1000));
-        assertEquals("1_000.0", ExtendedDecimalFormatParser.parse(",000.0;;grp=_", Locale.US).format(1000));
-        assertEquals("1_000,0", ExtendedDecimalFormatParser.parse(",000.0;;grp=_", Locale.FRANCE).format(1000));
+        assertEquals("1_000.0", ExtendedDecimalFormatParser.parse(",000.0;;groupingSeparator=_",
Locale.US).format(1000));
+        assertEquals("1_000,0", ExtendedDecimalFormatParser.parse(",000.0;;groupingSeparator=_",
Locale.FRANCE).format(1000));
     }
     
     @Test
@@ -267,16 +278,16 @@ public class ExtendedDecimalFormatTest extends TemplateTest {
         
         cfg.setNumberFormat(",000.#");
         assertOutput("${1000.15} ${1000.25}", "1,000.2 1,000.2");
-        cfg.setNumberFormat(",000.#;; rnd=hu grp=_");
+        cfg.setNumberFormat(",000.#;; roundingMode=halfUp groupingSeparator=_");
         assertOutput("${1000.15} ${1000.25}", "1_000.2 1_000.3");
         cfg.setLocale(Locale.GERMANY);
         assertOutput("${1000.15} ${1000.25}", "1_000,2 1_000,3");
         cfg.setLocale(Locale.US);
         assertOutput(
                 "${1000.15}; "
-                + "${1000.15?string(',##.#;;grp=\" \"')}; "
+                + "${1000.15?string(',##.#;;groupingSeparator=\" \"')}; "
                 + "<#setting locale='de_DE'>${1000.15}; "
-                + "<#setting numberFormat='0.0;;rnd=d'>${1000.15}",
+                + "<#setting numberFormat='0.0;;roundingMode=down'>${1000.15}",
                 "1_000.2; 10 00.2; 1_000,2; 1000,1");
         assertErrorContains("${1?string('#E')}",
                 TemplateException.class, "\"#E\"", "format string", "exponential");
@@ -284,7 +295,7 @@ public class ExtendedDecimalFormatTest extends TemplateTest {
                 TemplateException.class, "\"#E\"", "format string", "exponential");
         assertErrorContains("<#setting numberFormat=';;foo=bar'>${1}",
                 TemplateException.class, "\"foo\"", "supported");
-        assertErrorContains("<#setting numberFormat='0;;rnd=un'>${1.5}",
+        assertErrorContains("<#setting numberFormat='0;;roundingMode=unnecessary'>${1.5}",
                 TemplateException.class, "can't format", "1.5", "UNNECESSARY");
     }
 


Mime
View raw message