Replace to(Upper|Lower)Case with Ascii.to$1Case

The presubmits are warning that toUpperCase() and toLowerCase() are locale-specific, and advise using Ascii.toUpperCase() and Ascii.toLowerCase() as a local-invariant alternative.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=127583677
This commit is contained in:
mountford 2016-07-15 15:10:13 -07:00 committed by Ben McIlwain
parent d9596fa30c
commit e72491e59b
22 changed files with 62 additions and 38 deletions

View file

@ -57,8 +57,8 @@ public final class Idn {
}
/**
* Translates a string from Unicode to ASCII Compatible Encoding (ACE), as defined by the ToASCII
* operation of <a href="http://www.ietf.org/rfc/rfc3490.txt">RFC 3490</a>.
* Translates a string from ASCII Compatible Encoding (ACE) to Unicode, as defined by the
* ToUnicode operation of <a href="http://www.ietf.org/rfc/rfc3490.txt">RFC 3490</a>.
*
* <p>This method always uses <a href="http://unicode.org/reports/tr46/">UTS46 transitional
* processing</a>.

View file

@ -16,11 +16,13 @@ package google.registry.util;
import static com.google.common.base.CharMatcher.javaLetterOrDigit;
import com.google.common.base.Ascii;
/** Utilities for working with {@code Registrar} objects. */
public class RegistrarUtils {
/** Strip out anything that isn't a letter or digit, and lowercase. */
public static String normalizeRegistrarName(String name) {
return javaLetterOrDigit().retainFrom(name).toLowerCase();
return Ascii.toLowerCase(javaLetterOrDigit().retainFrom(name));
}
/**
@ -29,6 +31,6 @@ public class RegistrarUtils {
* in Datastore, and is suitable for use in email addresses.
*/
public static String normalizeClientId(String clientId) {
return clientId.toLowerCase().replaceAll("[^a-z0-9\\-]", "");
return Ascii.toLowerCase(clientId).replaceAll("[^a-z0-9\\-]", "");
}
}

View file

@ -26,6 +26,7 @@ import static java.nio.charset.StandardCharsets.UTF_8;
import com.google.appengine.api.urlfetch.HTTPHeader;
import com.google.appengine.api.urlfetch.HTTPRequest;
import com.google.appengine.api.urlfetch.HTTPResponse;
import com.google.common.base.Ascii;
import com.google.common.base.Optional;
import com.google.common.net.MediaType;
import java.security.NoSuchAlgorithmException;
@ -49,9 +50,9 @@ public final class UrlFetchUtils {
}
private static Optional<String> getHeaderFirstInternal(Iterable<HTTPHeader> hdrs, String name) {
name = name.toLowerCase();
name = Ascii.toLowerCase(name);
for (HTTPHeader header : hdrs) {
if (header.getName().toLowerCase().equals(name)) {
if (Ascii.toLowerCase(header.getName()).equals(name)) {
return Optional.of(header.getValue());
}
}