/* * Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * (C) Copyright Taligent, Inc. 1996, 1997 - All Rights Reserved * (C) Copyright IBM Corp. 1996 - 1998 - All Rights Reserved * * The original version of this source code and documentation * is copyrighted and owned by Taligent, Inc., a wholly-owned * subsidiary of IBM. These materials are provided under terms * of a License Agreement between Taligent and Sun. This technology * is protected by multiple US and International patents. * * This notice and attribution to Taligent may not be removed. * Taligent is a registered trademark of Taligent, Inc. * */ package sun.util.locale.provider; import java.lang.ref.ReferenceQueue; import java.lang.ref.SoftReference; import java.text.ListFormat; import java.text.MessageFormat; import java.text.NumberFormat; import java.util.Arrays; import java.util.Calendar; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedHashSet; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Objects; import java.util.ResourceBundle; import java.util.Set; import java.util.TimeZone; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.regex.Pattern; import java.util.stream.Stream; import sun.security.action.GetPropertyAction; import sun.util.resources.LocaleData; import sun.util.resources.OpenListResourceBundle; import sun.util.resources.ParallelListResourceBundle; import sun.util.resources.TimeZoneNamesBundle; /** * Central accessor to locale-dependent resources for JRE/CLDR provider adapters. * * @author Masayoshi Okutsu * @author Naoto Sato */ public class LocaleResources { private final Locale locale; private final LocaleData localeData; private final LocaleProviderAdapter.Type type; // Resource cache private final ConcurrentMap cache = new ConcurrentHashMap<>(); private final ReferenceQueue referenceQueue = new ReferenceQueue<>(); // cache key prefixes private static final String BREAK_ITERATOR_INFO = "BII."; private static final String CALENDAR_DATA = "CALD."; private static final String COLLATION_DATA = "COLD."; private static final String DECIMAL_FORMAT_SYMBOLS_DATA_CACHEKEY = "DFSD"; private static final String CURRENCY_NAMES = "CN."; private static final String LOCALE_NAMES = "LN."; private static final String TIME_ZONE_NAMES = "TZN."; private static final String ZONE_IDS_CACHEKEY = "ZID"; private static final String CALENDAR_NAMES = "CALN."; private static final String NUMBER_PATTERNS_CACHEKEY = "NP"; private static final String COMPACT_NUMBER_PATTERNS_CACHEKEY = "CNP"; private static final String DATE_TIME_PATTERN = "DTP."; private static final String RULES_CACHEKEY = "RULE"; private static final String SKELETON_PATTERN = "SP."; private static final String LIST_PATTERN = "LP."; // ResourceBundle key names for skeletons private static final String SKELETON_INPUT_REGIONS_KEY = "DateFormatItemInputRegions"; // TimeZoneNamesBundle exemplar city prefix private static final String TZNB_EXCITY_PREFIX = "timezone.excity."; // null singleton cache value private static final Object NULLOBJECT = new Object(); // RegEx pattern for skeleton validity checking private static final Pattern VALID_SKELETON_PATTERN = Pattern.compile( "(?" + "G{0,5}" + // Era "y*" + // Year "Q{0,5}" + // Quarter "M{0,5}" + // Month "w*" + // Week of Week Based Year "E{0,5}" + // Day of Week "d{0,2})" + // Day of Month "(?