--- a/src/java.base/share/classes/java/util/Locale.java Thu Oct 17 20:27:44 2019 +0100
+++ b/src/java.base/share/classes/java/util/Locale.java Thu Oct 17 20:53:35 2019 +0100
@@ -66,9 +66,9 @@
import sun.util.locale.provider.TimeZoneNameUtility;
/**
- * A <code>Locale</code> object represents a specific geographical, political,
- * or cultural region. An operation that requires a <code>Locale</code> to perform
- * its task is called <em>locale-sensitive</em> and uses the <code>Locale</code>
+ * A {@code Locale} object represents a specific geographical, political,
+ * or cultural region. An operation that requires a {@code Locale} to perform
+ * its task is called <em>locale-sensitive</em> and uses the {@code Locale}
* to tailor information for the user. For example, displaying a number
* is a locale-sensitive operation— the number should be formatted
* according to the customs and conventions of the user's native country,
@@ -81,7 +81,7 @@
* Locale Data Markup Language") BCP 47-compatible extensions for locale data
* exchange.
*
- * <p> A <code>Locale</code> object logically consists of the fields
+ * <p> A {@code Locale} object logically consists of the fields
* described below.
*
* <dl>
@@ -93,7 +93,7 @@
* alpha-2 code must be used. You can find a full list of valid
* language codes in the IANA Language Subtag Registry (search for
* "Type: language"). The language field is case insensitive, but
- * <code>Locale</code> always canonicalizes to lower case.</dd>
+ * {@code Locale} always canonicalizes to lower case.</dd>
*
* <dd>Well-formed language values have the form
* <code>[a-zA-Z]{2,8}</code>. Note that this is not the full
@@ -108,7 +108,7 @@
* <dd>ISO 15924 alpha-4 script code. You can find a full list of
* valid script codes in the IANA Language Subtag Registry (search
* for "Type: script"). The script field is case insensitive, but
- * <code>Locale</code> always canonicalizes to title case (the first
+ * {@code Locale} always canonicalizes to title case (the first
* letter is upper case and the rest of the letters are lower
* case).</dd>
*
@@ -123,7 +123,7 @@
* You can find a full list of valid country and region codes in the
* IANA Language Subtag Registry (search for "Type: region"). The
* country (region) field is case insensitive, but
- * <code>Locale</code> always canonicalizes to upper case.</dd>
+ * {@code Locale} always canonicalizes to upper case.</dd>
*
* <dd>Well-formed country/region values have
* the form <code>[a-zA-Z]{2} | [0-9]{3}</code></dd>
@@ -134,7 +134,7 @@
* <dt><a id="def_variant"><b>variant</b></a></dt>
*
* <dd>Any arbitrary value used to indicate a variation of a
- * <code>Locale</code>. Where there are two or more variant values
+ * {@code Locale}. Where there are two or more variant values
* each indicating its own semantics, these values should be ordered
* by importance, with most important first, separated by
* underscore('_'). The variant field is case sensitive.</dd>
@@ -146,7 +146,7 @@
* region subtags. You can find a full list of valid variant codes
* in the IANA Language Subtag Registry (search for "Type: variant").
*
- * <p>However, the variant field in <code>Locale</code> has
+ * <p>However, the variant field in {@code Locale} has
* historically been used for any kind of variation, not just
* language variations. For example, some supported variants
* available in Java SE Runtime Environments indicate alternative
@@ -166,15 +166,15 @@
*
* <dd>A map from single character keys to string values, indicating
* extensions apart from language identification. The extensions in
- * <code>Locale</code> implement the semantics and syntax of BCP 47
+ * {@code Locale} implement the semantics and syntax of BCP 47
* extension subtags and private use subtags. The extensions are
- * case insensitive, but <code>Locale</code> canonicalizes all
+ * case insensitive, but {@code Locale} canonicalizes all
* extension keys and values to lower case. Note that extensions
* cannot have empty values.</dd>
*
* <dd>Well-formed keys are single characters from the set
- * <code>[0-9a-zA-Z]</code>. Well-formed values have the form
- * <code>SUBTAG ('-' SUBTAG)*</code> where for the key 'x'
+ * {@code [0-9a-zA-Z]}. Well-formed values have the form
+ * {@code SUBTAG ('-' SUBTAG)*} where for the key 'x'
* <code>SUBTAG = [0-9a-zA-Z]{1,8}</code> and for other keys
* <code>SUBTAG = [0-9a-zA-Z]{2,8}</code> (that is, 'x' allows
* single-character subtags).</dd>
@@ -184,8 +184,8 @@
* </dl>
*
* <b>Note:</b> Although BCP 47 requires field values to be registered
- * in the IANA Language Subtag Registry, the <code>Locale</code> class
- * does not provide any validation features. The <code>Builder</code>
+ * in the IANA Language Subtag Registry, the {@code Locale} class
+ * does not provide any validation features. The {@code Builder}
* only checks if an individual field satisfies the syntactic
* requirement (is well-formed), but does not validate the value
* itself. See {@link Builder} for details.
@@ -203,11 +203,11 @@
* extension key 'u' ({@link #UNICODE_LOCALE_EXTENSION}). The above
* example, "nu-thai", becomes the extension "u-nu-thai".
*
- * <p>Thus, when a <code>Locale</code> object contains Unicode locale
+ * <p>Thus, when a {@code Locale} object contains Unicode locale
* attributes and keywords,
- * <code>getExtension(UNICODE_LOCALE_EXTENSION)</code> will return a
+ * {@code getExtension(UNICODE_LOCALE_EXTENSION)} will return a
* String representing this information, for example, "nu-thai". The
- * <code>Locale</code> class also provides {@link
+ * {@code Locale} class also provides {@link
* #getUnicodeLocaleAttributes}, {@link #getUnicodeLocaleKeys}, and
* {@link #getUnicodeLocaleType} which allow you to access Unicode
* locale attributes and key/type pairs directly. When represented as
@@ -232,17 +232,17 @@
*
* <h3>Creating a Locale</h3>
*
- * <p>There are several different ways to create a <code>Locale</code>
+ * <p>There are several different ways to create a {@code Locale}
* object.
*
* <h4>Builder</h4>
*
- * <p>Using {@link Builder} you can construct a <code>Locale</code> object
+ * <p>Using {@link Builder} you can construct a {@code Locale} object
* that conforms to BCP 47 syntax.
*
* <h4>Constructors</h4>
*
- * <p>The <code>Locale</code> class provides three constructors:
+ * <p>The {@code Locale} class provides three constructors:
* <blockquote>
* <pre>
* {@link #Locale(String language)}
@@ -250,20 +250,20 @@
* {@link #Locale(String language, String country, String variant)}
* </pre>
* </blockquote>
- * These constructors allow you to create a <code>Locale</code> object
+ * These constructors allow you to create a {@code Locale} object
* with language, country and variant, but you cannot specify
* script or extensions.
*
* <h4>Factory Methods</h4>
*
- * <p>The method {@link #forLanguageTag} creates a <code>Locale</code>
+ * <p>The method {@link #forLanguageTag} creates a {@code Locale}
* object for a well-formed BCP 47 language tag.
*
* <h4>Locale Constants</h4>
*
- * <p>The <code>Locale</code> class provides a number of convenient constants
- * that you can use to create <code>Locale</code> objects for commonly used
- * locales. For example, the following creates a <code>Locale</code> object
+ * <p>The {@code Locale} class provides a number of convenient constants
+ * that you can use to create {@code Locale} objects for commonly used
+ * locales. For example, the following creates a {@code Locale} object
* for the United States:
* <blockquote>
* <pre>
@@ -344,25 +344,25 @@
*
* <h3>Use of Locale</h3>
*
- * <p>Once you've created a <code>Locale</code> you can query it for information
- * about itself. Use <code>getCountry</code> to get the country (or region)
- * code and <code>getLanguage</code> to get the language code.
- * You can use <code>getDisplayCountry</code> to get the
+ * <p>Once you've created a {@code Locale} you can query it for information
+ * about itself. Use {@code getCountry} to get the country (or region)
+ * code and {@code getLanguage} to get the language code.
+ * You can use {@code getDisplayCountry} to get the
* name of the country suitable for displaying to the user. Similarly,
- * you can use <code>getDisplayLanguage</code> to get the name of
+ * you can use {@code getDisplayLanguage} to get the name of
* the language suitable for displaying to the user. Interestingly,
- * the <code>getDisplayXXX</code> methods are themselves locale-sensitive
+ * the {@code getDisplayXXX} methods are themselves locale-sensitive
* and have two versions: one that uses the default
* {@link Locale.Category#DISPLAY DISPLAY} locale and one
* that uses the locale specified as an argument.
*
* <p>The Java Platform provides a number of classes that perform locale-sensitive
- * operations. For example, the <code>NumberFormat</code> class formats
+ * operations. For example, the {@code NumberFormat} class formats
* numbers, currency, and percentages in a locale-sensitive manner. Classes
- * such as <code>NumberFormat</code> have several convenience methods
+ * such as {@code NumberFormat} have several convenience methods
* for creating a default object of that type. For example, the
- * <code>NumberFormat</code> class provides these three convenience methods
- * for creating a default <code>NumberFormat</code> object:
+ * {@code NumberFormat} class provides these three convenience methods
+ * for creating a default {@code NumberFormat} object:
* <blockquote>
* <pre>
* NumberFormat.getInstance()
@@ -380,8 +380,8 @@
* NumberFormat.getPercentInstance(myLocale)
* </pre>
* </blockquote>
- * A <code>Locale</code> is the mechanism for identifying the kind of object
- * (<code>NumberFormat</code>) that you would like to get. The locale is
+ * A {@code Locale} is the mechanism for identifying the kind of object
+ * ({@code NumberFormat}) that you would like to get. The locale is
* <STRONG>just</STRONG> a mechanism for identifying objects,
* <STRONG>not</STRONG> a container for the objects themselves.
*
@@ -390,7 +390,7 @@
* <p>In order to maintain compatibility with existing usage, Locale's
* constructors retain their behavior prior to the Java Runtime
* Environment version 1.7. The same is largely true for the
- * <code>toString</code> method. Thus Locale objects can continue to
+ * {@code toString} method. Thus Locale objects can continue to
* be used as they were. In particular, clients who parse the output
* of toString into language, country, and variant fields can continue
* to do so (although this is strongly discouraged), although the
@@ -400,15 +400,15 @@
* <p>In addition, BCP 47 imposes syntax restrictions that are not
* imposed by Locale's constructors. This means that conversions
* between some Locales and BCP 47 language tags cannot be made without
- * losing information. Thus <code>toLanguageTag</code> cannot
+ * losing information. Thus {@code toLanguageTag} cannot
* represent the state of locales whose language, country, or variant
* do not conform to BCP 47.
*
* <p>Because of these issues, it is recommended that clients migrate
* away from constructing non-conforming locales and use the
- * <code>forLanguageTag</code> and <code>Locale.Builder</code> APIs instead.
+ * {@code forLanguageTag} and {@code Locale.Builder} APIs instead.
* Clients desiring a string representation of the complete locale can
- * then always rely on <code>toLanguageTag</code> for this purpose.
+ * then always rely on {@code toLanguageTag} for this purpose.
*
* <h4><a id="special_cases_constructor">Special cases</a></h4>
*
@@ -454,9 +454,9 @@
*
* <p>The APIs added in 1.7 map between the old and new language codes,
* maintaining the old codes internal to Locale (so that
- * <code>getLanguage</code> and <code>toString</code> reflect the old
+ * {@code getLanguage} and {@code toString} reflect the old
* code), but using the new codes in the BCP 47 language tag APIs (so
- * that <code>toLanguageTag</code> reflects the new one). This
+ * that {@code toLanguageTag} reflects the new one). This
* preserves the equivalence between Locales no matter which code or
* API is used to construct them. Java's default resource bundle
* lookup mechanism also implements this mapping, so that resources
@@ -633,6 +633,7 @@
/** serialization ID
*/
+ @java.io.Serial
static final long serialVersionUID = 9149081749638150636L;
/**
@@ -733,13 +734,13 @@
* </ul>
*
* @param language An ISO 639 alpha-2 or alpha-3 language code, or a language subtag
- * up to 8 characters in length. See the <code>Locale</code> class description about
+ * up to 8 characters in length. See the {@code Locale} class description about
* valid language values.
* @param country An ISO 3166 alpha-2 country code or a UN M.49 numeric-3 area code.
- * See the <code>Locale</code> class description about valid country values.
- * @param variant Any arbitrary value used to indicate a variation of a <code>Locale</code>.
- * See the <code>Locale</code> class description for the details.
- * @exception NullPointerException thrown if any argument is null.
+ * See the {@code Locale} class description about valid country values.
+ * @param variant Any arbitrary value used to indicate a variation of a {@code Locale}.
+ * See the {@code Locale} class description for the details.
+ * @throws NullPointerException thrown if any argument is null.
*/
public Locale(String language, String country, String variant) {
if (language == null || country == null || variant == null) {
@@ -765,11 +766,11 @@
* </ul>
*
* @param language An ISO 639 alpha-2 or alpha-3 language code, or a language subtag
- * up to 8 characters in length. See the <code>Locale</code> class description about
+ * up to 8 characters in length. See the {@code Locale} class description about
* valid language values.
* @param country An ISO 3166 alpha-2 country code or a UN M.49 numeric-3 area code.
- * See the <code>Locale</code> class description about valid country values.
- * @exception NullPointerException thrown if either argument is null.
+ * See the {@code Locale} class description about valid country values.
+ * @throws NullPointerException thrown if either argument is null.
*/
public Locale(String language, String country) {
this(language, country, "");
@@ -790,9 +791,9 @@
* </ul>
*
* @param language An ISO 639 alpha-2 or alpha-3 language code, or a language subtag
- * up to 8 characters in length. See the <code>Locale</code> class description about
+ * up to 8 characters in length. See the {@code Locale} class description about
* valid language values.
- * @exception NullPointerException thrown if argument is null.
+ * @throws NullPointerException thrown if argument is null.
* @since 1.4
*/
public Locale(String language) {
@@ -800,18 +801,18 @@
}
/**
- * Returns a <code>Locale</code> constructed from the given
- * <code>language</code>, <code>country</code> and
- * <code>variant</code>. If the same <code>Locale</code> instance
+ * Returns a {@code Locale} constructed from the given
+ * {@code language}, {@code country} and
+ * {@code variant}. If the same {@code Locale} instance
* is available in the cache, then that instance is
- * returned. Otherwise, a new <code>Locale</code> instance is
+ * returned. Otherwise, a new {@code Locale} instance is
* created and cached.
*
* @param language lowercase 2 to 8 language code.
* @param country uppercase two-letter ISO-3166 code and numeric-3 UN M.49 area code.
* @param variant vendor and browser specific code. See class description.
- * @return the <code>Locale</code> instance requested
- * @exception NullPointerException if any argument is null.
+ * @return the {@code Locale} instance requested
+ * @throws NullPointerException if any argument is null.
*/
static Locale getInstance(String language, String country, String variant) {
return getInstance(language, "", country, variant, null);
@@ -929,7 +930,7 @@
* if no locale is explicitly specified. It can be changed using the
* setDefault(Locale.Category, Locale) method.
*
- * @param category - the specified category to get the default locale
+ * @param category the specified category to get the default locale
* @throws NullPointerException if category is null
* @return the default locale for the specified Category for this instance
* of the Java Virtual Machine
@@ -1028,8 +1029,8 @@
* Sets the default locale for this instance of the Java Virtual Machine.
* This does not affect the host locale.
* <p>
- * If there is a security manager, its <code>checkPermission</code>
- * method is called with a <code>PropertyPermission("user.language", "write")</code>
+ * If there is a security manager, its {@code checkPermission}
+ * method is called with a {@code PropertyPermission("user.language", "write")}
* permission before the default locale is changed.
* <p>
* The Java Virtual Machine sets the default locale during startup
@@ -1046,8 +1047,8 @@
*
* @throws SecurityException
* if a security manager exists and its
- * <code>checkPermission</code> method doesn't allow the operation.
- * @throws NullPointerException if <code>newLocale</code> is null
+ * {@code checkPermission} method doesn't allow the operation.
+ * @throws NullPointerException if {@code newLocale} is null
* @param newLocale the new default locale
* @see SecurityManager#checkPermission
* @see java.util.PropertyPermission
@@ -1075,8 +1076,8 @@
* prepared to reinitialize locale-sensitive code running within the
* same Java Virtual Machine.
*
- * @param category - the specified category to set the default locale
- * @param newLocale - the new default locale
+ * @param category the specified category to set the default locale
+ * @param newLocale the new default locale
* @throws SecurityException if a security manager exists and its
* checkPermission method doesn't allow the operation.
* @throws NullPointerException if category and/or newLocale is null
@@ -1112,7 +1113,7 @@
* The returned array represents the union of locales supported
* by the Java runtime environment and by installed
* {@link java.util.spi.LocaleServiceProvider LocaleServiceProvider}
- * implementations. It must contain at least a <code>Locale</code>
+ * implementations. It must contain at least a {@code Locale}
* instance equal to {@link java.util.Locale#US Locale.US}.
*
* @return An array of installed locales.
@@ -1127,7 +1128,7 @@
* This method is equivalent to {@link #getISOCountries(Locale.IsoCountryCode type)}
* with {@code type} {@link IsoCountryCode#PART1_ALPHA2}.
* <p>
- * <b>Note:</b> The <code>Locale</code> class also supports other codes for
+ * <b>Note:</b> The {@code Locale} class also supports other codes for
* country (region), such as 3-letter numeric UN M.49 area codes.
* Therefore, the list returned by this method does not contain ALL valid
* codes that can be used to create Locales.
@@ -1170,7 +1171,7 @@
* <li>ISO 639 is not a stable standard— some languages' codes have changed.
* The list this function returns includes both the new and the old codes for the
* languages whose codes have changed.
- * <li>The <code>Locale</code> class also supports language codes up to
+ * <li>The {@code Locale} class also supports language codes up to
* 8 characters in length. Therefore, the list returned by this method does
* not contain ALL valid codes that can be used to create Locales.
* </ul>
@@ -1282,7 +1283,7 @@
* Returns the extension (or private use) value associated with
* the specified key, or null if there is no extension
* associated with the key. To be well-formed, the key must be one
- * of <code>[0-9A-Za-z]</code>. Keys are case-insensitive, so
+ * of {@code [0-9A-Za-z]}. Keys are case-insensitive, so
* for example 'z' and 'Z' represent the same extension.
*
* @param key the extension key
@@ -1342,7 +1343,7 @@
* @return The Unicode locale type associated with the key, or null if the
* locale does not define the key.
* @throws IllegalArgumentException if the key is not well-formed
- * @throws NullPointerException if <code>key</code> is null
+ * @throws NullPointerException if {@code key} is null
* @since 1.7
*/
public String getUnicodeLocaleType(String key) {
@@ -1387,7 +1388,7 @@
}
/**
- * Returns a string representation of this <code>Locale</code>
+ * Returns a string representation of this {@code Locale}
* object, consisting of language, country, variant, script,
* and extensions as below:
* <blockquote>
@@ -1410,7 +1411,7 @@
* added before the "#".
*
* <p>This behavior is designed to support debugging and to be compatible with
- * previous uses of <code>toString</code> that expected language, country, and variant
+ * previous uses of {@code toString} that expected language, country, and variant
* fields only. To represent a Locale as a String for interchange purposes, use
* {@link #toLanguageTag}.
*
@@ -1466,7 +1467,7 @@
* Returns a well-formed IETF BCP 47 language tag representing
* this locale.
*
- * <p>If this <code>Locale</code> has a language, country, or
+ * <p>If this {@code Locale} has a language, country, or
* variant that does not satisfy the IETF BCP 47 language tag
* syntax requirements, this method handles these fields as
* described below:
@@ -1702,12 +1703,12 @@
* <p>For a list of all grandfathered tags, see the
* IANA Language Subtag Registry (search for "Type: grandfathered").
*
- * <p><b>Note</b>: there is no guarantee that <code>toLanguageTag</code>
- * and <code>forLanguageTag</code> will round-trip.
+ * <p><b>Note</b>: there is no guarantee that {@code toLanguageTag}
+ * and {@code forLanguageTag} will round-trip.
*
* @param languageTag the language tag
* @return The locale that best represents the language tag.
- * @throws NullPointerException if <code>languageTag</code> is <code>null</code>
+ * @throws NullPointerException if {@code languageTag} is {@code null}
* @see #toLanguageTag()
* @see java.util.Locale.Builder#setLanguageTag(String)
* @since 1.7
@@ -1736,7 +1737,7 @@
* not specify a language the empty string is returned.
*
* @return A three-letter abbreviation of this locale's language.
- * @exception MissingResourceException Throws MissingResourceException if
+ * @throws MissingResourceException Throws MissingResourceException if
* three-letter language abbreviation is not available for this locale.
*/
public String getISO3Language() throws MissingResourceException {
@@ -1763,7 +1764,7 @@
* <p>The ISO 3166-1 codes can be found on-line.
*
* @return A three-letter abbreviation of this locale's country.
- * @exception MissingResourceException Throws MissingResourceException if the
+ * @throws MissingResourceException Throws MissingResourceException if the
* three-letter country abbreviation is not available for this locale.
*/
public String getISO3Country() throws MissingResourceException {
@@ -1833,7 +1834,7 @@
*
* @param inLocale The locale for which to retrieve the display language.
* @return The name of the display language appropriate to the given locale.
- * @exception NullPointerException if <code>inLocale</code> is <code>null</code>
+ * @throws NullPointerException if {@code inLocale} is {@code null}
*/
public String getDisplayLanguage(Locale inLocale) {
return getDisplayString(baseLocale.getLanguage(), null, inLocale, DISPLAY_LANGUAGE);
@@ -1862,7 +1863,7 @@
* @param inLocale The locale for which to retrieve the display script.
* @return the display name of the script code for the current default
* {@link Locale.Category#DISPLAY DISPLAY} locale
- * @throws NullPointerException if <code>inLocale</code> is <code>null</code>
+ * @throws NullPointerException if {@code inLocale} is {@code null}
* @since 1.7
*/
public String getDisplayScript(Locale inLocale) {
@@ -1906,7 +1907,7 @@
*
* @param inLocale The locale for which to retrieve the display country.
* @return The name of the country appropriate to the given locale.
- * @exception NullPointerException if <code>inLocale</code> is <code>null</code>
+ * @throws NullPointerException if {@code inLocale} is {@code null}
*/
public String getDisplayCountry(Locale inLocale) {
return getDisplayString(baseLocale.getRegion(), null, inLocale, DISPLAY_COUNTRY);
@@ -1948,7 +1949,7 @@
*
* @param inLocale The locale for which to retrieve the display variant code.
* @return The name of the display variant code appropriate to the given locale.
- * @exception NullPointerException if <code>inLocale</code> is <code>null</code>
+ * @throws NullPointerException if {@code inLocale} is {@code null}
*/
public String getDisplayVariant(Locale inLocale) {
if (baseLocale.getVariant().isEmpty())
@@ -2013,7 +2014,7 @@
*
* @param inLocale The locale for which to retrieve the display name.
* @return The name of the locale appropriate to display.
- * @throws NullPointerException if <code>inLocale</code> is <code>null</code>
+ * @throws NullPointerException if {@code inLocale} is {@code null}
*/
public String getDisplayName(Locale inLocale) {
LocaleResources lr = LocaleProviderAdapter
@@ -2301,6 +2302,7 @@
* (See <a href="java.base/java/util/Locale.html#getExtensionKeys()">getExtensionKeys()</a>,
* <a href="java.base/java/util/Locale.html#getExtension(char)">getExtension(char)</a>)
*/
+ @java.io.Serial
private static final ObjectStreamField[] serialPersistentFields = {
new ObjectStreamField("language", String.class),
new ObjectStreamField("country", String.class),
@@ -2311,11 +2313,12 @@
};
/**
- * Serializes this <code>Locale</code> to the specified <code>ObjectOutputStream</code>.
- * @param out the <code>ObjectOutputStream</code> to write
+ * Serializes this {@code Locale} to the specified {@code ObjectOutputStream}.
+ * @param out the {@code ObjectOutputStream} to write
* @throws IOException
* @since 1.7
*/
+ @java.io.Serial
private void writeObject(ObjectOutputStream out) throws IOException {
ObjectOutputStream.PutField fields = out.putFields();
fields.put("language", baseLocale.getLanguage());
@@ -2328,13 +2331,14 @@
}
/**
- * Deserializes this <code>Locale</code>.
- * @param in the <code>ObjectInputStream</code> to read
+ * Deserializes this {@code Locale}.
+ * @param in the {@code ObjectInputStream} to read
* @throws IOException
* @throws ClassNotFoundException
* @throws IllformedLocaleException
* @since 1.7
*/
+ @java.io.Serial
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
ObjectInputStream.GetField fields = in.readFields();
String language = (String)fields.get("language", "");
@@ -2358,19 +2362,20 @@
}
/**
- * Returns a cached <code>Locale</code> instance equivalent to
- * the deserialized <code>Locale</code>. When serialized
+ * Returns a cached {@code Locale} instance equivalent to
+ * the deserialized {@code Locale}. When serialized
* language, country and variant fields read from the object data stream
* are exactly "ja", "JP", "JP" or "th", "TH", "TH" and script/extensions
- * fields are empty, this method supplies <code>UNICODE_LOCALE_EXTENSION</code>
+ * fields are empty, this method supplies {@code UNICODE_LOCALE_EXTENSION}
* "ca"/"japanese" (calendar type is "japanese") or "nu"/"thai" (number script
* type is "thai"). See <a href="Locale.html#special_cases_constructor">Special Cases</a>
* for more information.
*
- * @return an instance of <code>Locale</code> equivalent to
- * the deserialized <code>Locale</code>.
+ * @return an instance of {@code Locale} equivalent to
+ * the deserialized {@code Locale}.
* @throws java.io.ObjectStreamException
*/
+ @java.io.Serial
private Object readResolve() throws java.io.ObjectStreamException {
return getInstance(baseLocale.getLanguage(), baseLocale.getScript(),
baseLocale.getRegion(), baseLocale.getVariant(), localeExtensions);
@@ -2504,33 +2509,33 @@
}
/**
- * <code>Builder</code> is used to build instances of <code>Locale</code>
- * from values configured by the setters. Unlike the <code>Locale</code>
- * constructors, the <code>Builder</code> checks if a value configured by a
- * setter satisfies the syntax requirements defined by the <code>Locale</code>
- * class. A <code>Locale</code> object created by a <code>Builder</code> is
+ * {@code Builder} is used to build instances of {@code Locale}
+ * from values configured by the setters. Unlike the {@code Locale}
+ * constructors, the {@code Builder} checks if a value configured by a
+ * setter satisfies the syntax requirements defined by the {@code Locale}
+ * class. A {@code Locale} object created by a {@code Builder} is
* well-formed and can be transformed to a well-formed IETF BCP 47 language tag
* without losing information.
*
- * <p><b>Note:</b> The <code>Locale</code> class does not provide any
+ * <p><b>Note:</b> The {@code Locale} class does not provide any
* syntactic restrictions on variant, while BCP 47 requires each variant
* subtag to be 5 to 8 alphanumerics or a single numeric followed by 3
- * alphanumerics. The method <code>setVariant</code> throws
- * <code>IllformedLocaleException</code> for a variant that does not satisfy
+ * alphanumerics. The method {@code setVariant} throws
+ * {@code IllformedLocaleException} for a variant that does not satisfy
* this restriction. If it is necessary to support such a variant, use a
- * Locale constructor. However, keep in mind that a <code>Locale</code>
+ * Locale constructor. However, keep in mind that a {@code Locale}
* object created this way might lose the variant information when
* transformed to a BCP 47 language tag.
*
- * <p>The following example shows how to create a <code>Locale</code> object
- * with the <code>Builder</code>.
+ * <p>The following example shows how to create a {@code Locale} object
+ * with the {@code Builder}.
* <blockquote>
* <pre>
* Locale aLocale = new Builder().setLanguage("sr").setScript("Latn").setRegion("RS").build();
* </pre>
* </blockquote>
*
- * <p>Builders can be reused; <code>clear()</code> resets all
+ * <p>Builders can be reused; {@code clear()} resets all
* fields to their default values.
*
* @see Locale#forLanguageTag
@@ -2549,13 +2554,13 @@
}
/**
- * Resets the <code>Builder</code> to match the provided
- * <code>locale</code>. Existing state is discarded.
+ * Resets the {@code Builder} to match the provided
+ * {@code locale}. Existing state is discarded.
*
* <p>All fields of the locale must be well-formed, see {@link Locale}.
*
* <p>Locales with any ill-formed fields cause
- * <code>IllformedLocaleException</code> to be thrown, except for the
+ * {@code IllformedLocaleException} to be thrown, except for the
* following three cases which are accepted for compatibility
* reasons:<ul>
* <li>Locale("ja", "JP", "JP") is treated as "ja-JP-u-ca-japanese"
@@ -2564,9 +2569,9 @@
*
* @param locale the locale
* @return This builder.
- * @throws IllformedLocaleException if <code>locale</code> has
+ * @throws IllformedLocaleException if {@code locale} has
* any ill-formed fields.
- * @throws NullPointerException if <code>locale</code> is null.
+ * @throws NullPointerException if {@code locale} is null.
*/
public Builder setLocale(Locale locale) {
try {
@@ -2585,13 +2590,13 @@
* Locale#forLanguageTag}) are converted to their canonical
* form before being processed. Otherwise, the language tag
* must be well-formed (see {@link Locale}) or an exception is
- * thrown (unlike <code>Locale.forLanguageTag</code>, which
+ * thrown (unlike {@code Locale.forLanguageTag}, which
* just discards ill-formed and following portions of the
* tag).
*
* @param languageTag the language tag
* @return This builder.
- * @throws IllformedLocaleException if <code>languageTag</code> is ill-formed
+ * @throws IllformedLocaleException if {@code languageTag} is ill-formed
* @see Locale#forLanguageTag(String)
*/
public Builder setLanguageTag(String languageTag) {
@@ -2605,8 +2610,8 @@
}
/**
- * Sets the language. If <code>language</code> is the empty string or
- * null, the language in this <code>Builder</code> is removed. Otherwise,
+ * Sets the language. If {@code language} is the empty string or
+ * null, the language in this {@code Builder} is removed. Otherwise,
* the language must be <a href="./Locale.html#def_language">well-formed</a>
* or an exception is thrown.
*
@@ -2615,7 +2620,7 @@
*
* @param language the language
* @return This builder.
- * @throws IllformedLocaleException if <code>language</code> is ill-formed
+ * @throws IllformedLocaleException if {@code language} is ill-formed
*/
public Builder setLanguage(String language) {
try {
@@ -2627,8 +2632,8 @@
}
/**
- * Sets the script. If <code>script</code> is null or the empty string,
- * the script in this <code>Builder</code> is removed.
+ * Sets the script. If {@code script} is null or the empty string,
+ * the script in this {@code Builder} is removed.
* Otherwise, the script must be <a href="./Locale.html#def_script">well-formed</a> or an
* exception is thrown.
*
@@ -2636,7 +2641,7 @@
*
* @param script the script
* @return This builder.
- * @throws IllformedLocaleException if <code>script</code> is ill-formed
+ * @throws IllformedLocaleException if {@code script} is ill-formed
*/
public Builder setScript(String script) {
try {
@@ -2649,19 +2654,19 @@
/**
* Sets the region. If region is null or the empty string, the region
- * in this <code>Builder</code> is removed. Otherwise,
+ * in this {@code Builder} is removed. Otherwise,
* the region must be <a href="./Locale.html#def_region">well-formed</a> or an
* exception is thrown.
*
* <p>The typical region value is a two-letter ISO 3166 code or a
* three-digit UN M.49 area code.
*
- * <p>The country value in the <code>Locale</code> created by the
- * <code>Builder</code> is always normalized to upper case.
+ * <p>The country value in the {@code Locale} created by the
+ * {@code Builder} is always normalized to upper case.
*
* @param region the region
* @return This builder.
- * @throws IllformedLocaleException if <code>region</code> is ill-formed
+ * @throws IllformedLocaleException if {@code region} is ill-formed
*/
public Builder setRegion(String region) {
try {
@@ -2674,21 +2679,21 @@
/**
* Sets the variant. If variant is null or the empty string, the
- * variant in this <code>Builder</code> is removed. Otherwise, it
+ * variant in this {@code Builder} is removed. Otherwise, it
* must consist of one or more <a href="./Locale.html#def_variant">well-formed</a>
* subtags, or an exception is thrown.
*
- * <p><b>Note:</b> This method checks if <code>variant</code>
+ * <p><b>Note:</b> This method checks if {@code variant}
* satisfies the IETF BCP 47 variant subtag's syntax requirements,
* and normalizes the value to lowercase letters. However,
- * the <code>Locale</code> class does not impose any syntactic
+ * the {@code Locale} class does not impose any syntactic
* restriction on variant, and the variant value in
- * <code>Locale</code> is case sensitive. To set such a variant,
+ * {@code Locale} is case sensitive. To set such a variant,
* use a Locale constructor.
*
* @param variant the variant
* @return This builder.
- * @throws IllformedLocaleException if <code>variant</code> is ill-formed
+ * @throws IllformedLocaleException if {@code variant} is ill-formed
*/
public Builder setVariant(String variant) {
try {
@@ -2718,8 +2723,8 @@
* @param key the extension key
* @param value the extension value
* @return This builder.
- * @throws IllformedLocaleException if <code>key</code> is illegal
- * or <code>value</code> is ill-formed
+ * @throws IllformedLocaleException if {@code key} is illegal
+ * or {@code value} is ill-formed
* @see #setUnicodeLocaleKeyword(String, String)
*/
public Builder setExtension(char key, String value) {
@@ -2747,9 +2752,9 @@
* @param key the Unicode locale key
* @param type the Unicode locale type
* @return This builder.
- * @throws IllformedLocaleException if <code>key</code> or <code>type</code>
+ * @throws IllformedLocaleException if {@code key} or {@code type}
* is ill-formed
- * @throws NullPointerException if <code>key</code> is null
+ * @throws NullPointerException if {@code key} is null
* @see #setExtension(char, String)
*/
public Builder setUnicodeLocaleKeyword(String key, String type) {
@@ -2769,8 +2774,8 @@
*
* @param attribute the attribute
* @return This builder.
- * @throws NullPointerException if <code>attribute</code> is null
- * @throws IllformedLocaleException if <code>attribute</code> is ill-formed
+ * @throws NullPointerException if {@code attribute} is null
+ * @throws IllformedLocaleException if {@code attribute} is ill-formed
* @see #setExtension(char, String)
*/
public Builder addUnicodeLocaleAttribute(String attribute) {
@@ -2792,8 +2797,8 @@
*
* @param attribute the attribute
* @return This builder.
- * @throws NullPointerException if <code>attribute</code> is null
- * @throws IllformedLocaleException if <code>attribute</code> is ill-formed
+ * @throws NullPointerException if {@code attribute} is null
+ * @throws IllformedLocaleException if {@code attribute} is ill-formed
* @see #setExtension(char, String)
*/
public Builder removeUnicodeLocaleAttribute(String attribute) {
@@ -2829,7 +2834,7 @@
}
/**
- * Returns an instance of <code>Locale</code> created from the fields set
+ * Returns an instance of {@code Locale} created from the fields set
* on this builder.
*
* <p>This applies the conversions listed in {@link Locale#forLanguageTag}
@@ -3477,7 +3482,7 @@
* @param priorityList user's Language Priority List in which each language
* tag is sorted in descending order based on priority or weight
* @param locales {@code Locale} instances used for matching
- * @return the best matching <code>Locale</code> instance chosen based on
+ * @return the best matching {@code Locale} instance chosen based on
* priority or weight, or {@code null} if nothing matches.
* @throws NullPointerException if {@code priorityList} or {@code tags} is
* {@code null}