com.google.common.base.Ascii#equalsIgnoreCase ( )源码实例Demo

下面列出了com.google.common.base.Ascii#equalsIgnoreCase ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

private static ZipPath obfuscateZipPath(
    ZipPath oldZipPath, ImmutableMap<String, String> resourceNameMapping) {
  HashCode hashCode = Hashing.sha256().hashString(oldZipPath.toString(), StandardCharsets.UTF_8);
  String encodedString =
      Base64.getUrlEncoder()
          .encodeToString(Arrays.copyOf(hashCode.asBytes(), RESOURCE_NAME_LENGTH));

  while (resourceNameMapping.containsValue("res/" + encodedString)) {
    encodedString = handleCollision(hashCode.asBytes());
  }
  String fileExtension = FileUtils.getFileExtension(oldZipPath);
  // The "xml" extension has to be preserved, because the Android Platform requires it
  if (Ascii.equalsIgnoreCase(fileExtension, "xml")) {
    encodedString = encodedString + "." + fileExtension;
  }
  return RESOURCES_DIRECTORY.resolve(encodedString);
}
 
源代码2 项目: copybara   文件: GeneralOptions.java
/**
 * Temporary features is mean to be used by Copybara team for guarding new codepaths. Should
 * never be used for user facing flags or longer term experiments. Any caller of this function
 * should have a todo saying when to remove the call.
 *
 * <p>If the flag doesn't have a value it will use defaultVal. If the flag is incorrect (different
 * from true/false) it will use defaultVal (And log at severe).
 */
public boolean isTemporaryFeature(String name, boolean defaultVal) {
  Preconditions.checkNotNull(name);
  String v = temporaryFeatures.get(name);
  if (v == null) {
    return defaultVal;
  }
  if (Ascii.equalsIgnoreCase(v, "true")) {
    return true;
  }
  if (Ascii.equalsIgnoreCase(v, "false")) {
    return false;
  }
  logger.atSevere()
      .withStackTrace(StackSize.SMALL)
      .log("Invalid boolean value for '%s' in '%s'. Needs to be true or false. Using default: %s",
          name, temporaryFeatures, defaultVal);
  return defaultVal;
}
 
源代码3 项目: armeria   文件: Http1RequestDecoder.java
private boolean handle100Continue(int id, HttpRequest nettyReq, HttpHeaders nettyHeaders) {
    if (nettyReq.protocolVersion().compareTo(HttpVersion.HTTP_1_1) < 0) {
        // Ignore HTTP/1.0 requests.
        return true;
    }

    final String expectValue = nettyHeaders.get(HttpHeaderNames.EXPECT);
    if (expectValue == null) {
        // No 'expect' header.
        return true;
    }

    // '100-continue' is the only allowed expectation.
    if (!Ascii.equalsIgnoreCase("100-continue", expectValue)) {
        return false;
    }

    // Send a '100 Continue' response.
    writer.writeHeaders(id, 1, CONTINUE_RESPONSE, false);

    // Remove the 'expect' header so that it's handled in a way invisible to a Service.
    nettyHeaders.remove(HttpHeaderNames.EXPECT);
    return true;
}
 
源代码4 项目: android-uiconductor   文件: MinicapUtil.java
private static String getMinicapFilePath(Device device, String minicapBasePath) {
  String minicapVersionSuffix = device.getSdkVersion();
  String abi = device.getAbi();
  String buildId = device.getBuildId();
  Integer sdkIntVersion = Ints.tryParse(minicapVersionSuffix);

  // For PPR1, the standard minicap.so for android-28 doesn't work. Keep this logic here since
  // there are still some devices in PPR1.
  if (Ascii.toUpperCase(buildId).contains("PPR1")
      || Ascii.toUpperCase(device.getReleaseVersion()).equals("9")) {
    minicapVersionSuffix = "28-ppr1";
  }

  List<String> androidRBuildIdKeyWordList = Arrays.asList("MASTER", "RP1A");
  boolean isAndroidRBranch =
      androidRBuildIdKeyWordList.stream()
          .parallel()
          .anyMatch(x -> Ascii.toUpperCase(buildId).contains(x));
  // 29 (Android Q) is the max version minicap currently supports.
  if (sdkIntVersion == null
      || sdkIntVersion > 29
      || isAndroidRBranch
      || Ascii.equalsIgnoreCase(device.getReleaseVersion(), "11")) {
    minicapVersionSuffix = "master";
  }

  return Paths.get(
          minicapBasePath,
          "jni",
          "minicap-shared",
          "aosp",
          "libs",
          "android-" + minicapVersionSuffix,
          abi,
          "minicap.so")
      .toString();
}
 
private static BluetoothDevice getConnectedBluetoothDevice(String deviceAddress)
        throws BluetoothHearingAidSnippetException {
    for (BluetoothDevice device : hearingAidProfile.getConnectedDevices()) {
        if (Ascii.equalsIgnoreCase(device.getAddress(), deviceAddress)) {
            return device;
        }
    }
    throw new BluetoothHearingAidSnippetException(String.format(
            "No device with address %s is connected via HA Profile.", deviceAddress));
}
 
源代码6 项目: sfs   文件: NullSafeAscii.java
public static boolean equalsIgnoreCase(CharSequence s1, CharSequence s2) {
    if (s1 == s2) {
        return true;
    } else if (s1 == null || s2 == null) {
        return false;
    } else {
        return Ascii.equalsIgnoreCase(s1, s2);
    }
}
 
/** Is this one of the ENGLISH_STOPWORDS, ignoring case? */

  private static boolean isStopword(String term) {
    for (String word : ENGLISH_STOPWORDS) {
      if (Ascii.equalsIgnoreCase(word, term)) {
        return true;
      }
    }
    return false;
  }
 
源代码8 项目: armeria   文件: MimeTypeUtil.java
@Nullable
static MediaType guessFromPath(String path, @Nullable String contentEncoding) {
    if (contentEncoding == null || Ascii.equalsIgnoreCase(contentEncoding, "identity")) {
        return guessFromPath(path);
    }

    requireNonNull(path, "path");
    // If the path is for a precompressed file, it will have an additional extension indicating the
    // encoding, which we don't want to use when determining content type.
    return guessFromPath(path.substring(0, path.lastIndexOf('.')));
}
 
源代码9 项目: armeria   文件: MediaType.java
private static boolean containsValue(String expectedValue, List<String> actualValues) {
    final int numActualValues = actualValues.size();
    for (int i = 0; i < numActualValues; i++) {
        if (Ascii.equalsIgnoreCase(expectedValue, actualValues.get(i))) {
            return true;
        }
    }
    return false;
}
 
源代码10 项目: bazel   文件: BlazeDirectories.java
@AutoCodec.Instantiator
public BlazeDirectories(
    ServerDirectories serverDirectories,
    Path workspace,
    Path defaultSystemJavabase,
    String productName) {
  this.serverDirectories = serverDirectories;
  this.workspace = workspace;
  this.defaultSystemJavabase = defaultSystemJavabase;
  this.productName = productName;
  Path outputBase = serverDirectories.getOutputBase();
  if (Ascii.equalsIgnoreCase(productName, "blaze")) {
    boolean useDefaultExecRootName =
        this.workspace == null || this.workspace.getParentDirectory() == null;
    if (useDefaultExecRootName) {
      // TODO(bazel-team): if workspace is null execRoot should be null, but at the moment there
      // is a lot of code that depends on it being non-null.
      this.blazeExecRoot = serverDirectories.getExecRootBase().getChild(DEFAULT_EXEC_ROOT);
    } else {
      this.blazeExecRoot = serverDirectories.getExecRootBase().getChild(workspace.getBaseName());
    }
    this.blazeOutputPath = blazeExecRoot.getRelative(getRelativeOutputPath());
  } else {
    this.blazeExecRoot = null;
    this.blazeOutputPath = null;
  }
  this.localOutputPath = outputBase.getRelative(getRelativeOutputPath());
}
 
源代码11 项目: grpc-java   文件: SdsX509TrustManager.java
/**
 * helper function for verifying URI or IP address. For now we compare IP addresses as strings
 * without any regard to IPv4 vs IPv6.
 *
 * @param stringFromCert either URI or IP address
 * @param verifySanList list of SANs from certificate context
 * @return true if there is a match
 */
private static boolean verifyStringInSanList(String stringFromCert, List<String> verifySanList) {
  for (String sanToVerify : verifySanList) {
    if (Ascii.equalsIgnoreCase(sanToVerify, stringFromCert)) {
      return true;
    }
  }
  return false;
}
 
源代码12 项目: j2cl   文件: JavaEnvironment.java
private static boolean isNonNullAnnotation(AnnotationMirror annotation) {
  Type annotationType = (Type) annotation.getAnnotationType();
  return JsInteropAnnotationUtils.isJsNonNullAnnotation(annotationType)
      || Ascii.equalsIgnoreCase(annotationType.asElement().getSimpleName().toString(), "Nonnull");
}
 
源代码13 项目: bazel   文件: HttpUtils.java
static boolean isProtocol(URL url, String protocol) {
  // An implementation should accept uppercase letters as equivalent to lowercase in scheme names
  // (e.g., allow "HTTP" as well as "http") for the sake of robustness. Quoth RFC3986 § 3.1
  return Ascii.equalsIgnoreCase(protocol, url.getProtocol());
}
 
源代码14 项目: bazel   文件: CppCompileAction.java
private static boolean startsWithIgnoreCase(String s, String prefix) {
  return s.length() >= prefix.length()
      && Ascii.equalsIgnoreCase(s.substring(0, prefix.length()), prefix);
}