jdk/src/java.base/share/classes/java/text/MessageFormat.java
changeset 46149 b515ebc3db98
parent 45434 4582657c7260
equal deleted inserted replaced
46148:6d8e27cd2f1e 46149:b515ebc3db98
   148  *
   148  *
   149  * <table class="plain">
   149  * <table class="plain">
   150  * <caption style="display:none">Shows how FormatType and FormatStyle values map to Format instances</caption>
   150  * <caption style="display:none">Shows how FormatType and FormatStyle values map to Format instances</caption>
   151  * <thead>
   151  * <thead>
   152  *    <tr>
   152  *    <tr>
   153  *       <th id="ft" class="TableHeadingColor">FormatType
   153  *       <th scope="col" class="TableHeadingColor">FormatType
   154  *       <th id="fs" class="TableHeadingColor">FormatStyle
   154  *       <th scope="col" class="TableHeadingColor">FormatStyle
   155  *       <th id="sc" class="TableHeadingColor">Subformat Created
   155  *       <th scope="col" class="TableHeadingColor">Subformat Created
   156  * </thead>
   156  * </thead>
   157  * <tbody>
   157  * <tbody>
   158  *    <tr>
   158  *    <tr>
   159  *       <td headers="ft"><i>(none)</i>
   159  *       <th scope="row" style="text-weight: normal"><i>(none)</i>
   160  *       <td headers="fs"><i>(none)</i>
   160  *       <th scope="row" style="text-weight: normal"><i>(none)</i>
   161  *       <td headers="sc"><code>null</code>
   161  *       <td>{@code null}
   162  *    <tr>
   162  *    <tr>
   163  *       <td headers="ft" rowspan=5><code>number</code>
   163  *       <th scope="row" style="text-weight: normal" rowspan=5>{@code number}
   164  *       <td headers="fs"><i>(none)</i>
   164  *       <th scope="row" style="text-weight: normal"><i>(none)</i>
   165  *       <td headers="sc">{@link NumberFormat#getInstance(Locale) NumberFormat.getInstance}{@code (getLocale())}
   165  *       <td>{@link NumberFormat#getInstance(Locale) NumberFormat.getInstance}{@code (getLocale())}
   166  *    <tr>
   166  *    <tr>
   167  *       <td headers="fs"><code>integer</code>
   167  *       <th scope="row" style="text-weight: normal">{@code integer}
   168  *       <td headers="sc">{@link NumberFormat#getIntegerInstance(Locale) NumberFormat.getIntegerInstance}{@code (getLocale())}
   168  *       <td>{@link NumberFormat#getIntegerInstance(Locale) NumberFormat.getIntegerInstance}{@code (getLocale())}
   169  *    <tr>
   169  *    <tr>
   170  *       <td headers="fs"><code>currency</code>
   170  *       <th scope="row" style="text-weight: normal">{@code currency}
   171  *       <td headers="sc">{@link NumberFormat#getCurrencyInstance(Locale) NumberFormat.getCurrencyInstance}{@code (getLocale())}
   171  *       <td>{@link NumberFormat#getCurrencyInstance(Locale) NumberFormat.getCurrencyInstance}{@code (getLocale())}
   172  *    <tr>
   172  *    <tr>
   173  *       <td headers="fs"><code>percent</code>
   173  *       <th scope="row" style="text-weight: normal">{@code percent}
   174  *       <td headers="sc">{@link NumberFormat#getPercentInstance(Locale) NumberFormat.getPercentInstance}{@code (getLocale())}
   174  *       <td>{@link NumberFormat#getPercentInstance(Locale) NumberFormat.getPercentInstance}{@code (getLocale())}
   175  *    <tr>
   175  *    <tr>
   176  *       <td headers="fs"><i>SubformatPattern</i>
   176  *       <th scope="row" style="text-weight: normal"><i>SubformatPattern</i>
   177  *       <td headers="sc">{@code new} {@link DecimalFormat#DecimalFormat(String,DecimalFormatSymbols) DecimalFormat}{@code (subformatPattern,} {@link DecimalFormatSymbols#getInstance(Locale) DecimalFormatSymbols.getInstance}{@code (getLocale()))}
   177  *       <td>{@code new} {@link DecimalFormat#DecimalFormat(String,DecimalFormatSymbols) DecimalFormat}{@code (subformatPattern,} {@link DecimalFormatSymbols#getInstance(Locale) DecimalFormatSymbols.getInstance}{@code (getLocale()))}
   178  *    <tr>
   178  *    <tr>
   179  *       <td headers="ft" rowspan=6><code>date</code>
   179  *       <th scope="row" style="text-weight: normal" rowspan=6>{@code date}
   180  *       <td headers="fs"><i>(none)</i>
   180  *       <th scope="row" style="text-weight: normal"><i>(none)</i>
   181  *       <td headers="sc">{@link DateFormat#getDateInstance(int,Locale) DateFormat.getDateInstance}{@code (}{@link DateFormat#DEFAULT}{@code , getLocale())}
   181  *       <td>{@link DateFormat#getDateInstance(int,Locale) DateFormat.getDateInstance}{@code (}{@link DateFormat#DEFAULT}{@code , getLocale())}
   182  *    <tr>
   182  *    <tr>
   183  *       <td headers="fs"><code>short</code>
   183  *       <th scope="row" style="text-weight: normal">{@code short}
   184  *       <td headers="sc">{@link DateFormat#getDateInstance(int,Locale) DateFormat.getDateInstance}{@code (}{@link DateFormat#SHORT}{@code , getLocale())}
   184  *       <td>{@link DateFormat#getDateInstance(int,Locale) DateFormat.getDateInstance}{@code (}{@link DateFormat#SHORT}{@code , getLocale())}
   185  *    <tr>
   185  *    <tr>
   186  *       <td headers="fs"><code>medium</code>
   186  *       <th scope="row" style="text-weight: normal">{@code medium}
   187  *       <td headers="sc">{@link DateFormat#getDateInstance(int,Locale) DateFormat.getDateInstance}{@code (}{@link DateFormat#DEFAULT}{@code , getLocale())}
   187  *       <td>{@link DateFormat#getDateInstance(int,Locale) DateFormat.getDateInstance}{@code (}{@link DateFormat#DEFAULT}{@code , getLocale())}
   188  *    <tr>
   188  *    <tr>
   189  *       <td headers="fs"><code>long</code>
   189  *       <th scope="row" style="text-weight: normal">{@code long}
   190  *       <td headers="sc">{@link DateFormat#getDateInstance(int,Locale) DateFormat.getDateInstance}{@code (}{@link DateFormat#LONG}{@code , getLocale())}
   190  *       <td>{@link DateFormat#getDateInstance(int,Locale) DateFormat.getDateInstance}{@code (}{@link DateFormat#LONG}{@code , getLocale())}
   191  *    <tr>
   191  *    <tr>
   192  *       <td headers="fs"><code>full</code>
   192  *       <th scope="row" style="text-weight: normal">{@code full}
   193  *       <td headers="sc">{@link DateFormat#getDateInstance(int,Locale) DateFormat.getDateInstance}{@code (}{@link DateFormat#FULL}{@code , getLocale())}
   193  *       <td>{@link DateFormat#getDateInstance(int,Locale) DateFormat.getDateInstance}{@code (}{@link DateFormat#FULL}{@code , getLocale())}
   194  *    <tr>
   194  *    <tr>
   195  *       <td headers="fs"><i>SubformatPattern</i>
   195  *       <th scope="row" style="text-weight: normal"><i>SubformatPattern</i>
   196  *       <td headers="sc">{@code new} {@link SimpleDateFormat#SimpleDateFormat(String,Locale) SimpleDateFormat}{@code (subformatPattern, getLocale())}
   196  *       <td>{@code new} {@link SimpleDateFormat#SimpleDateFormat(String,Locale) SimpleDateFormat}{@code (subformatPattern, getLocale())}
   197  *    <tr>
   197  *    <tr>
   198  *       <td headers="ft" rowspan=6><code>time</code>
   198  *       <th scope="row" style="text-weight: normal" rowspan=6>{@code time}
   199  *       <td headers="fs"><i>(none)</i>
   199  *       <th scope="row" style="text-weight: normal"><i>(none)</i>
   200  *       <td headers="sc">{@link DateFormat#getTimeInstance(int,Locale) DateFormat.getTimeInstance}{@code (}{@link DateFormat#DEFAULT}{@code , getLocale())}
   200  *       <td>{@link DateFormat#getTimeInstance(int,Locale) DateFormat.getTimeInstance}{@code (}{@link DateFormat#DEFAULT}{@code , getLocale())}
   201  *    <tr>
   201  *    <tr>
   202  *       <td headers="fs"><code>short</code>
   202  *       <th scope="row" style="text-weight: normal">{@code short}
   203  *       <td headers="sc">{@link DateFormat#getTimeInstance(int,Locale) DateFormat.getTimeInstance}{@code (}{@link DateFormat#SHORT}{@code , getLocale())}
   203  *       <td>{@link DateFormat#getTimeInstance(int,Locale) DateFormat.getTimeInstance}{@code (}{@link DateFormat#SHORT}{@code , getLocale())}
   204  *    <tr>
   204  *    <tr>
   205  *       <td headers="fs"><code>medium</code>
   205  *       <th scope="row" style="text-weight: normal">{@code medium}
   206  *       <td headers="sc">{@link DateFormat#getTimeInstance(int,Locale) DateFormat.getTimeInstance}{@code (}{@link DateFormat#DEFAULT}{@code , getLocale())}
   206  *       <td>{@link DateFormat#getTimeInstance(int,Locale) DateFormat.getTimeInstance}{@code (}{@link DateFormat#DEFAULT}{@code , getLocale())}
   207  *    <tr>
   207  *    <tr>
   208  *       <td headers="fs"><code>long</code>
   208  *       <th scope="row" style="text-weight: normal">{@code long}
   209  *       <td headers="sc">{@link DateFormat#getTimeInstance(int,Locale) DateFormat.getTimeInstance}{@code (}{@link DateFormat#LONG}{@code , getLocale())}
   209  *       <td>{@link DateFormat#getTimeInstance(int,Locale) DateFormat.getTimeInstance}{@code (}{@link DateFormat#LONG}{@code , getLocale())}
   210  *    <tr>
   210  *    <tr>
   211  *       <td headers="fs"><code>full</code>
   211  *       <th scope="row" style="text-weight: normal">{@code full}
   212  *       <td headers="sc">{@link DateFormat#getTimeInstance(int,Locale) DateFormat.getTimeInstance}{@code (}{@link DateFormat#FULL}{@code , getLocale())}
   212  *       <td>{@link DateFormat#getTimeInstance(int,Locale) DateFormat.getTimeInstance}{@code (}{@link DateFormat#FULL}{@code , getLocale())}
   213  *    <tr>
   213  *    <tr>
   214  *       <td headers="fs"><i>SubformatPattern</i>
   214  *       <th scope="row" style="text-weight: normal"><i>SubformatPattern</i>
   215  *       <td headers="sc">{@code new} {@link SimpleDateFormat#SimpleDateFormat(String,Locale) SimpleDateFormat}{@code (subformatPattern, getLocale())}
   215  *       <td>{@code new} {@link SimpleDateFormat#SimpleDateFormat(String,Locale) SimpleDateFormat}{@code (subformatPattern, getLocale())}
   216  *    <tr>
   216  *    <tr>
   217  *       <td headers="ft"><code>choice</code>
   217  *       <th scope="row" style="text-weight: normal">{@code choice}
   218  *       <td headers="fs"><i>SubformatPattern</i>
   218  *       <th scope="row" style="text-weight: normal"><i>SubformatPattern</i>
   219  *       <td headers="sc">{@code new} {@link ChoiceFormat#ChoiceFormat(String) ChoiceFormat}{@code (subformatPattern)}
   219  *       <td>{@code new} {@link ChoiceFormat#ChoiceFormat(String) ChoiceFormat}{@code (subformatPattern)}
   220  * </tbody>
   220  * </tbody>
   221  * </table>
   221  * </table>
   222  *
   222  *
   223  * <h4>Usage Information</h4>
   223  * <h4>Usage Information</h4>
   224  *
   224  *
   774      *
   774      *
   775      * <table class="plain">
   775      * <table class="plain">
   776      * <caption style="display:none">Examples of subformat,argument,and formatted text</caption>
   776      * <caption style="display:none">Examples of subformat,argument,and formatted text</caption>
   777      * <thead>
   777      * <thead>
   778      *    <tr>
   778      *    <tr>
   779      *       <th>Subformat
   779      *       <th scope="col">Subformat
   780      *       <th>Argument
   780      *       <th scope="col">Argument
   781      *       <th>Formatted Text
   781      *       <th scope="col">Formatted Text
   782      * </thead>
   782      * </thead>
   783      * <tbody>
   783      * <tbody>
   784      *    <tr>
   784      *    <tr>
   785      *       <td><i>any</i>
   785      *       <th scope="row" style="text-weight-normal" rowspan=2><i>any</i>
   786      *       <td><i>unavailable</i>
   786      *       <th scope="row" style="text-weight-normal"><i>unavailable</i>
   787      *       <td><code>"{" + argumentIndex + "}"</code>
   787      *       <td><code>"{" + argumentIndex + "}"</code>
   788      *    <tr>
   788      *    <tr>
   789      *       <td><i>any</i>
   789      *       <th scope="row" style="text-weight-normal"><code>null</code>
   790      *       <td><code>null</code>
       
   791      *       <td><code>"null"</code>
   790      *       <td><code>"null"</code>
   792      *    <tr>
   791      *    <tr>
   793      *       <td><code>instanceof ChoiceFormat</code>
   792      *       <th scope="row" style="text-weight-normal"><code>instanceof ChoiceFormat</code>
   794      *       <td><i>any</i>
   793      *       <th scope="row" style="text-weight-normal"><i>any</i>
   795      *       <td><code>subformat.format(argument).indexOf('{') &gt;= 0 ?<br>
   794      *       <td><code>subformat.format(argument).indexOf('{') &gt;= 0 ?<br>
   796      *           (new MessageFormat(subformat.format(argument), getLocale())).format(argument) :
   795      *           (new MessageFormat(subformat.format(argument), getLocale())).format(argument) :
   797      *           subformat.format(argument)</code>
   796      *           subformat.format(argument)</code>
   798      *    <tr>
   797      *    <tr>
   799      *       <td><code>!= null</code>
   798      *       <th scope="row" style="text-weight-normal"><code>!= null</code>
   800      *       <td><i>any</i>
   799      *       <th scope="row" style="text-weight-normal"><i>any</i>
   801      *       <td><code>subformat.format(argument)</code>
   800      *       <td><code>subformat.format(argument)</code>
   802      *    <tr>
   801      *    <tr>
   803      *       <td><code>null</code>
   802      *       <th scope="row" style="text-weight-normal" rowspan=4><code>null</code>
   804      *       <td><code>instanceof Number</code>
   803      *       <th scope="row" style="text-weight-normal"><code>instanceof Number</code>
   805      *       <td><code>NumberFormat.getInstance(getLocale()).format(argument)</code>
   804      *       <td><code>NumberFormat.getInstance(getLocale()).format(argument)</code>
   806      *    <tr>
   805      *    <tr>
   807      *       <td><code>null</code>
   806      *       <th scope="row" style="text-weight-normal"><code>instanceof Date</code>
   808      *       <td><code>instanceof Date</code>
       
   809      *       <td><code>DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, getLocale()).format(argument)</code>
   807      *       <td><code>DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, getLocale()).format(argument)</code>
   810      *    <tr>
   808      *    <tr>
   811      *       <td><code>null</code>
   809      *       <th scope="row" style="text-weight-normal"><code>instanceof String</code>
   812      *       <td><code>instanceof String</code>
       
   813      *       <td><code>argument</code>
   810      *       <td><code>argument</code>
   814      *    <tr>
   811      *    <tr>
   815      *       <td><code>null</code>
   812      *       <th scope="row" style="text-weight-normal"><i>any</i>
   816      *       <td><i>any</i>
       
   817      *       <td><code>argument.toString()</code>
   813      *       <td><code>argument.toString()</code>
   818      * </tbody>
   814      * </tbody>
   819      * </table>
   815      * </table>
   820      * <p>
   816      * <p>
   821      * If <code>pos</code> is non-null, and refers to
   817      * If <code>pos</code> is non-null, and refers to