Lines Matching defs:bundle

69  * load it from the resource bundle that is appropriate for the current user's
87 * resource bundle which simply has the same name as its family -
88 * "MyResources" - and will be used as the bundle of last resort if a
94 * Each resource bundle in a family contains the same items, but the items have
95 * been translated for the locale represented by that resource bundle.
122 * identify a locale-specific object in the bundle. Here's an
146 * You retrieve an object from resource bundle using the appropriate
189 * to perform the bundle loading process by the <code>getBundle</code>
192 * non-standard resource bundle formats, change the search strategy, or
199 * Resource bundle instances created by the <code>getBundle</code> factory
201 * resource bundle instance multiple times if it has been
203 * lifetime of cached resource bundle instances using time-to-live values,
204 * or specify not to cache resource bundle instances. Refer to the
270 /** initial size of the bundle cache */
273 /** constant indicating that no resource bundle exists */
282 * The cache is a map from cache keys (with bundle base name, locale, and
283 * class loader) to either a resource bundle or NONEXISTENT_BUNDLE wrapped by a
302 * The parent bundle of this bundle.
303 * The parent bundle is searched by {@link #getObject getObject}
304 * when this bundle does not contain a particular resource.
309 * The locale for this bundle.
314 * The base bundle name for this bundle.
319 * The flag indicating this bundle has expired in the cache.
324 * The back link to the cache key. null if this bundle isn't in
342 * Gets a string for the given key from this resource bundle or one of its parents.
359 * Gets a string array for the given key from this resource bundle or one of its parents.
376 * Gets an object for the given key from this resource bundle or one of its parents.
377 * This method first tries to obtain the object from this resource bundle using
379 * If not successful, and the parent resource bundle is not null,
395 throw new MissingResourceException("Can't find resource for bundle "
405 * Returns the locale of this resource bundle. This method can be used after a
406 * call to getBundle() to determine whether the resource bundle returned really
409 * @return the locale of this resource bundle
469 * Sets the parent bundle of this bundle.
470 * The parent bundle is searched by {@link #getObject getObject}
471 * when this bundle does not contain a particular resource.
473 * @param parent this bundle's parent bundle.
493 // bundle format which is necessary for calling
500 // The time when the bundle has been loaded
503 // The time when the bundle expires in the cache, or either
701 * Gets a resource bundle using the specified base name, the default locale,
711 * @param baseName the base name of the resource bundle, a fully qualified class name
715 * if no resource bundle for the specified base name can be found
716 * @return a resource bundle for the given base name and the default locale
728 * Returns a resource bundle using the specified base name, the
738 * complete description of the resource bundle loading process with a
742 * the base name of the resource bundle, a fully qualified class
745 * the control which gives information for the resource bundle
747 * @return a resource bundle for the given base name and the default
753 * if no resource bundle for the specified base name can be found
771 * Gets a resource bundle using the specified base name and locale,
782 * the base name of the resource bundle, a fully qualified class name
784 * the locale for which a resource bundle is desired
788 * if no resource bundle for the specified base name can be found
789 * @return a resource bundle for the given base name and locale
802 * Returns a resource bundle using the specified base name, target
812 * complete description of the resource bundle loading process with a
816 * the base name of the resource bundle, a fully qualified
819 * the locale for which a resource bundle is desired
822 * bundle loading process
823 * @return a resource bundle for the given base name and a
829 * if no resource bundle for the specified base name in any
848 * Gets a resource bundle using the specified base name, locale, and class
858 * name="candidates"><em>candidate bundle names</em></a>. If the specified
860 * then the base name is the only candidate bundle name. Otherwise, a list
874 * <p>Candidate bundle names where the final component is an empty string
876 * empty string, the second and the fifth candidate bundle names above
888 * sequence of bundle names generated by truncating the last underscore and
889 * the part following it is inserted after a candidate bundle name with the
891 * "Latn, country "US" and variant "WINDOWS_VISTA", and bundle base name
892 * "MyResource", the list of candidate bundle names below is generated:
906 * candidate bundle names contains extra names, or the order of bundle names
911 * <p><code>getBundle</code> then iterates over the candidate bundle names
913 * resource bundle. It uses the default controls' {@link Control#getFormats
914 * getFormats} method, which generates two bundle names for each generated
916 * each candidate bundle name, it attempts to create a resource bundle:
923 * bundle</em>.
927 * path name from the candidate bundle name by replacing all "." characters
933 * resource bundle, it is just a container of data, such as a file.) If it
936 * instance becomes the <em>result resource bundle</em>. </ul>
938 * <p>This continues until a result resource bundle is instantiated or the
939 * list of candidate bundle names is exhausted. If no matching resource
940 * bundle is found, the default control's {@link Control#getFallbackLocale
945 * <p>If still no result bundle is found, the base name alone is looked up. If
948 * <p><a name="parent_chain"/> Once a result resource bundle has been found,
949 * its <em>parent chain</em> is instantiated. If the result bundle already
955 * result resource bundle. (As before, candidate bundle names where the
957 * end of the candidate list, it tries the plain bundle name. With each of the
958 * candidate bundle names it attempts to instantiate a resource bundle (first
962 * bundle's {@link #setParent(java.util.ResourceBundle) setParent} method
963 * with the new resource bundle. This continues until the list of names
964 * is exhausted or the current bundle already has a non-null parent.
966 * <p>Once the parent chain is complete, the bundle is returned.
969 * bundles and might return the same resource bundle instance multiple times.
1012 * @param baseName the base name of the resource bundle, a fully qualified class name
1013 * @param locale the locale for which a resource bundle is desired
1014 * @param loader the class loader from which to load the resource bundle
1015 * @return a resource bundle for the given base name and locale
1019 * if no resource bundle for the specified base name can be found
1032 * Returns a resource bundle using the specified base name, target
1037 * bundles. Conceptually, the bundle loading process with the given
1042 * <li>This factory method looks up the resource bundle in the cache for
1044 * <code>loader</code>. If the requested resource bundle instance is
1051 * control.getFormats} method is called to get resource bundle formats
1052 * to produce bundle or resource names. The strings
1067 * instantiate a <code>ResourceBundle</code> for the base bundle name, a
1122 * <li>If the previous step has found no resource bundle, proceed to
1123 * Step 6. If a bundle has been found that is a base bundle (a bundle
1125 * <code>Locale("")</code>, return the bundle to the caller. If a bundle
1126 * has been found that is a base bundle, but the candidate locale list
1127 * contained locales other than Locale(""), put the bundle on hold and
1128 * proceed to Step 6. If a bundle has been found that is not a base
1129 * bundle, proceed to Step 7.</li>
1134 * finding a resource bundle. If the method returns a non-null locale,
1136 * from Step 3. Otherwise, if a base bundle was found and put on hold in
1140 * <li>At this point, we have found a resource bundle that's not the
1141 * base bundle. If this bundle set its parent during its instantiation,
1145 * found. Finally, the bundle is returned to the caller.</li>
1148 * <p>During the resource bundle loading process above, this factory
1152 * resource bundle found in the cache has expired, the factory method
1155 * method to determine whether the resource bundle needs to be reloaded.
1157 * <code>control.newBundle</code> to reload the resource bundle. If
1159 * method puts a dummy resource bundle in the cache as a mark of
1168 * <p>The following is an example of the bundle loading process with the
1173 * <li>Base bundle name: <code>foo.bar.Messages</code>
1181 * <p>First, <code>getBundle</code> tries loading a resource bundle in
1195 * because it's the base bundle. <code>getBundle</code> calls {@link
1199 * tries loading a bundle in the following sequence.
1218 * the base name of the resource bundle, a fully qualified
1221 * the locale for which a resource bundle is desired
1223 * the class loader from which to load the resource bundle
1226 * bundle loading process
1227 * @return a resource bundle for the given base name and locale
1233 * if no resource bundle for the specified base name can be found
1256 // name and loader will never change during the bundle loading
1260 ResourceBundle bundle = null;
1265 bundle = bundleRef.get();
1269 // If this bundle and all of its parents are valid (not expired),
1270 // then return this bundle. If any of the bundles is expired, we
1273 if (isValidBundle(bundle) && hasValidParentChain(bundle)) {
1274 return bundle;
1277 // No valid bundle was found in the cache, so we need to load the
1278 // resource bundle and its parents.
1296 bundle = findBundle(cacheKey, candidateLocales, formats, 0, control, baseBundle);
1298 // If the loaded bundle is the base bundle and exactly for the
1300 // bundle as the resulting one. If the loaded bundle is the base
1301 // bundle, it's put on hold until we finish processing all
1303 if (isValidBundle(bundle)) {
1304 boolean isBaseBundle = Locale.ROOT.equals(bundle.locale);
1305 if (!isBaseBundle || bundle.locale.equals(locale)
1307 && bundle.locale.equals(candidateLocales.get(0)))) {
1311 // If the base bundle has been loaded, keep the reference in
1315 baseBundle = bundle;
1320 if (bundle == null) {
1324 bundle = baseBundle;
1327 return bundle;
1369 // flag indicating the resource bundle has expired in the cache
1373 // attempting to load bundle.
1375 ResourceBundle bundle = findBundleInCache(cacheKey, control);
1376 if (isValidBundle(bundle)) {
1377 expiredBundle = bundle.expired;
1384 if (bundle.parent == parent) {
1385 return bundle;
1390 if (bundleRef != null && bundleRef.get() == bundle) {
1396 if (bundle != NONEXISTENT_BUNDLE) {
1400 bundle = loadBundle(cacheKey, formats, control, expiredBundle);
1401 if (bundle != null) {
1402 if (bundle.parent == null) {
1403 bundle.setParent(parent);
1405 bundle.locale = targetLocale;
1406 bundle = putBundleInCache(cacheKey, bundle, control);
1407 return bundle;
1410 // Put NONEXISTENT_BUNDLE in the cache as a mark that there's no bundle
1427 // Here we actually load the bundle in the order of formats
1431 ResourceBundle bundle = null;
1436 bundle = control.newBundle(cacheKey.getName(), targetLocale, format,
1446 if (bundle != null) {
1450 bundle.name = cacheKey.getName();
1451 bundle.locale = targetLocale;
1454 bundle.expired = false;
1459 return bundle;
1462 private static final boolean isValidBundle(ResourceBundle bundle) {
1463 return bundle != null && bundle != NONEXISTENT_BUNDLE;
1470 private static final boolean hasValidParentChain(ResourceBundle bundle) {
1472 while (bundle != null) {
1473 if (bundle.expired) {
1476 CacheKey key = bundle.cacheKey;
1483 bundle = bundle.parent;
1499 throw new MissingResourceException("Can't find bundle for base name "
1507 * Finds a bundle in the cache. Any expired bundles are marked as
1512 * @return the cached bundle, or null if the bundle is not found in the
1513 * cache or its parent has expired. <code>bundle.expire</code> is true
1514 * upon return if the bundle in the cache has expired.
1522 ResourceBundle bundle = bundleRef.get();
1523 if (bundle == null) {
1526 ResourceBundle p = bundle.parent;
1549 // someone else has started loading the same bundle and finds the
1550 // base bundle has expired. Then, what we get from the first
1551 // getBundle call includes the expired base bundle. However, if
1553 // base bundle has expired at the end of the loading process. The
1554 // expiration control doesn't guarantee that the returned bundle and
1562 assert bundle != NONEXISTENT_BUNDLE;
1563 bundle.expired = true;
1564 bundle.cacheKey = null;
1566 bundle = null;
1570 if (!bundle.expired && expirationTime >= 0 &&
1573 if (bundle != NONEXISTENT_BUNDLE) {
1575 // redundant concurrent calls for the same bundle.
1576 synchronized (bundle) {
1578 if (!bundle.expired && expirationTime >= 0 &&
1581 bundle.expired = control.needsReload(key.getName(),
1585 bundle,
1590 if (bundle.expired) {
1591 // If the bundle needs to be reloaded, then
1592 // remove the bundle from the cache, but
1593 // return the bundle with the expired flag
1595 bundle.cacheKey = null;
1599 // the same bundle instance
1607 bundle = null;
1611 return bundle;
1615 * Put a new bundle in the cache.
1617 * @param cacheKey the key for the resource bundle
1618 * @param bundle the resource bundle to be put in the cache
1620 * the bundle before this call, the one found in the cache is
1624 ResourceBundle bundle,
1629 BundleReference bundleRef = new BundleReference(bundle, referenceQueue, key);
1630 bundle.cacheKey = key;
1632 // Put the bundle in the cache if it's not been in the cache.
1635 // If someone else has put the same bundle in the cache before
1641 bundle.cacheKey = null;
1642 bundle = rb;
1653 return bundle;
1706 * Gets an object for the given key from this resource bundle.
1707 * Returns null if this resource bundle does not contain an
1807 * methods during the bundle loading process. In other words, a
1827 * variations of the default bundle loading process.
1834 * bundle. Otherwise, the <code>ResourceBundle.getBundle</code> methods
1851 * customize the bundle loading process. The following are examples of
1852 * changing the default bundle loading process.
1863 * ResourceBundle bundle =
1902 * ResourceBundle bundle = null;
1923 * bundle = new XMLResourceBundle(bis);
1927 * return bundle;
1984 * The time-to-live constant for not caching loaded resource bundle
1993 * for loaded resource bundle instances in the cache.
2103 * the base name of the resource bundle, a fully qualified class
2125 * resource bundle for a target <code>Locale</code>.
2133 * have the base bundle as the terminal of the parent chain.
2139 * the base bundle as the resulting resource bundle.
2290 * the base name of the resource bundle, a fully
2293 * the locale for which a resource bundle is desired
2353 // as bundle names (recommended for Java7+)
2421 * further resource bundle searches by the
2424 * resource bundle has been found for <code>baseName</code> and
2438 * the base name of the resource bundle, a fully
2442 * base bundle)
2447 * base bundle)
2464 * Instantiates a resource bundle for the given bundle name of the
2467 * resource bundle available for the given parameters. If a resource
2468 * bundle can't be instantiated due to an unexpected error, the
2475 * loaded resource bundle has expired.
2482 * <li>The bundle name is obtained by calling {@link
2487 * {@link Class} specified by the bundle name is loaded by calling
2518 * the base bundle name of the resource bundle, a fully
2521 * the locale for which the resource bundle should be
2524 * the resource bundle format to be loaded
2526 * the <code>ClassLoader</code> to use to load the bundle
2528 * the flag to indicate bundle reloading; <code>true</code>
2529 * if reloading an expired resource bundle,
2531 * @return the resource bundle instance,
2563 ResourceBundle bundle = null;
2572 bundle = bundleClass.newInstance();
2611 bundle = new PropertyResourceBundle(stream);
2619 return bundle;
2626 * specify the number of milliseconds a bundle can remain in the
2628 * it was constructed. The value 0 indicates that a bundle must be
2635 * <p>The expiration affects only the bundle loading process by the
2637 * if the factory method finds a resource bundle in the cache that
2641 * bundle needs to be reloaded. If <code>needsReload</code> returns
2642 * <code>true</code>, the cached resource bundle instance is removed
2654 * the base name of the resource bundle for which the
2657 * the locale of the resource bundle for which the
2676 * Determines if the expired <code>bundle</code> in the cache needs
2688 * bundle.
2692 * bundle. If it's determined that the source data has been modified
2701 * the base bundle name of the resource bundle, a
2704 * the locale for which the resource bundle
2707 * the resource bundle format to be loaded
2709 * the <code>ClassLoader</code> to use to load the bundle
2710 * @param bundle
2711 * the resource bundle instance that has been expired
2714 * the time when <code>bundle</code> was loaded and put
2716 * @return <code>true</code> if the expired bundle needs to be
2721 * <code>bundle</code> is <code>null</code>
2725 ResourceBundle bundle, long loadTime) {
2726 if (bundle == null) {
2766 * to the bundle name. This method is called from the default
2796 * the base name of the resource bundle, a fully
2799 * the locale for which a resource bundle should be
2801 * @return the bundle name for the resource bundle
2855 * the bundle name