< prev index next >

src/java.base/share/classes/java/text/MessageFormat.java

Print this page




 684     }
 685 
 686     /**
 687      * Sets the format to use for the format element with the given
 688      * format element index within the previously set pattern string.
 689      * The format element index is the zero-based number of the format
 690      * element counting from the start of the pattern string.
 691      * <p>
 692      * Since the order of format elements in a pattern string often
 693      * changes during localization, it is generally better to use the
 694      * {@link #setFormatByArgumentIndex setFormatByArgumentIndex}
 695      * method, which accesses format elements based on the argument
 696      * index they specify.
 697      *
 698      * @param formatElementIndex the index of a format element within the pattern
 699      * @param newFormat the format to use for the specified format element
 700      * @exception ArrayIndexOutOfBoundsException if {@code formatElementIndex} is equal to or
 701      *            larger than the number of format elements in the pattern string
 702      */
 703     public void setFormat(int formatElementIndex, Format newFormat) {




 704         formats[formatElementIndex] = newFormat;
 705     }
 706 
 707     /**
 708      * Gets the formats used for the values passed into
 709      * <code>format</code> methods or returned from <code>parse</code>
 710      * methods. The indices of elements in the returned array
 711      * correspond to the argument indices used in the previously set
 712      * pattern string.
 713      * The order of formats in the returned array thus corresponds to
 714      * the order of elements in the <code>arguments</code> array passed
 715      * to the <code>format</code> methods or the result array returned
 716      * by the <code>parse</code> methods.
 717      * <p>
 718      * If an argument index is used for more than one format element
 719      * in the pattern string, then the format used for the last such
 720      * format element is returned in the array. If an argument index
 721      * is not used for any format element in the pattern string, then
 722      * null is returned in the array.
 723      *




 684     }
 685 
 686     /**
 687      * Sets the format to use for the format element with the given
 688      * format element index within the previously set pattern string.
 689      * The format element index is the zero-based number of the format
 690      * element counting from the start of the pattern string.
 691      * <p>
 692      * Since the order of format elements in a pattern string often
 693      * changes during localization, it is generally better to use the
 694      * {@link #setFormatByArgumentIndex setFormatByArgumentIndex}
 695      * method, which accesses format elements based on the argument
 696      * index they specify.
 697      *
 698      * @param formatElementIndex the index of a format element within the pattern
 699      * @param newFormat the format to use for the specified format element
 700      * @exception ArrayIndexOutOfBoundsException if {@code formatElementIndex} is equal to or
 701      *            larger than the number of format elements in the pattern string
 702      */
 703     public void setFormat(int formatElementIndex, Format newFormat) {
 704 
 705         if (formatElementIndex > maxOffset) {
 706             throw new ArrayIndexOutOfBoundsException(formatElementIndex);
 707         }
 708         formats[formatElementIndex] = newFormat;
 709     }
 710 
 711     /**
 712      * Gets the formats used for the values passed into
 713      * <code>format</code> methods or returned from <code>parse</code>
 714      * methods. The indices of elements in the returned array
 715      * correspond to the argument indices used in the previously set
 716      * pattern string.
 717      * The order of formats in the returned array thus corresponds to
 718      * the order of elements in the <code>arguments</code> array passed
 719      * to the <code>format</code> methods or the result array returned
 720      * by the <code>parse</code> methods.
 721      * <p>
 722      * If an argument index is used for more than one format element
 723      * in the pattern string, then the format used for the last such
 724      * format element is returned in the array. If an argument index
 725      * is not used for any format element in the pattern string, then
 726      * null is returned in the array.
 727      *


< prev index next >