Java 类javax.annotation.PropertyKey 实例源码

项目:ph-commons    文件:EnumTextResolverWithPropertiesOverrideAndFallback.java   
@Override
@Nullable
protected String internalGetOverrideString (@Nonnull @PropertyKey final String sID,
                                            @Nonnull final Locale aContentLocale)
{
  // Try all possible locales of the passed locale
  for (final Locale aLocale : LocaleHelper.getCalculatedLocaleListForResolving (aContentLocale))
  {
    // Explicitly use a bundle name containing the locale in the base name to
    // avoid strange fallback behaviour to the default locale
    final String sBundleName = PREFIX_OVERRIDE + aLocale.toString ();
    final String ret = ResourceBundleHelper.getString (_getResourceBundle (sBundleName, aLocale), sID);
    if (ret != null)
    {
      // Match!
      m_aRWLock.writeLocked ( () -> m_aUsedOverrideBundles.add (sBundleName));
      return ret;
    }
  }
  return null;
}
项目:ph-commons    文件:EnumTextResolverWithPropertiesOverrideAndFallback.java   
@Override
@Nullable
protected String internalGetFallbackString (@Nonnull @PropertyKey final String sID,
                                            @Nonnull final Locale aContentLocale)
{
  // Try all possible locales of the passed locale
  for (final Locale aLocale : LocaleHelper.getCalculatedLocaleListForResolving (aContentLocale))
  {
    // Explicitly use a bundle name containing the locale in the base name to
    // avoid strange fallback behaviour to the default locale
    final String sBundleName = PREFIX_FALLBACK + aLocale.toString ();
    final String ret = ResourceBundleHelper.getString (_getResourceBundle (sBundleName, aLocale), sID);
    if (ret != null)
    {
      m_aRWLock.writeLocked ( () -> m_aUsedFallbackBundles.add (sBundleName));
      return ret;
    }
  }

  s_aStatsFailed.increment (PREFIX_FALLBACK + aContentLocale.toString () + ':' + sID);
  if (GlobalDebug.isDebugMode ())
  {
    s_aLogger.warn ("getFallbackString (" + sID + "; " + aContentLocale.toString () + ") failed!");

    // Return consistent results
    if (false)
      return "[fallback-" + sID.substring (sID.lastIndexOf ('.') + 1) + "-" + aContentLocale.toString () + "]";
  }
  return null;
}
项目:ph-commons    文件:ResourceBundleHelper.java   
@Nullable
public static String getString (@Nullable final ResourceBundle aResourceBundle,
                                @Nonnull @PropertyKey final String sKey)
{
  if (aResourceBundle != null)
    try
    {
      return aResourceBundle.getString (sKey);
    }
    catch (final MissingResourceException ex)
    {
      // Fall through
    }
  return null;
}
项目:ph-commons    文件:ResourceBundleHelper.java   
@Nullable
public static String getString (@Nonnull final String sBundleName,
                                @Nonnull final Locale aContentLocale,
                                @Nonnull @PropertyKey final String sKey)
{
  return getString (getResourceBundle (sBundleName, aContentLocale), sKey);
}
项目:ph-commons    文件:ResourceBundleHelper.java   
@Nullable
public static String getString (@Nonnull final String sBundleName,
                                @Nonnull final Locale aContentLocale,
                                @Nonnull @PropertyKey final String sKey,
                                @Nonnull final ClassLoader aClassLoader)
{
  return getString (getResourceBundle (sBundleName, aContentLocale, aClassLoader), sKey);
}
项目:ph-commons    文件:ResourceBundleHelper.java   
@Nullable
public static String getUtf8String (@Nonnull final String sBundleName,
                                    @Nonnull final Locale aContentLocale,
                                    @Nonnull @PropertyKey final String sKey)
{
  return getString (getUtf8ResourceBundle (sBundleName, aContentLocale), sKey);
}
项目:ph-commons    文件:ResourceBundleHelper.java   
@Nullable
public static String getUtf8String (@Nonnull final String sBundleName,
                                    @Nonnull final Locale aContentLocale,
                                    @Nonnull @PropertyKey final String sKey,
                                    @Nonnull final ClassLoader aClassLoader)
{
  return getString (getUtf8ResourceBundle (sBundleName, aContentLocale, aClassLoader), sKey);
}
项目:ph-commons    文件:ResourceBundleKey.java   
@Nonnull
@Nonempty
@PropertyKey
public String getKey ()
{
  return m_sKey;
}
项目:ph-commons    文件:ResourceBundleKey.java   
public ResourceBundleKey (@Nonnull @Nonempty final String sBundleName,
                          @Nonnull @Nonempty @PropertyKey final String sKey)
{
  m_sBundleName = ValueEnforcer.notEmpty (sBundleName, "BundleName");
  m_sKey = ValueEnforcer.notEmpty (sKey, "Key");
}