< prev index next >

src/java.base/share/classes/java/time/format/DateTimeTextProvider.java

Print this page
rev 47480 : [mq]: 8176841


 493      * @param text  the text, not null
 494      * @param field  the field, not null
 495      * @return the entry, not null
 496      */
 497     private static <A, B> Entry<A, B> createEntry(A text, B field) {
 498         return new SimpleImmutableEntry<>(text, field);
 499     }
 500 
 501     /**
 502      * Returns the localized resource of the given key and locale, or null
 503      * if no localized resource is available.
 504      *
 505      * @param key  the key of the localized resource, not null
 506      * @param locale  the locale, not null
 507      * @return the localized resource, or null if not available
 508      * @throws NullPointerException if key or locale is null
 509      */
 510     @SuppressWarnings("unchecked")
 511     static <T> T getLocalizedResource(String key, Locale locale) {
 512         LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased()
 513                                     .getLocaleResources(locale);


 514         ResourceBundle rb = lr.getJavaTimeFormatData();
 515         return rb.containsKey(key) ? (T) rb.getObject(key) : null;
 516     }
 517 
 518     /**
 519      * Stores the text for a single locale.
 520      * <p>
 521      * Some fields have a textual representation, such as day-of-week or month-of-year.
 522      * These textual representations can be captured in this class for printing
 523      * and parsing.
 524      * <p>
 525      * This class is immutable and thread-safe.
 526      */
 527     static final class LocaleStore {
 528         /**
 529          * Map of value to text.
 530          */
 531         private final Map<TextStyle, Map<Long, String>> valueTextMap;
 532         /**
 533          * Parsable data.




 493      * @param text  the text, not null
 494      * @param field  the field, not null
 495      * @return the entry, not null
 496      */
 497     private static <A, B> Entry<A, B> createEntry(A text, B field) {
 498         return new SimpleImmutableEntry<>(text, field);
 499     }
 500 
 501     /**
 502      * Returns the localized resource of the given key and locale, or null
 503      * if no localized resource is available.
 504      *
 505      * @param key  the key of the localized resource, not null
 506      * @param locale  the locale, not null
 507      * @return the localized resource, or null if not available
 508      * @throws NullPointerException if key or locale is null
 509      */
 510     @SuppressWarnings("unchecked")
 511     static <T> T getLocalizedResource(String key, Locale locale) {
 512         LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased()
 513                                     .getLocaleResources(
 514                                         CalendarDataUtility.findRegionOverride(locale)
 515                                         .orElse(locale));
 516         ResourceBundle rb = lr.getJavaTimeFormatData();
 517         return rb.containsKey(key) ? (T) rb.getObject(key) : null;
 518     }
 519 
 520     /**
 521      * Stores the text for a single locale.
 522      * <p>
 523      * Some fields have a textual representation, such as day-of-week or month-of-year.
 524      * These textual representations can be captured in this class for printing
 525      * and parsing.
 526      * <p>
 527      * This class is immutable and thread-safe.
 528      */
 529     static final class LocaleStore {
 530         /**
 531          * Map of value to text.
 532          */
 533         private final Map<TextStyle, Map<Long, String>> valueTextMap;
 534         /**
 535          * Parsable data.


< prev index next >