src/java.base/share/classes/java/util/spi/TimeZoneNameProvider.java
author chegar
Thu, 17 Oct 2019 20:54:25 +0100
branchdatagramsocketimpl-branch
changeset 58679 9c3209ff7550
parent 58678 9cf78a70fa4f
parent 58288 48e480e56aad
permissions -rw-r--r--
datagramsocketimpl-branch: merge with default
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
58242
94bb65cb37d3 8230648: Replace @exception tag with @throws in java.base
jboes
parents: 52773
diff changeset
     2
 * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package java.util.spi;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.util.Locale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * An abstract class for service providers that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * provide localized time zone names for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * {@link java.util.TimeZone TimeZone} class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * The localized time zone names available from the implementations of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * this class are also the source for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * {@link java.text.DateFormatSymbols#getZoneStrings()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * DateFormatSymbols.getZoneStrings()} method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * @since        1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
public abstract class TimeZoneNameProvider extends LocaleServiceProvider {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
     * Sole constructor.  (For invocation by subclass constructors, typically
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
     * implicit.)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    protected TimeZoneNameProvider() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
     * Returns a name for the given time zone ID that's suitable for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
     * presentation to the user in the specified locale. The given time
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
     * zone ID is "GMT" or one of the names defined using "Zone" entries
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
     * in the "tz database", a public domain time zone database at
52773
61e442695048 8212878: host in ftp: link not found
naoto
parents: 47216
diff changeset
    55
     * <a href="https://www.iana.org/time-zones">https://www.iana.org/time-zones</a>.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
     * The data of this database is contained in a file whose name starts with
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
     * "tzdata", and the specification of the data format is part of the zic.8
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
     * man page, which is contained in a file whose name starts with "tzcode".
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
     * <p>
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
    60
     * If {@code daylight} is true, the method should return a name
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     * appropriate for daylight saving time even if the specified time zone
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     * has not observed daylight saving time in the past.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     * @param ID a time zone ID string
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     * @param daylight if true, return the daylight saving name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     * @param style either {@link java.util.TimeZone#LONG TimeZone.LONG} or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     *    {@link java.util.TimeZone#SHORT TimeZone.SHORT}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     * @param locale the desired locale
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     * @return the human-readable name of the given time zone in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     *     given locale, or null if it's not available.
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
    71
     * @throws    IllegalArgumentException if {@code style} is invalid,
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
    72
     *     or {@code locale} isn't one of the locales returned from
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     *     {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     *     getAvailableLocales()}.
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
    75
     * @throws    NullPointerException if {@code ID} or {@code locale}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     *     is null
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * @see java.util.TimeZone#getDisplayName(boolean, int, java.util.Locale)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    public abstract String getDisplayName(String ID, boolean daylight, int style, Locale locale);
14765
0987999ed367 8000983: Support narrow display names for calendar fields
okutsu
parents: 5506
diff changeset
    80
0987999ed367 8000983: Support narrow display names for calendar fields
okutsu
parents: 5506
diff changeset
    81
    /**
0987999ed367 8000983: Support narrow display names for calendar fields
okutsu
parents: 5506
diff changeset
    82
     * Returns a generic name for the given time zone {@code ID} that's suitable
0987999ed367 8000983: Support narrow display names for calendar fields
okutsu
parents: 5506
diff changeset
    83
     * for presentation to the user in the specified {@code locale}. Generic
0987999ed367 8000983: Support narrow display names for calendar fields
okutsu
parents: 5506
diff changeset
    84
     * time zone names are neutral from standard time and daylight saving
0987999ed367 8000983: Support narrow display names for calendar fields
okutsu
parents: 5506
diff changeset
    85
     * time. For example, "PT" is the short generic name of time zone ID {@code
0987999ed367 8000983: Support narrow display names for calendar fields
okutsu
parents: 5506
diff changeset
    86
     * America/Los_Angeles}, while its short standard time and daylight saving
0987999ed367 8000983: Support narrow display names for calendar fields
okutsu
parents: 5506
diff changeset
    87
     * time names are "PST" and "PDT", respectively. Refer to
0987999ed367 8000983: Support narrow display names for calendar fields
okutsu
parents: 5506
diff changeset
    88
     * {@link #getDisplayName(String, boolean, int, Locale) getDisplayName}
0987999ed367 8000983: Support narrow display names for calendar fields
okutsu
parents: 5506
diff changeset
    89
     * for valid time zone IDs.
0987999ed367 8000983: Support narrow display names for calendar fields
okutsu
parents: 5506
diff changeset
    90
     *
0987999ed367 8000983: Support narrow display names for calendar fields
okutsu
parents: 5506
diff changeset
    91
     * <p>The default implementation of this method returns {@code null}.
0987999ed367 8000983: Support narrow display names for calendar fields
okutsu
parents: 5506
diff changeset
    92
     *
0987999ed367 8000983: Support narrow display names for calendar fields
okutsu
parents: 5506
diff changeset
    93
     * @param ID a time zone ID string
0987999ed367 8000983: Support narrow display names for calendar fields
okutsu
parents: 5506
diff changeset
    94
     * @param style either {@link java.util.TimeZone#LONG TimeZone.LONG} or
0987999ed367 8000983: Support narrow display names for calendar fields
okutsu
parents: 5506
diff changeset
    95
     *    {@link java.util.TimeZone#SHORT TimeZone.SHORT}
0987999ed367 8000983: Support narrow display names for calendar fields
okutsu
parents: 5506
diff changeset
    96
     * @param locale the desired locale
0987999ed367 8000983: Support narrow display names for calendar fields
okutsu
parents: 5506
diff changeset
    97
     * @return the human-readable generic name of the given time zone in the
0987999ed367 8000983: Support narrow display names for calendar fields
okutsu
parents: 5506
diff changeset
    98
     *     given locale, or {@code null} if it's not available.
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
    99
     * @throws    IllegalArgumentException if {@code style} is invalid,
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   100
     *     or {@code locale} isn't one of the locales returned from
14765
0987999ed367 8000983: Support narrow display names for calendar fields
okutsu
parents: 5506
diff changeset
   101
     *     {@link LocaleServiceProvider#getAvailableLocales()
0987999ed367 8000983: Support narrow display names for calendar fields
okutsu
parents: 5506
diff changeset
   102
     *     getAvailableLocales()}.
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   103
     * @throws    NullPointerException if {@code ID} or {@code locale}
14765
0987999ed367 8000983: Support narrow display names for calendar fields
okutsu
parents: 5506
diff changeset
   104
     *     is {@code null}
0987999ed367 8000983: Support narrow display names for calendar fields
okutsu
parents: 5506
diff changeset
   105
     * @since 1.8
0987999ed367 8000983: Support narrow display names for calendar fields
okutsu
parents: 5506
diff changeset
   106
     */
0987999ed367 8000983: Support narrow display names for calendar fields
okutsu
parents: 5506
diff changeset
   107
    public String getGenericDisplayName(String ID, int style, Locale locale) {
0987999ed367 8000983: Support narrow display names for calendar fields
okutsu
parents: 5506
diff changeset
   108
        return null;
0987999ed367 8000983: Support narrow display names for calendar fields
okutsu
parents: 5506
diff changeset
   109
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
}