本文整理了Java中java.lang.String.equalsIgnoreCase()
方法的一些代码示例,展示了String.equalsIgnoreCase()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。String.equalsIgnoreCase()
方法的具体详情如下:
包路径:java.lang.String
类名称:String
方法名:equalsIgnoreCase
[英]Compares the specified string to this string ignoring the case of the characters and returns true if they are equal.
[中]将指定的字符串与此字符串进行比较,忽略字符的大小写,如果它们相等,则返回true。
代码示例来源:origin: square/okhttp
/**
* Returns true if {@code fieldName} is content specific and therefore should always be used
* from cached headers.
*/
static boolean isContentSpecificHeader(String fieldName) {
return "Content-Length".equalsIgnoreCase(fieldName)
|| "Content-Encoding".equalsIgnoreCase(fieldName)
|| "Content-Type".equalsIgnoreCase(fieldName);
}
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Determine if the HTTP method is supported by browsers (i.e. GET or POST).
*/
protected boolean isMethodBrowserSupported(String method) {
return ("get".equalsIgnoreCase(method) || "post".equalsIgnoreCase(method));
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Return {@code true} if the {@link #setSecure secure} flag has been set
* to {@code true} or if the {@link #getScheme scheme} is {@code https}.
* @see javax.servlet.ServletRequest#isSecure()
*/
@Override
public boolean isSecure() {
return (this.secure || HTTPS.equalsIgnoreCase(this.scheme));
}
代码示例来源:origin: square/okhttp
private boolean isDotDot(String input) {
return input.equals("..")
|| input.equalsIgnoreCase("%2e.")
|| input.equalsIgnoreCase(".%2e")
|| input.equalsIgnoreCase("%2e%2e");
}
代码示例来源:origin: square/okhttp
private static @Nullable String get(String[] namesAndValues, String name) {
for (int i = namesAndValues.length - 2; i >= 0; i -= 2) {
if (name.equalsIgnoreCase(namesAndValues[i])) {
return namesAndValues[i + 1];
}
}
return null;
}
代码示例来源:origin: square/okhttp
public Builder scheme(String scheme) {
if (scheme == null) {
throw new NullPointerException("scheme == null");
} else if (scheme.equalsIgnoreCase("http")) {
this.scheme = "http";
} else if (scheme.equalsIgnoreCase("https")) {
this.scheme = "https";
} else {
throw new IllegalArgumentException("unexpected scheme: " + scheme);
}
return this;
}
代码示例来源:origin: spring-projects/spring-framework
public PathExtensionPredicate(String extension) {
Assert.notNull(extension, "Extension must not be null");
this.extensionPredicate = s -> {
boolean match = extension.equalsIgnoreCase(s);
traceMatch("Extension", extension, s, match);
return match;
};
this.extension = extension;
}
代码示例来源:origin: spring-projects/spring-framework
private static int getPort(URI uri) {
int port = uri.getPort();
if (port == -1) {
if ("http".equalsIgnoreCase(uri.getScheme())) {
port = 80;
}
else if ("https".equalsIgnoreCase(uri.getScheme())) {
port = 443;
}
}
return port;
}
代码示例来源:origin: square/okhttp
private static boolean bodyHasUnknownEncoding(Headers headers) {
String contentEncoding = headers.get("Content-Encoding");
return contentEncoding != null
&& !contentEncoding.equalsIgnoreCase("identity")
&& !contentEncoding.equalsIgnoreCase("gzip");
}
}
代码示例来源:origin: square/okhttp
/** Equivalent to {@code build().get(name)}, but potentially faster. */
public @Nullable String get(String name) {
for (int i = namesAndValues.size() - 2; i >= 0; i -= 2) {
if (name.equalsIgnoreCase(namesAndValues.get(i))) {
return namesAndValues.get(i + 1);
}
}
return null;
}
代码示例来源:origin: square/okhttp
public Builder removeAll(String name) {
for (int i = 0; i < namesAndValues.size(); i += 2) {
if (name.equalsIgnoreCase(namesAndValues.get(i))) {
namesAndValues.remove(i); // name
namesAndValues.remove(i); // value
i -= 2;
}
}
return this;
}
代码示例来源:origin: square/retrofit
void addHeader(String name, String value) {
if ("Content-Type".equalsIgnoreCase(name)) {
try {
contentType = MediaType.get(value);
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException("Malformed content type: " + value, e);
}
} else {
requestBuilder.addHeader(name, value);
}
}
代码示例来源:origin: square/okhttp
/** Returns true if {@code certificate} matches {@code ipAddress}. */
private boolean verifyIpAddress(String ipAddress, X509Certificate certificate) {
List<String> altNames = getSubjectAltNames(certificate, ALT_IPA_NAME);
for (int i = 0, size = altNames.size(); i < size; i++) {
if (ipAddress.equalsIgnoreCase(altNames.get(i))) {
return true;
}
}
return false;
}
代码示例来源:origin: spring-projects/spring-framework
@Nullable
public Subscription getSubscription(String subscriptionId) {
for (Map.Entry<String, Set<DefaultSubscriptionRegistry.Subscription>> destinationEntry :
this.destinationLookup.entrySet()) {
for (Subscription sub : destinationEntry.getValue()) {
if (sub.getId().equalsIgnoreCase(subscriptionId)) {
return sub;
}
}
}
return null;
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (other == null || getClass() != other.getClass()) {
return false;
}
AbstractNameValueExpression<?> that = (AbstractNameValueExpression<?>) other;
return ((isCaseSensitiveName() ? this.name.equals(that.name) : this.name.equalsIgnoreCase(that.name)) &&
ObjectUtils.nullSafeEquals(this.value, that.value) && this.isNegated == that.isNegated);
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public boolean equals(Object other) {
if (this == other) {
return true;
}
if (!(other instanceof HttpCookie)) {
return false;
}
HttpCookie otherCookie = (HttpCookie) other;
return (this.name.equalsIgnoreCase(otherCookie.getName()));
}
代码示例来源:origin: spring-projects/spring-framework
private boolean isMultiple() throws JspException {
Object multiple = getMultiple();
if (multiple != null) {
String stringValue = multiple.toString();
return ("multiple".equalsIgnoreCase(stringValue) || Boolean.parseBoolean(stringValue));
}
return forceMultiple();
}
代码示例来源:origin: spring-projects/spring-framework
private boolean peekIdentifierToken(String identifierString) {
Token t = peekToken();
if (t == null) {
return false;
}
return (t.kind == TokenKind.IDENTIFIER && identifierString.equalsIgnoreCase(t.stringValue()));
}
代码示例来源:origin: square/okhttp
@Override public Sink createRequestBody(Request request, long contentLength) {
if ("chunked".equalsIgnoreCase(request.header("Transfer-Encoding"))) {
// Stream a request body of unknown length.
return newChunkedSink();
}
if (contentLength != -1) {
// Stream a request body of a known length.
return newFixedLengthSink(contentLength);
}
throw new IllegalStateException(
"Cannot stream a request body without chunked encoding or a known content length!");
}
代码示例来源:origin: google/guava
@GwtIncompatible // String.toUpperCase() has browser semantics
public void testEqualsIgnoreCaseUnicodeEquivalence() {
// Note that it's possible in future that the JDK's idea to toUpperCase() or equalsIgnoreCase()
// may change and break assumptions in this test [*]. This is not a bug in the implementation of
// Ascii.equalsIgnoreCase(), but it is a signal that its documentation may need updating as
// regards edge cases.
// The Unicode point {@code 00df} is the lowercase form of sharp-S (ß), whose uppercase is "SS".
assertEquals("PASSWORD", "pa\u00dfword".toUpperCase()); // [*]
assertFalse("pa\u00dfword".equalsIgnoreCase("PASSWORD")); // [*]
assertFalse(Ascii.equalsIgnoreCase("pa\u00dfword", "PASSWORD"));
}
}
内容来源于网络,如有侵权,请联系作者删除!