当前位置: 首页>>代码示例>>Java>>正文


Java ResourceBundle.getObject方法代码示例

本文整理汇总了Java中java.util.ResourceBundle.getObject方法的典型用法代码示例。如果您正苦于以下问题:Java ResourceBundle.getObject方法的具体用法?Java ResourceBundle.getObject怎么用?Java ResourceBundle.getObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.ResourceBundle的用法示例。


在下文中一共展示了ResourceBundle.getObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: runTest

import java.util.ResourceBundle; //导入方法依赖的package包/类
/**
 * Performs the test itself.
 *
 * @throws java.lang.Throwable
 */
protected void runTest() throws Throwable {

    String keys = getProperties(getDescendantClassLoader(), getPropertiesName()).getProperty(getName());

    ResourceBundle lrBundle=NbBundle.getBundle(getName());

    String[] lrTokens = keys.split(",");        
    int lnNumMissing = 0;
    StringBuffer lrBufMissing = new StringBuffer();
    for (String lsKey : lrTokens)
    try {
        lrBundle.getObject(lsKey);
    } catch (MissingResourceException mre) {
        lrBufMissing.append(lsKey).append(" ");
        lnNumMissing++;
    }
    if (lnNumMissing > 0)
        throw new AssertionFailedError("Missing "+String.valueOf(lnNumMissing)+" key(s): "+ lrBufMissing.toString());

}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:TestBundleKeys.java

示例2: initialize

import java.util.ResourceBundle; //导入方法依赖的package包/类
@Override
public void initialize(URL url, ResourceBundle rb) {
    // TODO
    udp = (UDPConnector)rb.getObject("UDPConnector");
    
    REMOTE_DESKTOP.setOnMouseClicked(listener ->{
        calculatePostition(listener.getSceneX(), listener.getSceneY());
        System.out.println("Clicked...");
    });

    
    REMOTE_DESKTOP.setOnKeyPressed( listener ->{
        try {
            commitCharacter(listener.getText());
        } catch (BufferException ex) {
            Logger.getLogger(RemoteDesktopSceneController.class.getName()).log(Level.SEVERE, null, ex);
        }
    });
}
 
开发者ID:Obsidiam,项目名称:amelia,代码行数:20,代码来源:RemoteDesktopSceneController.java

示例3: compareResources

import java.util.ResourceBundle; //导入方法依赖的package包/类
private static void compareResources(ResourceBundle compat, ResourceBundle cldr) {
    Set<String> supplementalKeys = getSupplementalKeys(compat);
    for (String key : supplementalKeys) {
        Object compatData = compat.getObject(key);
        String cldrKey = toCldrKey(key);
        Object cldrData = cldr.containsKey(cldrKey) ? cldr.getObject(cldrKey) : null;
        if (!Objects.deepEquals(compatData, cldrData)) {
            // OK if key is for the Buddhist or Japanese calendars which had been
            // supported before java.time, or if key is "java.time.short.Eras" due
            // to legacy era names.
            if (!(key.contains("buddhist") || key.contains("japanese")
                  || key.equals("java.time.short.Eras"))) {
                errors++;
                System.out.print("Failure: ");
            }
            System.out.println("diff: " + compat.getLocale().toLanguageTag() + "\n"
                               + "  COMPAT: " + key + " -> " + toString(compatData) + "\n"
                               + "    CLDR: " + cldrKey + " -> " + toString(cldrData));
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:JavaTimeSupplementaryTest.java

示例4: getResourceBundleObject

import java.util.ResourceBundle; //导入方法依赖的package包/类
private static Object getResourceBundleObject(String messageKey, Locale locale) {

    // slow resource checking
    // need to loop thru all registered resource bundles
    for (Iterator<String> it = bundles.keySet().iterator(); it.hasNext();) {
      Class<? extends NLS> clazz = bundles.get(it.next());
      ResourceBundle resourceBundle = ResourceBundle.getBundle(clazz.getName(),
          locale);
      if (resourceBundle != null) {
        try {
          Object obj = resourceBundle.getObject(messageKey);
          if (obj != null)
            return obj;
        } catch (MissingResourceException e) {
          // just continue it might be on the next resource bundle
        }
      }
    }
    // if resource is not found
    return null;
  }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:NLS.java

示例5: getOrientation

import java.util.ResourceBundle; //导入方法依赖的package包/类
/**
 * Returns the orientation appropriate for the given ResourceBundle's
 * localization.  Three approaches are tried, in the following order:
 * <ol>
 * <li>Retrieve a ComponentOrientation object from the ResourceBundle
 *      using the string "Orientation" as the key.
 * <li>Use the ResourceBundle.getLocale to determine the bundle's
 *      locale, then return the orientation for that locale.
 * <li>Return the default locale's orientation.
 * </ol>
 *
 * @deprecated As of J2SE 1.4, use {@link #getOrientation(java.util.Locale)}.
 */
@Deprecated
public static ComponentOrientation getOrientation(ResourceBundle bdl)
{
    ComponentOrientation result = null;

    try {
        result = (ComponentOrientation)bdl.getObject("Orientation");
    }
    catch (Exception e) {
    }

    if (result == null) {
        result = getOrientation(bdl.getLocale());
    }
    if (result == null) {
        result = getOrientation(Locale.getDefault());
    }
    return result;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:33,代码来源:ComponentOrientation.java

示例6: getOrientation

import java.util.ResourceBundle; //导入方法依赖的package包/类
/**
 * Returns the orientation appropriate for the given ResourceBundle's
 * localization.  Three approaches are tried, in the following order:
 * <ol>
 * <li>Retrieve a ComponentOrientation object from the ResourceBundle
 *      using the string "Orientation" as the key.
 * <li>Use the ResourceBundle.getLocale to determine the bundle's
 *      locale, then return the orientation for that locale.
 * <li>Return the default locale's orientation.
 * </ol>
 *
 * @param  bdl the bundle to use
 * @return the orientation
 * @deprecated As of J2SE 1.4, use {@link #getOrientation(java.util.Locale)}.
 */
@Deprecated
public static ComponentOrientation getOrientation(ResourceBundle bdl)
{
    ComponentOrientation result = null;

    try {
        result = (ComponentOrientation)bdl.getObject("Orientation");
    }
    catch (Exception e) {
    }

    if (result == null) {
        result = getOrientation(bdl.getLocale());
    }
    if (result == null) {
        result = getOrientation(Locale.getDefault());
    }
    return result;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:35,代码来源:ComponentOrientation.java

示例7: handleGetObject

import java.util.ResourceBundle; //导入方法依赖的package包/类
@Override
protected Object handleGetObject(String key) {
	for (ResourceBundle bundle : bundles) {
		if (bundle.containsKey(key)) {
			return bundle.getObject(key);
		}
	}
	return null;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:10,代码来源:ExtensibleResourceBundle.java

示例8: getHolidays

import java.util.ResourceBundle; //导入方法依赖的package包/类
/**
 * @draft ICU 3.2
 * @provisional This API might change or be removed in a future release.
 */
public static Holiday[] getHolidays(ULocale locale)
{
    Holiday[] result = noHolidays;

    try {
        ResourceBundle bundle = UResourceBundle.getBundleInstance("com.ibm.icu.impl.data.HolidayBundle", locale);

        result = (Holiday[]) bundle.getObject("holidays");
    }
    catch (MissingResourceException e) {
    }
    return result;
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:18,代码来源:Holiday.java

示例9: setUpAndValidateDefaultBundle

import java.util.ResourceBundle; //导入方法依赖的package包/类
private static void setUpAndValidateDefaultBundle(
  BundleContext  context)
{
  ResourceBundle bundle = context.getLoadedBundle();
  _LOG.fine("Testing default bundle:{0}",context.getLoadedBundleName());
  Enumeration<String> en = bundle.getKeys();
  while (en.hasMoreElements())
  {
    String key = en.nextElement();
    Object value = bundle.getObject(key);

    assertNotNull(value);

    String valueStr = value.toString().trim();
    if (valueStr.length() == 0)
    {
      String errorMsg
       = "Error while testing bundle " + context.getBundleName() + "\n" +
         "check value for key " +
         key +  " " +
         "Null or zero length string is not allowed";
      _LOG.severe(errorMsg);
      fail(errorMsg);
    }

    _validateBundleValue(context, valueStr, key);

    _DEF_BUNDLE_PARAMS.put(key, _getPlaceHolders(value.toString()));
    _DEF_BUNDLE_KEYS.add(key);
  }
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:32,代码来源:MessageBundleTest.java

示例10: _getBundleString

import java.util.ResourceBundle; //导入方法依赖的package包/类
/**
 * @param bundle Bundle in which translated string is to be found for given key
 * @param key
 * @return
 */
private static String _getBundleString(ResourceBundle bundle, String key)
{
  try
  {
    Object localeStr = bundle.getObject(key);
    return localeStr == null ? null : localeStr.toString();
  }
  catch (MissingResourceException mre)
  {
    _LOG.finer("Key {0} not found in {1}", new Object[]{key, bundle});
    return null;
  }
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:19,代码来源:LocaleUtils.java

示例11: getResourceCache

import java.util.ResourceBundle; //导入方法依赖的package包/类
/**
 * Returns a Map of the known resources for the given locale.
 */
private Map<String, Object> getResourceCache(Locale l) {
    Map<String, Object> values = resourceCache.get(l);

    if (values == null) {
        values = new TextAndMnemonicHashMap();
        for (int i=resourceBundles.size()-1; i >= 0; i--) {
            String bundleName = resourceBundles.get(i);
            try {
                Control c = CoreResourceBundleControl.getRBControlInstance(bundleName);
                ResourceBundle b;
                if (c != null) {
                    b = ResourceBundle.getBundle(bundleName, l, c);
                } else {
                    b = ResourceBundle.getBundle(bundleName, l);
                }
                Enumeration keys = b.getKeys();

                while (keys.hasMoreElements()) {
                    String key = (String)keys.nextElement();

                    if (values.get(key) == null) {
                        Object value = b.getObject(key);

                        values.put(key, value);
                    }
                }
            } catch( MissingResourceException mre ) {
                // Keep looking
            }
        }
        resourceCache.put(l, values);
    }
    return values;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:38,代码来源:UIDefaults.java

示例12: toMap

import java.util.ResourceBundle; //导入方法依赖的package包/类
/**
 * Creates a new HashMap using data copied from a ResourceBundle.
 *
 * @param resourceBundle  the resource bundle to convert, may not be null
 * @return the hashmap containing the data
 * @throws NullPointerException if the bundle is null
 */
public static Map<String, Object> toMap(final ResourceBundle resourceBundle) {
    final Enumeration<String> enumeration = resourceBundle.getKeys();
    final Map<String, Object> map = new HashMap<String, Object>();

    while (enumeration.hasMoreElements()) {
        final String key = enumeration.nextElement();
        final Object value = resourceBundle.getObject(key);
        map.put(key, value);
    }

    return map;
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:20,代码来源:MapUtils.java

示例13: getValue

import java.util.ResourceBundle; //导入方法依赖的package包/类
/**
 * Get a resource given bundle name and key
 * @param <T> type of the resource
 * @param bundleName name of the resource bundle
 * @param key to lookup the resource
 * @param suffix for the key to lookup
 * @param defaultValue of the resource
 * @return the resource or the defaultValue
 * @throws ClassCastException if the resource found doesn't match T
 */
@SuppressWarnings("unchecked")
public static synchronized <T> T getValue(String bundleName, String key,
                                          String suffix, T defaultValue) {
  T value;
  try {
    ResourceBundle bundle = getBundle(bundleName);
    value = (T) bundle.getObject(getLookupKey(key, suffix));
  }
  catch (Exception e) {
    return defaultValue;
  }
  return value;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:24,代码来源:ResourceBundles.java

示例14: getResourceCache

import java.util.ResourceBundle; //导入方法依赖的package包/类
/**
 * Returns a Map of the known resources for the given locale.
 */
private Map<String, Object> getResourceCache(Locale l) {
    Map<String, Object> values = resourceCache.get(l);

    if (values == null) {
        values = new TextAndMnemonicHashMap();
        for (int i=resourceBundles.size()-1; i >= 0; i--) {
            String bundleName = resourceBundles.get(i);
            try {
                ResourceBundle b;
                if (isDesktopResourceBundle(bundleName)) {
                    // load resource bundle from java.desktop module
                    b = ResourceBundle.getBundle(bundleName, l, UIDefaults.class.getModule());
                } else {
                    b = ResourceBundle.getBundle(bundleName, l, ClassLoader.getSystemClassLoader());
                }
                Enumeration<String> keys = b.getKeys();

                while (keys.hasMoreElements()) {
                    String key = keys.nextElement();

                    if (values.get(key) == null) {
                        Object value = b.getObject(key);

                        values.put(key, value);
                    }
                }
            } catch( MissingResourceException mre ) {
                // Keep looking
            }
        }
        resourceCache.put(l, values);
    }
    return values;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:38,代码来源:UIDefaults.java

示例15: getLocalizedResource

import java.util.ResourceBundle; //导入方法依赖的package包/类
/**
 * Returns the localized resource of the given key and locale, or null
 * if no localized resource is available.
 *
 * @param key  the key of the localized resource, not null
 * @param locale  the locale, not null
 * @return the localized resource, or null if not available
 * @throws NullPointerException if key or locale is null
 */
@SuppressWarnings("unchecked")
static <T> T getLocalizedResource(String key, Locale locale) {
    LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased()
                                .getLocaleResources(locale);
    ResourceBundle rb = lr.getJavaTimeFormatData();
    return rb.containsKey(key) ? (T) rb.getObject(key) : null;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:17,代码来源:DateTimeTextProvider.java


注:本文中的java.util.ResourceBundle.getObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。