本文整理汇总了Java中org.apache.commons.text.StrSubstitutor.replace方法的典型用法代码示例。如果您正苦于以下问题:Java StrSubstitutor.replace方法的具体用法?Java StrSubstitutor.replace怎么用?Java StrSubstitutor.replace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.text.StrSubstitutor
的用法示例。
在下文中一共展示了StrSubstitutor.replace方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: launch
import org.apache.commons.text.StrSubstitutor; //导入方法依赖的package包/类
public static void launch(LauncherModel launcher, ServerModel server, KeyModel key, ActionModel action, Map<String, String> params) {
params.put("host", server.getHost());
params.put("user", server.getUser());
params.put("keyPath", key.getPaths().get(launcher.getKeyFormat()));
StrSubstitutor sub = new StrSubstitutor(params);
String actionCommand = sub.replace(action.getCommand());
params.put("actionCommand", '"' + actionCommand + '"');
String shellCommand = sub.replace(launcher.getShellCommand());
params.put("shellCommand", shellCommand);
final List<String> terminalCommandList = launcher.getTerminalCommandList();
String[] terminalCommandArray = terminalCommandList.stream()
.map(sub::replace)
.collect(Collectors.toList())
.toArray(new String[terminalCommandList.size()]);
try {
final Process process = getRuntime().exec(terminalCommandArray);
process.waitFor();
} catch (IOException | InterruptedException e) {
e.printStackTrace();
}
}
示例2: parseInputField
import org.apache.commons.text.StrSubstitutor; //导入方法依赖的package包/类
private String parseInputField(String input, Map<String, String> replacements) {
if (input != null && input.length() > 0) {
StrSubstitutor substitutor = new StrSubstitutor(replacements);
String output = substitutor.replace(input);
checkForRemainingPlaceholders(output);
return output;
}
return input;
}
示例3: log
import org.apache.commons.text.StrSubstitutor; //导入方法依赖的package包/类
@Override
public void log(@NonNull final LogContext logContext)
{
String replacedMessage = StrSubstitutor.replace( CoreConfig.Logging.logFormat, logContext.toMap() );
if ( getPrintStream() != null )
{
getPrintStream().println( replacedMessage );
}
Bukkit.getConsoleSender()
.sendMessage( ChatColor.translateAlternateColorCodes( '&', replacedMessage ) );
}
示例4: buildCheckSessionIframe
import org.apache.commons.text.StrSubstitutor; //导入方法依赖的package包/类
private String buildCheckSessionIframe() {
return StrSubstitutor.replace(CHECK_SESSION_IFRAME_TEMPLATE,
Collections.singletonMap("cookieName", this.cookieName));
}
示例5: resolve
import org.apache.commons.text.StrSubstitutor; //导入方法依赖的package包/类
public String resolve(final String text) {
return StrSubstitutor.replace(text, environmentVariables.toJavaMap());
}