@@ -371,7 +371,7 @@ public class MessageFormat extends Format {
371371 * The constructor first sets the locale, then parses the pattern and
372372 * creates a list of subformats for the format elements contained in it.
373373 * Patterns and their interpretation are specified in the
374- * <a href="# patterns"> class description</a> .
374+ * {@linkplain ## patterns class description} .
375375 *
376376 * @param pattern the pattern for this message format
377377 * @throws IllegalArgumentException if the pattern is invalid
@@ -380,7 +380,7 @@ public class MessageFormat extends Format {
380380 */
381381 public MessageFormat (String pattern ) {
382382 this .locale = Locale .getDefault (Locale .Category .FORMAT );
383- applyPattern (pattern );
383+ applyPatternImpl (pattern );
384384 }
385385
386386 /**
@@ -389,7 +389,7 @@ public MessageFormat(String pattern) {
389389 * The constructor first sets the locale, then parses the pattern and
390390 * creates a list of subformats for the format elements contained in it.
391391 * Patterns and their interpretation are specified in the
392- * <a href="# patterns"> class description</a> .
392+ * {@linkplain ## patterns class description} .
393393 *
394394 * @implSpec The default implementation throws a
395395 * {@code NullPointerException} if {@code locale} is {@code null}
@@ -408,7 +408,7 @@ public MessageFormat(String pattern) {
408408 */
409409 public MessageFormat (String pattern , Locale locale ) {
410410 this .locale = locale ;
411- applyPattern (pattern );
411+ applyPatternImpl (pattern );
412412 }
413413
414414 /**
@@ -447,15 +447,29 @@ public Locale getLocale() {
447447 * The method parses the pattern and creates a list of subformats
448448 * for the format elements contained in it.
449449 * Patterns and their interpretation are specified in the
450- * <a href="# patterns"> class description</a> .
450+ * {@linkplain ## patterns class description} .
451451 *
452452 * @param pattern the pattern for this message format
453453 * @throws IllegalArgumentException if the pattern is invalid
454454 * @throws NullPointerException if {@code pattern} is
455455 * {@code null}
456456 */
457- @ SuppressWarnings ("fallthrough" ) // fallthrough in switch is expected, suppress it
458457 public void applyPattern (String pattern ) {
458+ applyPatternImpl (pattern );
459+ }
460+
461+ /**
462+ * Implementation of applying a pattern to this MessageFormat.
463+ * This method processes a String pattern in accordance with the MessageFormat
464+ * pattern syntax and sets the internal {@code pattern} variable as well as
465+ * populating the {@code formats} array with the subformats defined in the
466+ * pattern. See the {@linkplain ##patterns} section for further understanding
467+ * of certain special characters: "{", "}", ",". See {@linkplain
468+ * ##makeFormat(int, int, StringBuilder[])} for the implementation of setting
469+ * a subformat.
470+ */
471+ @ SuppressWarnings ("fallthrough" ) // fallthrough in switch is expected, suppress it
472+ private void applyPatternImpl (String pattern ) {
459473 StringBuilder [] segments = new StringBuilder [4 ];
460474 // Allocate only segments[SEG_RAW] here. The rest are
461475 // allocated on demand.
@@ -509,6 +523,7 @@ public void applyPattern(String pattern) {
509523 case '}' :
510524 if (braceStack == 0 ) {
511525 part = SEG_RAW ;
526+ // Set the subformat
512527 makeFormat (i , formatNumber , segments );
513528 formatNumber ++;
514529 // throw away other segments
@@ -1592,7 +1607,7 @@ private void makeFormat(int position, int offsetNumber,
15921607 formats [offsetNumber ] = newFormat ;
15931608 }
15941609
1595- private static final int findKeyword (String s , String [] list ) {
1610+ private static int findKeyword (String s , String [] list ) {
15961611 for (int i = 0 ; i < list .length ; ++i ) {
15971612 if (s .equals (list [i ]))
15981613 return i ;
@@ -1609,8 +1624,8 @@ private static final int findKeyword(String s, String[] list) {
16091624 return -1 ;
16101625 }
16111626
1612- private static final void copyAndFixQuotes (String source , int start , int end ,
1613- StringBuilder target ) {
1627+ private static void copyAndFixQuotes (String source , int start , int end ,
1628+ StringBuilder target ) {
16141629 boolean quoted = false ;
16151630
16161631 for (int i = start ; i < end ; ++i ) {
0 commit comments