本文整理匯總了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());
}
}
示例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();
}
示例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;
}
示例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();
}
示例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();
}
示例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);
}
}
示例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();
}
}
示例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();
}
示例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);
}
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例14: normalizeToken
import com.google.common.base.Ascii; //導入方法依賴的package包/類
private static String normalizeToken(String token) {
checkArgument(TOKEN_MATCHER.matchesAllOf(token));
return Ascii.toLowerCase(token);
}
示例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;
}