@Test public void testParsePropInput() { Assert.assertEquals("${PROP.doesNotExist}", SpecialValuesReplace.replace("${PROP.doesNotExist}", null, null, null, null)); System.getProperties().setProperty("nifty.test", "existsInSystem"); Properties myProperties = new Properties(); myProperties.setProperty("nifty.test", "existsInMyProperties"); Assert.assertEquals("existsInSystem", SpecialValuesReplace.replace("${PROP.nifty.test}", null, null, null, null)); Assert.assertEquals("existsInMyProperties", SpecialValuesReplace.replace("${PROP.nifty.test}", null, null, myProperties, null)); }
@Nonnull public static String replace( @Nullable final String input, @Nonnull final Map<String, BundleInfo> resourceBundles, @Nullable final Object methodCallTarget, @Nullable final Properties properties, @Nonnull final Locale locale) { if (input == null) { return ""; } if (!Split.containsKey(input)) { return input; } List<String> parts = Split.split(input); for (int idx=0; idx<parts.size(); idx++) { String part = parts.get(idx); String prev = getPrev(parts, idx); if (isSpecialTag(part, prev)) { String value = removeQuotes(part); if (value.startsWith(KEY_ENV)) { parts.set(idx, handleENV(part)); } else if (value.startsWith(KEY_PROP)) { parts.set(idx, handleProperties(part, properties)); } else if (value.startsWith(KEY_CALL)) { parts.set(idx, handleCall(part, methodCallTarget)); } else { parts.set(idx, handleLocalize(part, resourceBundles, locale)); } } else { if (endsWithQuote(prev)) { assert prev != null; parts.set(idx-1, prev.substring(0, prev.length()-1)); } } } String result = Split.join(parts); if (log.isLoggable(Level.FINER)) { log.finer(MessageFormat.format("Parsed input \"{0}\" to \"{1}\"", input, result)); } return result; }
SpecialValuesReplace { @Nonnull public static String replace( @Nullable final String input, @Nonnull final Map<String, BundleInfo> resourceBundles, @Nullable final Object methodCallTarget, @Nullable final Properties properties, @Nonnull final Locale locale) { if (input == null) { return ""; } if (!Split.containsKey(input)) { return input; } List<String> parts = Split.split(input); for (int idx=0; idx<parts.size(); idx++) { String part = parts.get(idx); String prev = getPrev(parts, idx); if (isSpecialTag(part, prev)) { String value = removeQuotes(part); if (value.startsWith(KEY_ENV)) { parts.set(idx, handleENV(part)); } else if (value.startsWith(KEY_PROP)) { parts.set(idx, handleProperties(part, properties)); } else if (value.startsWith(KEY_CALL)) { parts.set(idx, handleCall(part, methodCallTarget)); } else { parts.set(idx, handleLocalize(part, resourceBundles, locale)); } } else { if (endsWithQuote(prev)) { assert prev != null; parts.set(idx-1, prev.substring(0, prev.length()-1)); } } } String result = Split.join(parts); if (log.isLoggable(Level.FINER)) { log.finer(MessageFormat.format("Parsed input \"{0}\" to \"{1}\"", input, result)); } return result; } }
SpecialValuesReplace { @Nonnull public static String replace( @Nullable final String input, @Nonnull final Map<String, BundleInfo> resourceBundles, @Nullable final Object methodCallTarget, @Nullable final Properties properties, @Nonnull final Locale locale) { if (input == null) { return ""; } if (!Split.containsKey(input)) { return input; } List<String> parts = Split.split(input); for (int idx=0; idx<parts.size(); idx++) { String part = parts.get(idx); String prev = getPrev(parts, idx); if (isSpecialTag(part, prev)) { String value = removeQuotes(part); if (value.startsWith(KEY_ENV)) { parts.set(idx, handleENV(part)); } else if (value.startsWith(KEY_PROP)) { parts.set(idx, handleProperties(part, properties)); } else if (value.startsWith(KEY_CALL)) { parts.set(idx, handleCall(part, methodCallTarget)); } else { parts.set(idx, handleLocalize(part, resourceBundles, locale)); } } else { if (endsWithQuote(prev)) { assert prev != null; parts.set(idx-1, prev.substring(0, prev.length()-1)); } } } String result = Split.join(parts); if (log.isLoggable(Level.FINER)) { log.finer(MessageFormat.format("Parsed input \"{0}\" to \"{1}\"", input, result)); } return result; }  }
SpecialValuesReplace { @Nonnull public static String replace( @Nullable final String input, @Nonnull final Map<String, BundleInfo> resourceBundles, @Nullable final Object methodCallTarget, @Nullable final Properties properties, @Nonnull final Locale locale) { if (input == null) { return ""; } if (!Split.containsKey(input)) { return input; } List<String> parts = Split.split(input); for (int idx=0; idx<parts.size(); idx++) { String part = parts.get(idx); String prev = getPrev(parts, idx); if (isSpecialTag(part, prev)) { String value = removeQuotes(part); if (value.startsWith(KEY_ENV)) { parts.set(idx, handleENV(part)); } else if (value.startsWith(KEY_PROP)) { parts.set(idx, handleProperties(part, properties)); } else if (value.startsWith(KEY_CALL)) { parts.set(idx, handleCall(part, methodCallTarget)); } else { parts.set(idx, handleLocalize(part, resourceBundles, locale)); } } else { if (endsWithQuote(prev)) { assert prev != null; parts.set(idx-1, prev.substring(0, prev.length()-1)); } } } String result = Split.join(parts); if (log.isLoggable(Level.FINER)) { log.finer(MessageFormat.format("Parsed input \"{0}\" to \"{1}\"", input, result)); } return result; }  @Nonnull static String replace(
      @Nullable final String input,
      @Nonnull final Map<String, BundleInfo> resourceBundles,
      @Nullable final Object methodCallTarget,
      @Nullable final Properties properties,
      @Nonnull final Locale locale); }
SpecialValuesReplace { @Nonnull public static String replace( @Nullable final String input, @Nonnull final Map<String, BundleInfo> resourceBundles, @Nullable final Object methodCallTarget, @Nullable final Properties properties, @Nonnull final Locale locale) { if (input == null) { return ""; } if (!Split.containsKey(input)) { return input; } List<String> parts = Split.split(input); for (int idx=0; idx<parts.size(); idx++) { String part = parts.get(idx); String prev = getPrev(parts, idx); if (isSpecialTag(part, prev)) { String value = removeQuotes(part); if (value.startsWith(KEY_ENV)) { parts.set(idx, handleENV(part)); } else if (value.startsWith(KEY_PROP)) { parts.set(idx, handleProperties(part, properties)); } else if (value.startsWith(KEY_CALL)) { parts.set(idx, handleCall(part, methodCallTarget)); } else { parts.set(idx, handleLocalize(part, resourceBundles, locale)); } } else { if (endsWithQuote(prev)) { assert prev != null; parts.set(idx-1, prev.substring(0, prev.length()-1)); } } } String result = Split.join(parts); if (log.isLoggable(Level.FINER)) { log.finer(MessageFormat.format("Parsed input \"{0}\" to \"{1}\"", input, result)); } return result; }  @Nonnull static String replace(
      @Nullable final String input,
      @Nonnull final Map<String, BundleInfo> resourceBundles,
      @Nullable final Object methodCallTarget,
      @Nullable final Properties properties,
      @Nonnull final Locale locale);  }