mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 22:34:27 +02:00
8300794: Use @snippet in java.util:i18n
Reviewed-by: naoto, lancea
This commit is contained in:
parent
64d5157116
commit
4e92991809
5 changed files with 107 additions and 122 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -365,7 +365,7 @@ public final class Currency implements Serializable {
|
||||||
* of the respective countries.
|
* of the respective countries.
|
||||||
* <p>
|
* <p>
|
||||||
* If the specified {@code locale} contains "cu" and/or "rg"
|
* If the specified {@code locale} contains "cu" and/or "rg"
|
||||||
* <a href="./Locale.html#def_locale_extension">Unicode extensions</a>,
|
* {@linkplain Locale##def_locale_extension Unicode extensions},
|
||||||
* the instance returned from this method reflects
|
* the instance returned from this method reflects
|
||||||
* the values specified with those extensions. If both "cu" and "rg" are
|
* the values specified with those extensions. If both "cu" and "rg" are
|
||||||
* specified, the currency from the "cu" extension supersedes the implicit one
|
* specified, the currency from the "cu" extension supersedes the implicit one
|
||||||
|
@ -514,7 +514,7 @@ public final class Currency implements Serializable {
|
||||||
* <p>
|
* <p>
|
||||||
* If the default {@link Locale.Category#DISPLAY DISPLAY} locale
|
* If the default {@link Locale.Category#DISPLAY DISPLAY} locale
|
||||||
* contains "rg" (region override)
|
* contains "rg" (region override)
|
||||||
* <a href="./Locale.html#def_locale_extension">Unicode extension</a>,
|
* {@linkplain Locale##def_locale_extension Unicode extensions},
|
||||||
* the symbol returned from this method reflects
|
* the symbol returned from this method reflects
|
||||||
* the value specified with that extension.
|
* the value specified with that extension.
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -536,7 +536,7 @@ public final class Currency implements Serializable {
|
||||||
* symbol can be determined, the ISO 4217 currency code is returned.
|
* symbol can be determined, the ISO 4217 currency code is returned.
|
||||||
* <p>
|
* <p>
|
||||||
* If the specified {@code locale} contains "rg" (region override)
|
* If the specified {@code locale} contains "rg" (region override)
|
||||||
* <a href="./Locale.html#def_locale_extension">Unicode extension</a>,
|
* {@linkplain Locale##def_locale_extension Unicode extensions},
|
||||||
* the symbol returned from this method reflects
|
* the symbol returned from this method reflects
|
||||||
* the value specified with that extension.
|
* the value specified with that extension.
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1996, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -61,14 +61,13 @@ import sun.util.ResourceBundleEnumeration;
|
||||||
* "MyResources" is the default member of the bundle family, and
|
* "MyResources" is the default member of the bundle family, and
|
||||||
* "MyResources_fr" is the French member.
|
* "MyResources_fr" is the French member.
|
||||||
* These members are based on {@code ListResourceBundle}
|
* These members are based on {@code ListResourceBundle}
|
||||||
* (a related <a href="PropertyResourceBundle.html#sample">example</a> shows
|
* (a related {@linkplain PropertyResourceBundle##sample example} shows
|
||||||
* how you can add a bundle to this family that's based on a properties file).
|
* how you can add a bundle to this family that's based on a properties file).
|
||||||
* The keys in this example are of the form "s1" etc. The actual
|
* The keys in this example are of the form "s1" etc. The actual
|
||||||
* keys are entirely up to your choice, so long as they are the same as
|
* keys are entirely up to your choice, so long as they are the same as
|
||||||
* the keys you use in your program to retrieve the objects from the bundle.
|
* the keys you use in your program to retrieve the objects from the bundle.
|
||||||
* Keys are case-sensitive.
|
* Keys are case-sensitive.
|
||||||
* <blockquote>
|
* {@snippet lang=java :
|
||||||
* <pre>
|
|
||||||
*
|
*
|
||||||
* public class MyResources extends ListResourceBundle {
|
* public class MyResources extends ListResourceBundle {
|
||||||
* protected Object[][] getContents() {
|
* protected Object[][] getContents() {
|
||||||
|
@ -103,8 +102,7 @@ import sun.util.ResourceBundleEnumeration;
|
||||||
* };
|
* };
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* </pre>
|
* }
|
||||||
* </blockquote>
|
|
||||||
*
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* The implementation of a {@code ListResourceBundle} subclass must be thread-safe
|
* The implementation of a {@code ListResourceBundle} subclass must be thread-safe
|
||||||
|
|
|
@ -349,23 +349,19 @@ import sun.util.locale.provider.TimeZoneNameUtility;
|
||||||
* for creating a default object of that type. For example, the
|
* for creating a default object of that type. For example, the
|
||||||
* {@code NumberFormat} class provides these three convenience methods
|
* {@code NumberFormat} class provides these three convenience methods
|
||||||
* for creating a default {@code NumberFormat} object:
|
* for creating a default {@code NumberFormat} object:
|
||||||
* <blockquote>
|
* {@snippet lang=java :
|
||||||
* <pre>
|
* NumberFormat.getInstance();
|
||||||
* NumberFormat.getInstance()
|
* NumberFormat.getCurrencyInstance();
|
||||||
* NumberFormat.getCurrencyInstance()
|
* NumberFormat.getPercentInstance();
|
||||||
* NumberFormat.getPercentInstance()
|
* }
|
||||||
* </pre>
|
|
||||||
* </blockquote>
|
|
||||||
* Each of these methods has two variants; one with an explicit locale
|
* Each of these methods has two variants; one with an explicit locale
|
||||||
* and one without; the latter uses the default
|
* and one without; the latter uses the default
|
||||||
* {@link Locale.Category#FORMAT FORMAT} locale:
|
* {@link Locale.Category#FORMAT FORMAT} locale:
|
||||||
* <blockquote>
|
* {@snippet lang=java :
|
||||||
* <pre>
|
* NumberFormat.getInstance(myLocale);
|
||||||
* NumberFormat.getInstance(myLocale)
|
* NumberFormat.getCurrencyInstance(myLocale);
|
||||||
* NumberFormat.getCurrencyInstance(myLocale)
|
* NumberFormat.getPercentInstance(myLocale);
|
||||||
* NumberFormat.getPercentInstance(myLocale)
|
* }
|
||||||
* </pre>
|
|
||||||
* </blockquote>
|
|
||||||
* A {@code Locale} is the mechanism for identifying the kind of object
|
* A {@code Locale} is the mechanism for identifying the kind of object
|
||||||
* ({@code NumberFormat}) that you would like to get. The locale is
|
* ({@code NumberFormat}) that you would like to get. The locale is
|
||||||
* <STRONG>just</STRONG> a mechanism for identifying objects,
|
* <STRONG>just</STRONG> a mechanism for identifying objects,
|
||||||
|
@ -1620,8 +1616,9 @@ public final class Locale implements Cloneable, Serializable {
|
||||||
* method is well-formed (satisfies the syntax requirements
|
* method is well-formed (satisfies the syntax requirements
|
||||||
* defined by the IETF BCP 47 specification), it is not
|
* defined by the IETF BCP 47 specification), it is not
|
||||||
* necessarily a valid BCP 47 language tag. For example,
|
* necessarily a valid BCP 47 language tag. For example,
|
||||||
* <pre>
|
* {@snippet lang=java :
|
||||||
* Locale.forLanguageTag("xx-YY").toLanguageTag();</pre>
|
* Locale.forLanguageTag("xx-YY").toLanguageTag();
|
||||||
|
* }
|
||||||
*
|
*
|
||||||
* will return "xx-YY", but the language subtag "xx" and the
|
* will return "xx-YY", but the language subtag "xx" and the
|
||||||
* region subtag "YY" are invalid because they are not registered
|
* region subtag "YY" are invalid because they are not registered
|
||||||
|
@ -1764,7 +1761,7 @@ public final class Locale implements Cloneable, Serializable {
|
||||||
* result locale (without case normalization). If it is then
|
* result locale (without case normalization). If it is then
|
||||||
* empty, the private use subtag is discarded:
|
* empty, the private use subtag is discarded:
|
||||||
*
|
*
|
||||||
* <pre>
|
* {@snippet lang=java :
|
||||||
* Locale loc;
|
* Locale loc;
|
||||||
* loc = Locale.forLanguageTag("en-US-x-lvariant-POSIX");
|
* loc = Locale.forLanguageTag("en-US-x-lvariant-POSIX");
|
||||||
* loc.getVariant(); // returns "POSIX"
|
* loc.getVariant(); // returns "POSIX"
|
||||||
|
@ -1773,16 +1770,16 @@ public final class Locale implements Cloneable, Serializable {
|
||||||
* loc = Locale.forLanguageTag("de-POSIX-x-URP-lvariant-Abc-Def");
|
* loc = Locale.forLanguageTag("de-POSIX-x-URP-lvariant-Abc-Def");
|
||||||
* loc.getVariant(); // returns "POSIX_Abc_Def"
|
* loc.getVariant(); // returns "POSIX_Abc_Def"
|
||||||
* loc.getExtension('x'); // returns "urp"
|
* loc.getExtension('x'); // returns "urp"
|
||||||
* </pre>
|
* }
|
||||||
*
|
*
|
||||||
* <li>When the languageTag argument contains an extlang subtag,
|
* <li>When the languageTag argument contains an extlang subtag,
|
||||||
* the first such subtag is used as the language, and the primary
|
* the first such subtag is used as the language, and the primary
|
||||||
* language subtag and other extlang subtags are ignored:
|
* language subtag and other extlang subtags are ignored:
|
||||||
*
|
*
|
||||||
* <pre>
|
* {@snippet lang=java :
|
||||||
* Locale.forLanguageTag("ar-aao").getLanguage(); // returns "aao"
|
* Locale.forLanguageTag("ar-aao").getLanguage(); // returns "aao"
|
||||||
* Locale.forLanguageTag("en-abc-def-us").toString(); // returns "abc_US"
|
* Locale.forLanguageTag("en-abc-def-us").toString(); // returns "abc_US"
|
||||||
* </pre>
|
* }
|
||||||
*
|
*
|
||||||
* <li>Case is normalized except for variant tags, which are left
|
* <li>Case is normalized except for variant tags, which are left
|
||||||
* unchanged. Language is normalized to lower case, script to
|
* unchanged. Language is normalized to lower case, script to
|
||||||
|
@ -1793,12 +1790,12 @@ public final class Locale implements Cloneable, Serializable {
|
||||||
* ja_JP_JP or th_TH_TH with no extensions, the appropriate
|
* ja_JP_JP or th_TH_TH with no extensions, the appropriate
|
||||||
* extensions are added as though the constructor had been called:
|
* extensions are added as though the constructor had been called:
|
||||||
*
|
*
|
||||||
* <pre>
|
* {@snippet lang=java :
|
||||||
* Locale.forLanguageTag("ja-JP-x-lvariant-JP").toLanguageTag();
|
* Locale.forLanguageTag("ja-JP-x-lvariant-JP").toLanguageTag();
|
||||||
* // returns "ja-JP-u-ca-japanese-x-lvariant-JP"
|
* // returns "ja-JP-u-ca-japanese-x-lvariant-JP"
|
||||||
* Locale.forLanguageTag("th-TH-x-lvariant-TH").toLanguageTag();
|
* Locale.forLanguageTag("th-TH-x-lvariant-TH").toLanguageTag();
|
||||||
* // returns "th-TH-u-nu-thai-x-lvariant-TH"
|
* // returns "th-TH-u-nu-thai-x-lvariant-TH"
|
||||||
* </pre></ul>
|
* }</ul>
|
||||||
*
|
*
|
||||||
* <p id="legacy_tags">This implements the 'Language-Tag' production of BCP47, and
|
* <p id="legacy_tags">This implements the 'Language-Tag' production of BCP47, and
|
||||||
* so supports legacy (regular and irregular, referred to as
|
* so supports legacy (regular and irregular, referred to as
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1996, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -73,37 +73,29 @@ import sun.util.ResourceBundleEnumeration;
|
||||||
* the German member of the bundle family.
|
* the German member of the bundle family.
|
||||||
* This member is based on {@code PropertyResourceBundle}, and the text
|
* This member is based on {@code PropertyResourceBundle}, and the text
|
||||||
* therefore is the content of the file "MyResources_de.properties"
|
* therefore is the content of the file "MyResources_de.properties"
|
||||||
* (a related <a href="ListResourceBundle.html#sample">example</a> shows
|
* (a related {@linkplain ListResourceBundle##sample example} shows
|
||||||
* how you can add bundles to this family that are implemented as subclasses
|
* how you can add bundles to this family that are implemented as subclasses
|
||||||
* of {@code ListResourceBundle}).
|
* of {@code ListResourceBundle}).
|
||||||
* The keys in this example are of the form "s1" etc. The actual
|
* The keys in this example are of the form "s1" etc. The actual
|
||||||
* keys are entirely up to your choice, so long as they are the same as
|
* keys are entirely up to your choice, so long as they are the same as
|
||||||
* the keys you use in your program to retrieve the objects from the bundle.
|
* the keys you use in your program to retrieve the objects from the bundle.
|
||||||
* Keys are case-sensitive.
|
* Keys are case-sensitive.
|
||||||
* <blockquote>
|
* {@snippet lang=properties :
|
||||||
* <pre>
|
* # MessageFormat pattern
|
||||||
* # MessageFormat pattern
|
* s1=Die Platte \"{1}\" enth\u00E4lt {0}.
|
||||||
* s1=Die Platte \"{1}\" enthält {0}.
|
* # location of {0} in pattern
|
||||||
*
|
* s2=1
|
||||||
* # location of {0} in pattern
|
* # sample disk name
|
||||||
* s2=1
|
* s3=Meine Platte
|
||||||
*
|
* # first ChoiceFormat choice
|
||||||
* # sample disk name
|
* s4=keine Dateien
|
||||||
* s3=Meine Platte
|
* # second ChoiceFormat choice
|
||||||
*
|
* s5=eine Datei
|
||||||
* # first ChoiceFormat choice
|
* # third ChoiceFormat choice
|
||||||
* s4=keine Dateien
|
* s6={0,number} Dateien
|
||||||
*
|
* # sample date
|
||||||
* # second ChoiceFormat choice
|
* s7=3. M\u00E4rz 1996
|
||||||
* s5=eine Datei
|
* }
|
||||||
*
|
|
||||||
* # third ChoiceFormat choice
|
|
||||||
* s6={0,number} Dateien
|
|
||||||
*
|
|
||||||
* # sample date
|
|
||||||
* s7=3. März 1996
|
|
||||||
* </pre>
|
|
||||||
* </blockquote>
|
|
||||||
*
|
*
|
||||||
* @apiNote
|
* @apiNote
|
||||||
* {@code PropertyResourceBundle} can be constructed either
|
* {@code PropertyResourceBundle} can be constructed either
|
||||||
|
|
|
@ -125,20 +125,17 @@ import static sun.security.util.SecurityConstants.GET_CLASSLOADER_PERMISSION;
|
||||||
* the {@code ResourceBundle} class using the
|
* the {@code ResourceBundle} class using the
|
||||||
* {@link #getBundle(java.lang.String, java.util.Locale) getBundle}
|
* {@link #getBundle(java.lang.String, java.util.Locale) getBundle}
|
||||||
* method:
|
* method:
|
||||||
* <blockquote>
|
* {@snippet lang=java :
|
||||||
* <pre>
|
|
||||||
* ResourceBundle myResources =
|
* ResourceBundle myResources =
|
||||||
* ResourceBundle.getBundle("MyResources", currentLocale);
|
* ResourceBundle.getBundle("MyResources", currentLocale);
|
||||||
* </pre>
|
* }
|
||||||
* </blockquote>
|
|
||||||
*
|
*
|
||||||
* <P>
|
* <P>
|
||||||
* Resource bundles contain key/value pairs. The keys uniquely
|
* Resource bundles contain key/value pairs. The keys uniquely
|
||||||
* identify a locale-specific object in the bundle. Here's an
|
* identify a locale-specific object in the bundle. Here's an
|
||||||
* example of a {@code ListResourceBundle} that contains
|
* example of a {@code ListResourceBundle} that contains
|
||||||
* two key/value pairs:
|
* two key/value pairs:
|
||||||
* <blockquote>
|
* {@snippet lang=java :
|
||||||
* <pre>
|
|
||||||
* public class MyResources extends ListResourceBundle {
|
* public class MyResources extends ListResourceBundle {
|
||||||
* protected Object[][] getContents() {
|
* protected Object[][] getContents() {
|
||||||
* return new Object[][] {
|
* return new Object[][] {
|
||||||
|
@ -149,8 +146,7 @@ import static sun.security.util.SecurityConstants.GET_CLASSLOADER_PERMISSION;
|
||||||
* };
|
* };
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* </pre>
|
* }
|
||||||
* </blockquote>
|
|
||||||
* Keys are always {@code String}s.
|
* Keys are always {@code String}s.
|
||||||
* In this example, the keys are "OkKey" and "CancelKey".
|
* In this example, the keys are "OkKey" and "CancelKey".
|
||||||
* In the above example, the values
|
* In the above example, the values
|
||||||
|
@ -161,12 +157,10 @@ import static sun.security.util.SecurityConstants.GET_CLASSLOADER_PERMISSION;
|
||||||
* You retrieve an object from resource bundle using the appropriate
|
* You retrieve an object from resource bundle using the appropriate
|
||||||
* getter method. Because "OkKey" and "CancelKey"
|
* getter method. Because "OkKey" and "CancelKey"
|
||||||
* are both strings, you would use {@code getString} to retrieve them:
|
* are both strings, you would use {@code getString} to retrieve them:
|
||||||
* <blockquote>
|
* {@snippet lang=java :
|
||||||
* <pre>
|
|
||||||
* button1 = new Button(myResources.getString("OkKey"));
|
* button1 = new Button(myResources.getString("OkKey"));
|
||||||
* button2 = new Button(myResources.getString("CancelKey"));
|
* button2 = new Button(myResources.getString("CancelKey"));
|
||||||
* </pre>
|
* }
|
||||||
* </blockquote>
|
|
||||||
* The getter methods all require the key as an argument and return
|
* The getter methods all require the key as an argument and return
|
||||||
* the object if found. If the object is not found, the getter method
|
* the object if found. If the object is not found, the getter method
|
||||||
* throws a {@code MissingResourceException}.
|
* throws a {@code MissingResourceException}.
|
||||||
|
@ -177,11 +171,9 @@ import static sun.security.util.SecurityConstants.GET_CLASSLOADER_PERMISSION;
|
||||||
* as well as a generic {@code getObject} method for any other
|
* as well as a generic {@code getObject} method for any other
|
||||||
* type of object. When using {@code getObject}, you'll
|
* type of object. When using {@code getObject}, you'll
|
||||||
* have to cast the result to the appropriate type. For example:
|
* have to cast the result to the appropriate type. For example:
|
||||||
* <blockquote>
|
* {@snippet lang=java :
|
||||||
* <pre>
|
|
||||||
* int[] myIntegers = (int[]) myResources.getObject("intList");
|
* int[] myIntegers = (int[]) myResources.getObject("intList");
|
||||||
* </pre>
|
* }
|
||||||
* </blockquote>
|
|
||||||
*
|
*
|
||||||
* <P>
|
* <P>
|
||||||
* The Java Platform provides two subclasses of {@code ResourceBundle},
|
* The Java Platform provides two subclasses of {@code ResourceBundle},
|
||||||
|
@ -330,24 +322,27 @@ import static sun.security.util.SecurityConstants.GET_CLASSLOADER_PERMISSION;
|
||||||
* Notice that you don't need to supply a value if
|
* Notice that you don't need to supply a value if
|
||||||
* a "parent-level" {@code ResourceBundle} handles the same
|
* a "parent-level" {@code ResourceBundle} handles the same
|
||||||
* key with the same value (as for the okKey below).
|
* key with the same value (as for the okKey below).
|
||||||
* <blockquote>
|
* {@snippet lang=java :
|
||||||
* <pre>
|
|
||||||
* // default (English language, United States)
|
* // default (English language, United States)
|
||||||
* public class MyResources extends ResourceBundle {
|
* public class MyResources extends ResourceBundle {
|
||||||
* public Object handleGetObject(String key) {
|
* public Object handleGetObject(String key) {
|
||||||
* if (key.equals("okKey")) return "Ok";
|
* if (key.equals("okKey")) {
|
||||||
* if (key.equals("cancelKey")) return "Cancel";
|
* return "Ok";
|
||||||
|
* }
|
||||||
|
* if (key.equals("cancelKey")) {
|
||||||
|
* return "Cancel";
|
||||||
|
* }
|
||||||
* return null;
|
* return null;
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* public Enumeration<String> getKeys() {
|
* public Enumeration<String> getKeys() {
|
||||||
* return Collections.enumeration(keySet());
|
* return Collections.enumeration(keySet());
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* // Overrides handleKeySet() so that the getKeys() implementation
|
* // Overrides handleKeySet() so that the getKeys() implementation
|
||||||
* // can rely on the keySet() value.
|
* // can rely on the keySet() value.
|
||||||
* protected Set<String> handleKeySet() {
|
* protected Set<String> handleKeySet() {
|
||||||
* return new HashSet<String>(Arrays.asList("okKey", "cancelKey"));
|
* return new HashSet<String>(Arrays.asList("okKey", "cancelKey"));
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
|
@ -355,16 +350,17 @@ import static sun.security.util.SecurityConstants.GET_CLASSLOADER_PERMISSION;
|
||||||
* public class MyResources_de extends MyResources {
|
* public class MyResources_de extends MyResources {
|
||||||
* public Object handleGetObject(String key) {
|
* public Object handleGetObject(String key) {
|
||||||
* // don't need okKey, since parent level handles it.
|
* // don't need okKey, since parent level handles it.
|
||||||
* if (key.equals("cancelKey")) return "Abbrechen";
|
* if (key.equals("cancelKey")) {
|
||||||
|
* return "Abbrechen";
|
||||||
|
* }
|
||||||
* return null;
|
* return null;
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* protected Set<String> handleKeySet() {
|
* protected Set<String> handleKeySet() {
|
||||||
* return new HashSet<String>(Arrays.asList("cancelKey"));
|
* return new HashSet<String>(Arrays.asList("cancelKey"));
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* </pre>
|
* }
|
||||||
* </blockquote>
|
|
||||||
* You do not have to restrict yourself to using a single family of
|
* You do not have to restrict yourself to using a single family of
|
||||||
* {@code ResourceBundle}s. For example, you could have a set of bundles for
|
* {@code ResourceBundle}s. For example, you could have a set of bundles for
|
||||||
* exception messages, {@code ExceptionResources}
|
* exception messages, {@code ExceptionResources}
|
||||||
|
@ -512,9 +508,10 @@ public abstract class ResourceBundle {
|
||||||
/**
|
/**
|
||||||
* Gets a string for the given key from this resource bundle or one of its parents.
|
* Gets a string for the given key from this resource bundle or one of its parents.
|
||||||
* Calling this method is equivalent to calling
|
* Calling this method is equivalent to calling
|
||||||
* <blockquote>
|
* {@snippet lang=java :
|
||||||
* <code>(String) {@link #getObject(java.lang.String) getObject}(key)</code>.
|
* // @link substring="getObject" target="#getObject(java.lang.String)"
|
||||||
* </blockquote>
|
* (String[]) getObject(key);
|
||||||
|
* }
|
||||||
*
|
*
|
||||||
* @param key the key for the desired string
|
* @param key the key for the desired string
|
||||||
* @throws NullPointerException if {@code key} is {@code null}
|
* @throws NullPointerException if {@code key} is {@code null}
|
||||||
|
@ -529,9 +526,10 @@ public abstract class ResourceBundle {
|
||||||
/**
|
/**
|
||||||
* Gets a string array for the given key from this resource bundle or one of its parents.
|
* Gets a string array for the given key from this resource bundle or one of its parents.
|
||||||
* Calling this method is equivalent to calling
|
* Calling this method is equivalent to calling
|
||||||
* <blockquote>
|
* {@snippet lang=java :
|
||||||
* <code>(String[]) {@link #getObject(java.lang.String) getObject}(key)</code>.
|
* // @link substring="getObject" target="#getObject(java.lang.String)"
|
||||||
* </blockquote>
|
* (String[]) getObject(key);
|
||||||
|
* }
|
||||||
*
|
*
|
||||||
* @param key the key for the desired string array
|
* @param key the key for the desired string array
|
||||||
* @throws NullPointerException if {@code key} is {@code null}
|
* @throws NullPointerException if {@code key} is {@code null}
|
||||||
|
@ -842,9 +840,9 @@ public abstract class ResourceBundle {
|
||||||
/**
|
/**
|
||||||
* Gets a resource bundle using the specified base name, the default locale,
|
* Gets a resource bundle using the specified base name, the default locale,
|
||||||
* and the caller module. Calling this method is equivalent to calling
|
* and the caller module. Calling this method is equivalent to calling
|
||||||
* <blockquote>
|
* {@snippet lang=java :
|
||||||
* {@code getBundle(baseName, Locale.getDefault(), callerModule)},
|
* getBundle(baseName, Locale.getDefault(), callerModule);
|
||||||
* </blockquote>
|
* }
|
||||||
*
|
*
|
||||||
* @param baseName the base name of the resource bundle, a fully qualified class name
|
* @param baseName the base name of the resource bundle, a fully qualified class name
|
||||||
* @throws java.lang.NullPointerException
|
* @throws java.lang.NullPointerException
|
||||||
|
@ -868,10 +866,10 @@ public abstract class ResourceBundle {
|
||||||
* Returns a resource bundle using the specified base name, the
|
* Returns a resource bundle using the specified base name, the
|
||||||
* default locale and the specified control. Calling this method
|
* default locale and the specified control. Calling this method
|
||||||
* is equivalent to calling
|
* is equivalent to calling
|
||||||
* <pre>
|
* {@snippet lang=java :
|
||||||
* getBundle(baseName, Locale.getDefault(),
|
* getBundle(baseName, Locale.getDefault(),
|
||||||
* this.getClass().getClassLoader(), control),
|
* this.getClass().getClassLoader(), control);
|
||||||
* </pre>
|
* }
|
||||||
* except that {@code getClassLoader()} is run with the security
|
* except that {@code getClassLoader()} is run with the security
|
||||||
* privileges of {@code ResourceBundle}. See {@link
|
* privileges of {@code ResourceBundle}. See {@link
|
||||||
* #getBundle(String, Locale, ClassLoader, Control) getBundle} for the
|
* #getBundle(String, Locale, ClassLoader, Control) getBundle} for the
|
||||||
|
@ -912,9 +910,9 @@ public abstract class ResourceBundle {
|
||||||
/**
|
/**
|
||||||
* Gets a resource bundle using the specified base name and locale,
|
* Gets a resource bundle using the specified base name and locale,
|
||||||
* and the caller module. Calling this method is equivalent to calling
|
* and the caller module. Calling this method is equivalent to calling
|
||||||
* <blockquote>
|
* {@snippet lang=java :
|
||||||
* {@code getBundle(baseName, locale, callerModule)},
|
* getBundle(baseName, locale, callerModule);
|
||||||
* </blockquote>
|
* }
|
||||||
*
|
*
|
||||||
* @param baseName
|
* @param baseName
|
||||||
* the base name of the resource bundle, a fully qualified class name
|
* the base name of the resource bundle, a fully qualified class name
|
||||||
|
@ -941,9 +939,9 @@ public abstract class ResourceBundle {
|
||||||
/**
|
/**
|
||||||
* Gets a resource bundle using the specified base name and the default locale
|
* Gets a resource bundle using the specified base name and the default locale
|
||||||
* on behalf of the specified module. This method is equivalent to calling
|
* on behalf of the specified module. This method is equivalent to calling
|
||||||
* <blockquote>
|
* {@snippet lang=java :
|
||||||
* {@code getBundle(baseName, Locale.getDefault(), module)}
|
* getBundle(baseName, Locale.getDefault(), module);
|
||||||
* </blockquote>
|
* }
|
||||||
*
|
*
|
||||||
* @param baseName the base name of the resource bundle,
|
* @param baseName the base name of the resource bundle,
|
||||||
* a fully qualified class name
|
* a fully qualified class name
|
||||||
|
@ -1024,10 +1022,10 @@ public abstract class ResourceBundle {
|
||||||
* Returns a resource bundle using the specified base name, target
|
* Returns a resource bundle using the specified base name, target
|
||||||
* locale and control, and the caller's class loader. Calling this
|
* locale and control, and the caller's class loader. Calling this
|
||||||
* method is equivalent to calling
|
* method is equivalent to calling
|
||||||
* <pre>
|
* {@snippet lang=java :
|
||||||
* getBundle(baseName, targetLocale, this.getClass().getClassLoader(),
|
* getBundle(baseName, targetLocale, this.getClass().getClassLoader(),
|
||||||
* control),
|
* control);
|
||||||
* </pre>
|
* }
|
||||||
* except that {@code getClassLoader()} is run with the security
|
* except that {@code getClassLoader()} is run with the security
|
||||||
* privileges of {@code ResourceBundle}. See {@link
|
* privileges of {@code ResourceBundle}. See {@link
|
||||||
* #getBundle(String, Locale, ClassLoader, Control) getBundle} for the
|
* #getBundle(String, Locale, ClassLoader, Control) getBundle} for the
|
||||||
|
@ -1075,14 +1073,14 @@ public abstract class ResourceBundle {
|
||||||
* <p>When this method is called from a named module and the given
|
* <p>When this method is called from a named module and the given
|
||||||
* loader is the class loader of the caller module, this is equivalent
|
* loader is the class loader of the caller module, this is equivalent
|
||||||
* to calling:
|
* to calling:
|
||||||
* <blockquote><pre>
|
* {@snippet lang=java :
|
||||||
* getBundle(baseName, targetLocale, callerModule)
|
* getBundle(baseName, targetLocale, callerModule);
|
||||||
* </pre></blockquote>
|
* }
|
||||||
*
|
*
|
||||||
* otherwise, this is equivalent to calling:
|
* otherwise, this is equivalent to calling:
|
||||||
* <blockquote><pre>
|
* {@snippet lang=java :
|
||||||
* getBundle(baseName, targetLocale, loader, control)
|
* getBundle(baseName, targetLocale, loader, control);
|
||||||
* </pre></blockquote>
|
* }
|
||||||
* where {@code control} is the default instance of {@link Control} unless
|
* where {@code control} is the default instance of {@link Control} unless
|
||||||
* a {@code Control} instance is provided by
|
* a {@code Control} instance is provided by
|
||||||
* {@link ResourceBundleControlProvider} SPI. Refer to the
|
* {@link ResourceBundleControlProvider} SPI. Refer to the
|
||||||
|
@ -2432,14 +2430,14 @@ public abstract class ResourceBundle {
|
||||||
* <p>The following code lets {@code ResourceBundle.getBundle} look
|
* <p>The following code lets {@code ResourceBundle.getBundle} look
|
||||||
* up only properties-based resources.
|
* up only properties-based resources.
|
||||||
*
|
*
|
||||||
* <pre>
|
* {@snippet lang=java :
|
||||||
* import java.util.*;
|
* import java.util.*;
|
||||||
* import static java.util.ResourceBundle.Control.*;
|
* import static java.util.ResourceBundle.Control.*;
|
||||||
* ...
|
* code: // @replace substring="code:" replacement="..."
|
||||||
* ResourceBundle bundle =
|
* ResourceBundle bundle =
|
||||||
* ResourceBundle.getBundle("MyResources", Locale.forLanguageTag("fr-CH"),
|
* ResourceBundle.getBundle("MyResources", Locale.forLanguageTag("fr-CH"),
|
||||||
* ResourceBundle.Control.getControl(FORMAT_PROPERTIES));
|
* ResourceBundle.Control.getControl(FORMAT_PROPERTIES));
|
||||||
* </pre>
|
* }
|
||||||
*
|
*
|
||||||
* Given the resource bundles in the <a
|
* Given the resource bundles in the <a
|
||||||
* href="./ResourceBundle.html#default_behavior_example">example</a> in
|
* href="./ResourceBundle.html#default_behavior_example">example</a> in
|
||||||
|
@ -2456,10 +2454,10 @@ public abstract class ResourceBundle {
|
||||||
* using {@link Properties#loadFromXML(java.io.InputStream)
|
* using {@link Properties#loadFromXML(java.io.InputStream)
|
||||||
* Properties.loadFromXML}.
|
* Properties.loadFromXML}.
|
||||||
*
|
*
|
||||||
* <pre>
|
* {@snippet lang=java :
|
||||||
* ResourceBundle rb = ResourceBundle.getBundle("Messages",
|
* ResourceBundle rb = ResourceBundle.getBundle("Messages",
|
||||||
* new ResourceBundle.Control() {
|
* new ResourceBundle.Control() {
|
||||||
* public List<String> getFormats(String baseName) {
|
* public List<String> getFormats(String baseName) {
|
||||||
* if (baseName == null)
|
* if (baseName == null)
|
||||||
* throw new NullPointerException();
|
* throw new NullPointerException();
|
||||||
* return Arrays.asList("xml");
|
* return Arrays.asList("xml");
|
||||||
|
@ -2504,7 +2502,7 @@ public abstract class ResourceBundle {
|
||||||
* }
|
* }
|
||||||
* });
|
* });
|
||||||
*
|
*
|
||||||
* ...
|
* code: // @replace substring="code:" replacement="..."
|
||||||
*
|
*
|
||||||
* private static class XMLResourceBundle extends ResourceBundle {
|
* private static class XMLResourceBundle extends ResourceBundle {
|
||||||
* private Properties props;
|
* private Properties props;
|
||||||
|
@ -2515,11 +2513,11 @@ public abstract class ResourceBundle {
|
||||||
* protected Object handleGetObject(String key) {
|
* protected Object handleGetObject(String key) {
|
||||||
* return props.getProperty(key);
|
* return props.getProperty(key);
|
||||||
* }
|
* }
|
||||||
* public Enumeration<String> getKeys() {
|
* public Enumeration<String> getKeys() {
|
||||||
* ...
|
* code: // @replace substring="code:" replacement="..."
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* </pre>
|
* }
|
||||||
*
|
*
|
||||||
* @apiNote {@code ResourceBundle.Control} is not supported
|
* @apiNote {@code ResourceBundle.Control} is not supported
|
||||||
* in named modules. If the {@code ResourceBundle.getBundle} method with
|
* in named modules. If the {@code ResourceBundle.getBundle} method with
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue