/** * Gets the string from the key by locale and class-loader. * * @param key the key. * @param locale the locale. * @param classLoader the class loader. * @return the string corresponding to the key. */ private static String getKeyString(final Enum<?> key, Locale locale, ClassLoader classLoader) { String bundleName = key.getClass().getName(); String keyPrefix = key.getClass().getSimpleName(); Class<?> clazz = key.getClass(); if (clazz.isAnnotationPresent(ResourceKey.class)) { ResourceKey resourceKey = clazz.getAnnotation(ResourceKey.class); if (resourceKey.bundleName() != null && !resourceKey.bundleName().isEmpty()) { bundleName = resourceKey.bundleName(); } if (resourceKey.keyPrefix() != null && !resourceKey.keyPrefix().isEmpty()) { keyPrefix = resourceKey.keyPrefix(); } } ResourceBundle bundle = lookupBundle(bundleName, locale, classLoader); String value = bundle.getString(ResourceUtil.getBundleKey(keyPrefix, key.name())); return value; }
/** * Gets the string from the key by locale and class-loader. * * @param key the key. * @param locale the locale. * @param classLoader the class loader. * @return the string corresponding to the key. */ private static String getKeyString(final Enum<?> key, Locale locale, ClassLoader classLoader) { String bundleName = key.getClass().getName(); String keyPrefix = key.getClass().getSimpleName(); Class<?> clazz = key.getClass(); if (clazz.isAnnotationPresent(ResourceKey.class)) { ResourceKey resourceKey = clazz.getAnnotation(ResourceKey.class); if (resourceKey.bundleName() != null && !resourceKey.bundleName().isEmpty()) { bundleName = resourceKey.bundleName(); } if (resourceKey.keyPrefix() != null && !resourceKey.keyPrefix().isEmpty()) { keyPrefix = resourceKey.keyPrefix(); } } ResourceBundle bundle = lookupBundle(bundleName, locale, classLoader); String tmp = ResourceUtil.getBundleKey(keyPrefix, key.name()); String value = bundle.getString(tmp); return value; }