src/java.base/share/classes/java/util/spi/LocaleNameProvider.java
branchdatagramsocketimpl-branch
changeset 58678 9cf78a70fa4f
parent 48251 57148c79bd75
child 58679 9c3209ff7550
equal deleted inserted replaced
58677:13588c901957 58678:9cf78a70fa4f
     1 /*
     1 /*
     2  * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
    46 
    46 
    47     /**
    47     /**
    48      * Returns a localized name for the given <a href="http://www.rfc-editor.org/rfc/bcp/bcp47.txt">
    48      * Returns a localized name for the given <a href="http://www.rfc-editor.org/rfc/bcp/bcp47.txt">
    49      * IETF BCP47</a> language code and the given locale that is appropriate for
    49      * IETF BCP47</a> language code and the given locale that is appropriate for
    50      * display to the user.
    50      * display to the user.
    51      * For example, if <code>languageCode</code> is "fr" and <code>locale</code>
    51      * For example, if {@code languageCode} is "fr" and {@code locale}
    52      * is en_US, getDisplayLanguage() will return "French"; if <code>languageCode</code>
    52      * is en_US, getDisplayLanguage() will return "French"; if {@code languageCode}
    53      * is "en" and <code>locale</code> is fr_FR, getDisplayLanguage() will return "anglais".
    53      * is "en" and {@code locale} is fr_FR, getDisplayLanguage() will return "anglais".
    54      * If the name returned cannot be localized according to <code>locale</code>,
    54      * If the name returned cannot be localized according to {@code locale},
    55      * (say, the provider does not have a Japanese name for Croatian),
    55      * (say, the provider does not have a Japanese name for Croatian),
    56      * this method returns null.
    56      * this method returns null.
    57      * @param languageCode the language code string in the form of two to eight
    57      * @param languageCode the language code string in the form of two to eight
    58      *     lower-case letters between 'a' (U+0061) and 'z' (U+007A)
    58      *     lower-case letters between 'a' (U+0061) and 'z' (U+007A)
    59      * @param locale the desired locale
    59      * @param locale the desired locale
    60      * @return the name of the given language code for the specified locale, or null if it's not
    60      * @return the name of the given language code for the specified locale, or null if it's not
    61      *     available.
    61      *     available.
    62      * @exception NullPointerException if <code>languageCode</code> or <code>locale</code> is null
    62      * @throws    NullPointerException if {@code languageCode} or {@code locale} is null
    63      * @exception IllegalArgumentException if <code>languageCode</code> is not in the form of
    63      * @throws    IllegalArgumentException if {@code languageCode} is not in the form of
    64      *     two or three lower-case letters, or <code>locale</code> isn't
    64      *     two or three lower-case letters, or {@code locale} isn't
    65      *     one of the locales returned from
    65      *     one of the locales returned from
    66      *     {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
    66      *     {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
    67      *     getAvailableLocales()}.
    67      *     getAvailableLocales()}.
    68      * @see java.util.Locale#getDisplayLanguage(java.util.Locale)
    68      * @see java.util.Locale#getDisplayLanguage(java.util.Locale)
    69      */
    69      */
    71 
    71 
    72     /**
    72     /**
    73      * Returns a localized name for the given <a href="http://www.rfc-editor.org/rfc/bcp/bcp47.txt">
    73      * Returns a localized name for the given <a href="http://www.rfc-editor.org/rfc/bcp/bcp47.txt">
    74      * IETF BCP47</a> script code and the given locale that is appropriate for
    74      * IETF BCP47</a> script code and the given locale that is appropriate for
    75      * display to the user.
    75      * display to the user.
    76      * For example, if <code>scriptCode</code> is "Latn" and <code>locale</code>
    76      * For example, if {@code scriptCode} is "Latn" and {@code locale}
    77      * is en_US, getDisplayScript() will return "Latin"; if <code>scriptCode</code>
    77      * is en_US, getDisplayScript() will return "Latin"; if {@code scriptCode}
    78      * is "Cyrl" and <code>locale</code> is fr_FR, getDisplayScript() will return "cyrillique".
    78      * is "Cyrl" and {@code locale} is fr_FR, getDisplayScript() will return "cyrillique".
    79      * If the name returned cannot be localized according to <code>locale</code>,
    79      * If the name returned cannot be localized according to {@code locale},
    80      * (say, the provider does not have a Japanese name for Cyrillic),
    80      * (say, the provider does not have a Japanese name for Cyrillic),
    81      * this method returns null. The default implementation returns null.
    81      * this method returns null. The default implementation returns null.
    82      * @param scriptCode the four letter script code string in the form of title-case
    82      * @param scriptCode the four letter script code string in the form of title-case
    83      *     letters (the first letter is upper-case character between 'A' (U+0041) and
    83      *     letters (the first letter is upper-case character between 'A' (U+0041) and
    84      *     'Z' (U+005A) followed by three lower-case character between 'a' (U+0061)
    84      *     'Z' (U+005A) followed by three lower-case character between 'a' (U+0061)
    85      *     and 'z' (U+007A)).
    85      *     and 'z' (U+007A)).
    86      * @param locale the desired locale
    86      * @param locale the desired locale
    87      * @return the name of the given script code for the specified locale, or null if it's not
    87      * @return the name of the given script code for the specified locale, or null if it's not
    88      *     available.
    88      *     available.
    89      * @exception NullPointerException if <code>scriptCode</code> or <code>locale</code> is null
    89      * @throws    NullPointerException if {@code scriptCode} or {@code locale} is null
    90      * @exception IllegalArgumentException if <code>scriptCode</code> is not in the form of
    90      * @throws    IllegalArgumentException if {@code scriptCode} is not in the form of
    91      *     four title case letters, or <code>locale</code> isn't
    91      *     four title case letters, or {@code locale} isn't
    92      *     one of the locales returned from
    92      *     one of the locales returned from
    93      *     {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
    93      *     {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
    94      *     getAvailableLocales()}.
    94      *     getAvailableLocales()}.
    95      * @see java.util.Locale#getDisplayScript(java.util.Locale)
    95      * @see java.util.Locale#getDisplayScript(java.util.Locale)
    96      * @since 1.7
    96      * @since 1.7
   101 
   101 
   102     /**
   102     /**
   103      * Returns a localized name for the given <a href="http://www.rfc-editor.org/rfc/bcp/bcp47.txt">
   103      * Returns a localized name for the given <a href="http://www.rfc-editor.org/rfc/bcp/bcp47.txt">
   104      * IETF BCP47</a> region code (either ISO 3166 country code or UN M.49 area
   104      * IETF BCP47</a> region code (either ISO 3166 country code or UN M.49 area
   105      * codes) and the given locale that is appropriate for display to the user.
   105      * codes) and the given locale that is appropriate for display to the user.
   106      * For example, if <code>countryCode</code> is "FR" and <code>locale</code>
   106      * For example, if {@code countryCode} is "FR" and {@code locale}
   107      * is en_US, getDisplayCountry() will return "France"; if <code>countryCode</code>
   107      * is en_US, getDisplayCountry() will return "France"; if {@code countryCode}
   108      * is "US" and <code>locale</code> is fr_FR, getDisplayCountry() will return "Etats-Unis".
   108      * is "US" and {@code locale} is fr_FR, getDisplayCountry() will return "Etats-Unis".
   109      * If the name returned cannot be localized according to <code>locale</code>,
   109      * If the name returned cannot be localized according to {@code locale},
   110      * (say, the provider does not have a Japanese name for Croatia),
   110      * (say, the provider does not have a Japanese name for Croatia),
   111      * this method returns null.
   111      * this method returns null.
   112      * @param countryCode the country(region) code string in the form of two
   112      * @param countryCode the country(region) code string in the form of two
   113      *     upper-case letters between 'A' (U+0041) and 'Z' (U+005A) or the UN M.49 area code
   113      *     upper-case letters between 'A' (U+0041) and 'Z' (U+005A) or the UN M.49 area code
   114      *     in the form of three digit letters between '0' (U+0030) and '9' (U+0039).
   114      *     in the form of three digit letters between '0' (U+0030) and '9' (U+0039).
   115      * @param locale the desired locale
   115      * @param locale the desired locale
   116      * @return the name of the given country code for the specified locale, or null if it's not
   116      * @return the name of the given country code for the specified locale, or null if it's not
   117      *     available.
   117      *     available.
   118      * @exception NullPointerException if <code>countryCode</code> or <code>locale</code> is null
   118      * @throws    NullPointerException if {@code countryCode} or {@code locale} is null
   119      * @exception IllegalArgumentException if <code>countryCode</code> is not in the form of
   119      * @throws    IllegalArgumentException if {@code countryCode} is not in the form of
   120      *     two upper-case letters or three digit letters, or <code>locale</code> isn't
   120      *     two upper-case letters or three digit letters, or {@code locale} isn't
   121      *     one of the locales returned from
   121      *     one of the locales returned from
   122      *     {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
   122      *     {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
   123      *     getAvailableLocales()}.
   123      *     getAvailableLocales()}.
   124      * @see java.util.Locale#getDisplayCountry(java.util.Locale)
   124      * @see java.util.Locale#getDisplayCountry(java.util.Locale)
   125      */
   125      */
   126     public abstract String getDisplayCountry(String countryCode, Locale locale);
   126     public abstract String getDisplayCountry(String countryCode, Locale locale);
   127 
   127 
   128     /**
   128     /**
   129      * Returns a localized name for the given variant code and the given locale that
   129      * Returns a localized name for the given variant code and the given locale that
   130      * is appropriate for display to the user.
   130      * is appropriate for display to the user.
   131      * If the name returned cannot be localized according to <code>locale</code>,
   131      * If the name returned cannot be localized according to {@code locale},
   132      * this method returns null.
   132      * this method returns null.
   133      * @param variant the variant string
   133      * @param variant the variant string
   134      * @param locale the desired locale
   134      * @param locale the desired locale
   135      * @return the name of the given variant string for the specified locale, or null if it's not
   135      * @return the name of the given variant string for the specified locale, or null if it's not
   136      *     available.
   136      *     available.
   137      * @exception NullPointerException if <code>variant</code> or <code>locale</code> is null
   137      * @throws    NullPointerException if {@code variant} or {@code locale} is null
   138      * @exception IllegalArgumentException if <code>locale</code> isn't
   138      * @throws    IllegalArgumentException if {@code locale} isn't
   139      *     one of the locales returned from
   139      *     one of the locales returned from
   140      *     {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
   140      *     {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
   141      *     getAvailableLocales()}.
   141      *     getAvailableLocales()}.
   142      * @see java.util.Locale#getDisplayVariant(java.util.Locale)
   142      * @see java.util.Locale#getDisplayVariant(java.util.Locale)
   143      */
   143      */
   152      * @implSpec the default implementation returns {@code null}.
   152      * @implSpec the default implementation returns {@code null}.
   153      * @param key the Unicode Extension key, not null.
   153      * @param key the Unicode Extension key, not null.
   154      * @param locale the desired locale, not null.
   154      * @param locale the desired locale, not null.
   155      * @return the name of the given key string for the specified locale,
   155      * @return the name of the given key string for the specified locale,
   156      *  or null if it's not available.
   156      *  or null if it's not available.
   157      * @exception NullPointerException if {@code key} or {@code locale} is null
   157      * @throws    NullPointerException if {@code key} or {@code locale} is null
   158      * @exception IllegalArgumentException if {@code locale} isn't
   158      * @throws    IllegalArgumentException if {@code locale} isn't
   159      *     one of the locales returned from
   159      *     one of the locales returned from
   160      *     {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
   160      *     {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
   161      *     getAvailableLocales()}.
   161      *     getAvailableLocales()}.
   162      * @since 10
   162      * @since 10
   163      */
   163      */
   177      * @param type the Unicode Extension type, not null.
   177      * @param type the Unicode Extension type, not null.
   178      * @param key the Unicode Extension key for this {@code type}, not null.
   178      * @param key the Unicode Extension key for this {@code type}, not null.
   179      * @param locale the desired locale, not null.
   179      * @param locale the desired locale, not null.
   180      * @return the name of the given type string for the specified locale,
   180      * @return the name of the given type string for the specified locale,
   181      *  or null if it's not available.
   181      *  or null if it's not available.
   182      * @exception NullPointerException if {@code key}, {@code type} or {@code locale} is null
   182      * @throws    NullPointerException if {@code key}, {@code type} or {@code locale} is null
   183      * @exception IllegalArgumentException if {@code locale} isn't
   183      * @throws    IllegalArgumentException if {@code locale} isn't
   184      *     one of the locales returned from
   184      *     one of the locales returned from
   185      *     {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
   185      *     {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
   186      *     getAvailableLocales()}.
   186      *     getAvailableLocales()}.
   187      * @since 10
   187      * @since 10
   188      */
   188      */