mirror of https://github.com/apache/jclouds.git
Remove Strings2.replaceAll(String, Pattern, String)
Replace with direct calls to Pattern.matcher(String).replaceAll(String).
This commit is contained in:
parent
64e9a4e4c6
commit
d113b0ba63
|
@ -147,7 +147,7 @@ public class SignRequest implements HttpRequestFilter {
|
|||
// newline characters and extra embedded white spaces in the value.
|
||||
for (String value : request.getHeaders().get(header)) {
|
||||
value = value.replace(" ", " ");
|
||||
value = Strings2.replaceAll(value, NEWLINE_PATTERN, "");
|
||||
value = NEWLINE_PATTERN.matcher(value).replaceAll("");
|
||||
toSign.append(value).append(' ');
|
||||
}
|
||||
toSign.deleteCharAt(toSign.lastIndexOf(" "));
|
||||
|
|
|
@ -158,7 +158,7 @@ public class SharedKeyLiteAuthentication implements HttpRequestFilter {
|
|||
if (header.startsWith("x-ms-")) {
|
||||
toSign.append(header.toLowerCase()).append(":");
|
||||
for (String value : request.getHeaders().get(header)) {
|
||||
toSign.append(Strings2.replaceAll(value, NEWLINE_PATTERN, "")).append(",");
|
||||
toSign.append(NEWLINE_PATTERN.matcher(value).replaceAll("")).append(",");
|
||||
}
|
||||
toSign.deleteCharAt(toSign.lastIndexOf(","));
|
||||
toSign.append("\n");
|
||||
|
|
|
@ -62,9 +62,9 @@ public class BindAddInternetServiceToXmlPayload implements MapBinder {
|
|||
String payload = Strings2.replaceTokens(xmlTemplate,
|
||||
ImmutableMap.of("name", name, "protocol", protocol, "port", port, "enabled", enabled, "ns", ns));
|
||||
try {
|
||||
payload = Strings2.replaceAll(payload, Patterns.TOKEN_TO_PATTERN.get("description"), description == null ? ""
|
||||
payload = Patterns.TOKEN_TO_PATTERN.get("description").matcher(payload).replaceAll(description == null ? ""
|
||||
: String.format("\n\t<Description>%s</Description>", description));
|
||||
payload = Strings2.replaceAll(payload, Patterns.TOKEN_TO_PATTERN.get("monitor"), getMonitorString(postParams));
|
||||
payload = Patterns.TOKEN_TO_PATTERN.get("monitor").matcher(payload).replaceAll(getMonitorString(postParams));
|
||||
} catch (ExecutionException e) {
|
||||
Throwables.propagate(e);
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ public class BindAddNodeServiceToXmlPayload implements MapBinder {
|
|||
String payload = Strings2.replaceTokens(xmlTemplate,
|
||||
ImmutableMap.of("name", name, "ipAddress", ipAddress, "port", port, "enabled", enabled, "ns", ns));
|
||||
try {
|
||||
payload = Strings2.replaceAll(payload, Patterns.TOKEN_TO_PATTERN.get("description"), description == null ? ""
|
||||
payload = Patterns.TOKEN_TO_PATTERN.get("description").matcher(payload).replaceAll(description == null ? ""
|
||||
: String.format("\n <Description>%s</Description>", description));
|
||||
} catch (ExecutionException e) {
|
||||
Throwables.propagate(e);
|
||||
|
|
|
@ -113,12 +113,6 @@ public class Strings2 {
|
|||
}
|
||||
}
|
||||
|
||||
public static String replaceAll(String returnVal, Pattern pattern, String replace) {
|
||||
Matcher m = pattern.matcher(returnVal);
|
||||
returnVal = m.replaceAll(replace);
|
||||
return returnVal;
|
||||
}
|
||||
|
||||
public static String toString(InputSupplier<? extends InputStream> supplier)
|
||||
throws IOException {
|
||||
return CharStreams.toString(CharStreams.newReaderSupplier(supplier,
|
||||
|
@ -173,7 +167,7 @@ public class Strings2 {
|
|||
public static String replaceTokens(String input, Multimap<String, ?> tokenValues) {
|
||||
for (Entry<String, ?> tokenValue : tokenValues.entries()) {
|
||||
Pattern pattern = TOKEN_TO_PATTERN.getUnchecked(tokenValue.getKey());
|
||||
input = replaceAll(input, pattern, tokenValue.getValue().toString());
|
||||
input = pattern.matcher(input).replaceAll(tokenValue.getValue().toString());
|
||||
}
|
||||
return input;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue