Java Code Examples for org.apache.commons.lang3.StringUtils.replaceOnce()

The following are Jave code examples for showing how to use replaceOnce() of the org.apache.commons.lang3.StringUtils class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: spring-cloud-samples   File: ErrorHolder.java   View Source Code Vote up 6 votes
public static String getMessage(CodeTemp templ, String... params) {
	String regContent = templ.getTemp();
	int index = 0;
	while (regContent.indexOf("{}") >= 0) {
		if (ArrayUtils.isEmpty(params) || params.length <= index) {
			if (regContent.indexOf("{}") >= 0) {
				regContent = regContent.replaceAll("\\{\\}", "");
			}
			break;
		}
		regContent = StringUtils.replaceOnce(regContent, "{}", params[index]);
		index++;
	}

	return regContent;
}
 
Example 2
Project: cyberduck   File: TildePathExpander.java   View Source Code Vote up 5 votes
protected Path expand(final Path remote, final String format) throws BackgroundException {
    if(remote.getAbsolute().startsWith(format)) {
        return new Path(StringUtils.replaceOnce(remote.getAbsolute(), format, workdir.getAbsolute()),
                remote.getType());
    }
    return remote;
}
 
Example 3
Project: jvm-sandbox   File: CoreConfigure.java   View Source Code Vote up 5 votes
private static String[] replaceWithSysPropUserHome(final String[] pathArray) {
    if (ArrayUtils.isEmpty(pathArray)) {
        return pathArray;
    }
    final String SYS_PROP_USER_HOME = System.getProperty("user.home");
    for (int index = 0; index < pathArray.length; index++) {
        if (StringUtils.startsWith(pathArray[index], "~")) {
            pathArray[index] = StringUtils.replaceOnce(pathArray[index], "~", SYS_PROP_USER_HOME);
        }
    }
    return pathArray;
}
 
Example 4
Project: che-starter   File: ProjectHelper.java   View Source Code Vote up 4 votes
private String changeProtocolToHttpsIfNeeded(final String repositoryUrl) {
    if (!StringUtils.isBlank(repositoryUrl) && repositoryUrl.startsWith(GIT_PROTOCOL)) {
        return StringUtils.replaceOnce(repositoryUrl.replace(":", "/"), GIT_PROTOCOL, HTTPS_PROTOCOL);
    }
    return repositoryUrl;
}
 
Example 5
Project: vscrawler   File: ReplaceOnce.java   View Source Code Vote up 4 votes
@Override
protected String handle(String input, String second, String third) {
    return StringUtils.replaceOnce(input, second, third);
}