當前位置: 首頁>>代碼示例>>Java>>正文


Java Ascii.toLowerCase方法代碼示例

本文整理匯總了Java中com.google.common.base.Ascii.toLowerCase方法的典型用法代碼示例。如果您正苦於以下問題:Java Ascii.toLowerCase方法的具體用法?Java Ascii.toLowerCase怎麽用?Java Ascii.toLowerCase使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.common.base.Ascii的用法示例。


在下文中一共展示了Ascii.toLowerCase方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testToString

import com.google.common.base.Ascii; //導入方法依賴的package包/類
public void testToString() {
  for (String inputName : SOMEWHERE_UNDER_PS) {
    InternetDomainName domain = InternetDomainName.from(inputName);

    /*
     * We would ordinarily use constants for the expected results, but
     * doing it by derivation allows us to reuse the test case definitions
     * used in other tests.
     */

    String expectedName = Ascii.toLowerCase(inputName);
    expectedName = expectedName.replaceAll("[\u3002\uFF0E\uFF61]", ".");

    if (expectedName.endsWith(".")) {
      expectedName = expectedName.substring(0, expectedName.length() - 1);
    }

    assertEquals(expectedName, domain.toString());
  }
}
 
開發者ID:paul-hammant,項目名稱:googles-monorepo-demo,代碼行數:21,代碼來源:InternetDomainNameTest.java

示例2: InternetDomainName

import com.google.common.base.Ascii; //導入方法依賴的package包/類
/**
 * Constructor used to implement {@link #from(String)}, and from subclasses.
 */
InternetDomainName(String name) {
  // Normalize:
  // * ASCII characters to lowercase
  // * All dot-like characters to '.'
  // * Strip trailing '.'

  name = Ascii.toLowerCase(DOTS_MATCHER.replaceFrom(name, '.'));

  if (name.endsWith(".")) {
    name = name.substring(0, name.length() - 1);
  }

  checkArgument(name.length() <= MAX_LENGTH, "Domain name too long: '%s':", name);
  this.name = name;

  this.parts = ImmutableList.copyOf(DOT_SPLITTER.split(name));
  checkArgument(parts.size() <= MAX_PARTS, "Domain has too many parts: '%s'", name);
  checkArgument(validateSyntax(parts), "Not a valid domain name: '%s'", name);

  this.publicSuffixIndex = findPublicSuffix();
}
 
開發者ID:paul-hammant,項目名稱:googles-monorepo-demo,代碼行數:25,代碼來源:InternetDomainName.java

示例3: endsWithWordOrIs

import com.google.common.base.Ascii; //導入方法依賴的package包/類
/**
 * True when s ends with suffix in a way that suffix is not part of a larger
 * word by camel-casing or underscore naming conventions.
 */
public static boolean endsWithWordOrIs(String s, String suffix) {
  if (suffix.isEmpty()) {
    return true;
  }
  String lc = Ascii.toLowerCase(s);
  if (lc.endsWith(suffix)) {
    int beforeSuffix = lc.length() - suffix.length() - 1;
    if (beforeSuffix < 0) {
      return true;
    }
    if (!Character.isLetterOrDigit(lc.charAt(beforeSuffix))) {
      return true;
    }
    if (Ascii.isLowerCase(s.charAt(beforeSuffix))
        && Ascii.isUpperCase(s.charAt(beforeSuffix + 1))) {
      return true;
    }
  }
  return false;
}
 
開發者ID:mikesamuel,項目名稱:closure-maven-plugin,代碼行數:25,代碼來源:Words.java

示例4: InternetDomainName

import com.google.common.base.Ascii; //導入方法依賴的package包/類
/**
 * Constructor used to implement {@link #from(String)}, and from subclasses.
 */

InternetDomainName(String name) {
  // Normalize:
  // * ASCII characters to lowercase
  // * All dot-like characters to '.'
  // * Strip trailing '.'
  name = Ascii.toLowerCase(DOTS_MATCHER.replaceFrom(name, '.'));
  if (name.endsWith(".")) {
    name = name.substring(0, name.length() - 1);
  }
  checkArgument(name.length() <= MAX_LENGTH, "Domain name too long: '%s':", name);
  this.name = name;
  this.parts = ImmutableList.copyOf(DOT_SPLITTER.split(name));
  checkArgument(parts.size() <= MAX_PARTS, "Domain has too many parts: '%s'", name);
  checkArgument(validateSyntax(parts), "Not a valid domain name: '%s'", name);
  this.publicSuffixIndex = findPublicSuffix();
}
 
開發者ID:antlr,項目名稱:codebuff,代碼行數:21,代碼來源:InternetDomainName.java

示例5: setHeader

import com.google.common.base.Ascii; //導入方法依賴的package包/類
public final T setHeader(String name, @Nullable String value) {
  checkArgument(CharMatcher.whitespace().matchesNoneOf(name));
  name = Ascii.toLowerCase(name);
  value = emptyToNull(value);
  switch (name) {
    case "content-type":
      setContentType(value == null ? null : MediaType.parse(value));
      break;
    case "content-length":
      setContentLength(value == null ? -1 : Long.parseLong(value));
      break;
    default:
      if (value == null) {
        headers.remove(name);
      } else {
        checkArgument(CRLF.matchesNoneOf(value));
        headers.put(name, checkNotNull(value));
      }
  }
  return castThis();
}
 
開發者ID:bazelbuild,項目名稱:rules_closure,代碼行數:22,代碼來源:HttpMessage.java

示例6: millisPerUnit

import com.google.common.base.Ascii; //導入方法依賴的package包/類
private static int millisPerUnit(String unit) {
  switch (Ascii.toLowerCase(unit)) {
    case "d":
      return DateTimeConstants.MILLIS_PER_DAY;
    case "h":
      return DateTimeConstants.MILLIS_PER_HOUR;
    case "m":
      return DateTimeConstants.MILLIS_PER_MINUTE;
    case "s":
      return DateTimeConstants.MILLIS_PER_SECOND;
    case "ms":
      return 1;
    default:
      throw new IllegalArgumentException("Unknown duration unit " + unit);
  }
}
 
開發者ID:GoogleCloudPlatform,項目名稱:pubsub,代碼行數:17,代碼來源:Driver.java

示例7: process

import com.google.common.base.Ascii; //導入方法依賴的package包/類
void process() {
  if (startType.getKind().isPrimitive()) {
    // taking a shortcut for primitives
    String typeName = Ascii.toLowerCase(startType.getKind().name());
    this.rawTypeName = typeName;
    this.returnTypeName = typeName;
    List<? extends AnnotationMirror> annotations = AnnotationMirrors.from(startType);
    if (!annotations.isEmpty()) {
      returnTypeName = typeAnnotationsToBuffer(annotations).append(typeName).toString();
    }
  } else {
    this.buffer = new StringBuilder(100);
    caseType(startType);

    if (workaroundTypeString != null) {
      // to not mix the mess, we just replace buffer with workaround produced type string
      this.buffer = new StringBuilder(workaroundTypeString);
    }

    // It seems that array type annotations are not exposed in javac
    // Nested type argument's type annotations are not exposed as well (in javac)
    // So currently we instert only for top level, declared type (here),
    // and primitives (see above)
    TypeKind k = startType.getKind();
    if (k == TypeKind.DECLARED || k == TypeKind.ERROR) {
      insertTypeAnnotationsIfPresent(startType, 0, rawTypeName.length());
    }

    this.returnTypeName = buffer.toString();
  }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:32,代碼來源:TypeStringProvider.java

示例8: serialize

import com.google.common.base.Ascii; //導入方法依賴的package包/類
@Override
public void serialize(ServerPort value,
                      JsonGenerator gen, SerializerProvider serializers) throws IOException {

    final InetSocketAddress localAddr = value.localAddress();
    final int port = localAddr.getPort();
    final String proto = Ascii.toLowerCase(value.protocol().uriText());
    final String host;

    if (localAddr.getAddress().isAnyLocalAddress()) {
        host = "*";
    } else {
        final String hs = localAddr.getHostString();
        if (NetUtil.isValidIpV6Address(hs)) {
            // Try to get the platform-independent consistent IPv6 address string.
            host = NetUtil.toAddressString(localAddr.getAddress());
        } else {
            host = hs;
        }
    }

    gen.writeStartObject();
    gen.writeObjectFieldStart("localAddress");
    gen.writeStringField("host", host);
    gen.writeNumberField("port", port);
    gen.writeEndObject();
    gen.writeStringField("protocol", proto);
    gen.writeEndObject();
}
 
開發者ID:line,項目名稱:centraldogma,代碼行數:30,代碼來源:CentralDogmaConfig.java

示例9: lowerCase

import com.google.common.base.Ascii; //導入方法依賴的package包/類
Alphabet lowerCase() {
  if (!hasUpperCase()) {
    return this;
  } else {
    checkState(!hasLowerCase(), "Cannot call lowerCase() on a mixed-case alphabet");
    char[] lowerCased = new char[chars.length];
    for (int i = 0; i < chars.length; i++) {
      lowerCased[i] = Ascii.toLowerCase(chars[i]);
    }
    return new Alphabet(name + ".lowerCase()", lowerCased);
  }
}
 
開發者ID:zugzug90,項目名稱:guava-mock,代碼行數:13,代碼來源:BaseEncoding.java

示例10: upperToHttpHeaderName

import com.google.common.base.Ascii; //導入方法依賴的package包/類
private static String upperToHttpHeaderName(String constantName,
    ImmutableBiMap<String, String> specialCases, ImmutableSet<String> uppercaseAcronyms) {
  if (specialCases.containsKey(constantName)) {
    return specialCases.get(constantName);
  }
  List<String> parts = Lists.newArrayList();
  for (String part : SPLITTER.split(constantName)) {
    if (!uppercaseAcronyms.contains(part)) {
      part = part.charAt(0) + Ascii.toLowerCase(part.substring(1));
    }
    parts.add(part);
  }
  return JOINER.join(parts);
}
 
開發者ID:zugzug90,項目名稱:guava-mock,代碼行數:15,代碼來源:HttpHeadersTest.java

示例11: schemeForName

import com.google.common.base.Ascii; //導入方法依賴的package包/類
/**
 * Looks up a scheme by name.
 * @return {@link Scheme#UNKNOWN} if schemeName is not recognized.
 */
public Scheme schemeForName(String schemeName) {
  String lSchemeName = Ascii.toLowerCase(schemeName);
  Scheme s = additionalSchemes.get(lSchemeName);
  if (s == null) {
    s = BuiltinScheme.forName(lSchemeName);
  }
  return s != null ? s : Scheme.UNKNOWN;
}
 
開發者ID:OWASP,項目名稱:url-classifier,代碼行數:13,代碼來源:SchemeLookupTable.java

示例12: Outputs

import com.google.common.base.Ascii; //導入方法依賴的package包/類
/**
 * @param opts the options for the compilation job.
 * @param source the entry point source file.
 */
public Outputs(
    PlanContext context,
    CssOptions opts,
    Sources.Source source) {

  String basename = FilenameUtils.removeExtension(
      source.relativePath.getName());
  String reldir = source.relativePath.getParent();
  @SuppressWarnings("synthetic-access")
  String orientation =
      opts.outputOrientation.size() == 1
      ? Ascii.toLowerCase(opts.outputOrientation.get(0).name()) : null;
      @SuppressWarnings("synthetic-access")
  String vendor =
      opts.vendor.size() == 1
      ? Ascii.toLowerCase(opts.vendor.get(0).name()) : null;
  PathTemplateSubstitutor ts;
  {
    ImmutableMap.Builder<String, String> b = ImmutableMap.builder();
    if (basename != null) { b.put("basename", basename); }
    if (reldir != null) { b.put("reldir", reldir); }
    if (orientation != null) { b.put("orientation", orientation); }
    if (vendor != null) { b.put("vendor", vendor); }
    ts = new PathTemplateSubstitutor(b.build());
  }
  File cssOutputDir = context.closureOutputDirectoryForExt(FileExt.CSS);
  this.css = ts.substitute(cssOutputDir, opts.output);
  this.sourceMap = ts.substitute(cssOutputDir, opts.sourceMapFile);
}
 
開發者ID:mikesamuel,項目名稱:closure-maven-plugin,代碼行數:34,代碼來源:CssOptions.java

示例13: Primitive

import com.google.common.base.Ascii; //導入方法依賴的package包/類
Primitive(Reference wrapper, String defaultValue) {
  this.wrapper = wrapper;
  this.typename = Ascii.toLowerCase(name());
  this.defaultValue = defaultValue;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:6,代碼來源:Type.java

示例14: normalizeToken

import com.google.common.base.Ascii; //導入方法依賴的package包/類
private static String normalizeToken(String token) {
  checkArgument(TOKEN_MATCHER.matchesAllOf(token));
  return Ascii.toLowerCase(token);
}
 
開發者ID:zugzug90,項目名稱:guava-mock,代碼行數:5,代碼來源:MediaType.java

示例15: normalizeParameterValue

import com.google.common.base.Ascii; //導入方法依賴的package包/類
private static String normalizeParameterValue(String attribute, String value) {
  return CHARSET_ATTRIBUTE.equals(attribute) ? Ascii.toLowerCase(value) : value;
}
 
開發者ID:zugzug90,項目名稱:guava-mock,代碼行數:4,代碼來源:MediaType.java


注:本文中的com.google.common.base.Ascii.toLowerCase方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。