本文整理匯總了Java中org.apache.commons.lang3.text.StrSubstitutor.setEnableSubstitutionInVariables方法的典型用法代碼示例。如果您正苦於以下問題:Java StrSubstitutor.setEnableSubstitutionInVariables方法的具體用法?Java StrSubstitutor.setEnableSubstitutionInVariables怎麽用?Java StrSubstitutor.setEnableSubstitutionInVariables使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.lang3.text.StrSubstitutor
的用法示例。
在下文中一共展示了StrSubstitutor.setEnableSubstitutionInVariables方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: loadConfigFromEnv
import org.apache.commons.lang3.text.StrSubstitutor; //導入方法依賴的package包/類
public static <T> T loadConfigFromEnv(Class<T> configurationClass, final String path)
throws IOException {
LOGGER.info("Parsing configuration file from {} ", path);
logProcessEnv();
final Path configPath = Paths.get(path);
final File file = configPath.toAbsolutePath().toFile();
final ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
final StrSubstitutor sub = new StrSubstitutor(new StrLookup<Object>() {
@Override
public String lookup(String key) {
return System.getenv(key);
}
});
sub.setEnableSubstitutionInVariables(true);
final String conf = sub.replace(FileUtils.readFileToString(file));
return mapper.readValue(conf, configurationClass);
}
示例2: initialize
import org.apache.commons.lang3.text.StrSubstitutor; //導入方法依賴的package包/類
@Override
public void initialize(Bootstrap<MutableSchedulerConfiguration> bootstrap) {
super.initialize(bootstrap);
StrSubstitutor strSubstitutor = new StrSubstitutor(new EnvironmentVariableLookup(false));
strSubstitutor.setEnableSubstitutionInVariables(true);
bootstrap.addBundle(new Java8Bundle());
bootstrap.setConfigurationSourceProvider(
new SubstitutingSourceProvider(
bootstrap.getConfigurationSourceProvider(),
strSubstitutor));
}
示例3: processTemplate
import org.apache.commons.lang3.text.StrSubstitutor; //導入方法依賴的package包/類
public String processTemplate(String template, Map<String, String> values) {
StrSubstitutor strSubstitutor = new StrSubstitutor(values);
strSubstitutor.setEnableSubstitutionInVariables(true);
return strSubstitutor.replace(template);
}
示例4: createChatMessage
import org.apache.commons.lang3.text.StrSubstitutor; //導入方法依賴的package包/類
private static Text createChatMessage(Player player, Player recipient, Text rawMessage) {
String chatFormat = RPChat.get().getConfig().getChatFormat();
StrSubstitutor sub = new StrSubstitutor(new MessageVarLookup(player, recipient, rawMessage));
sub.setEnableSubstitutionInVariables(true);
return TextSerializers.FORMATTING_CODE.deserializeUnchecked(sub.replace(chatFormat));
}
示例5: processTemplate
import org.apache.commons.lang3.text.StrSubstitutor; //導入方法依賴的package包/類
public String processTemplate(String template, Map<String, String> values)
{
StrSubstitutor strSubstitutor = new StrSubstitutor(values);
strSubstitutor.setEnableSubstitutionInVariables(true);
return strSubstitutor.replace(template);
}