本文整理了Java中java.nio.charset.Charset.equals()
方法的一些代码示例,展示了Charset.equals()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Charset.equals()
方法的具体详情如下:
包路径:java.nio.charset.Charset
类名称:Charset
方法名:equals
[英]Determines whether this charset equals to the given object. They are considered to be equal if they have the same canonical name.
[中]确定此字符集是否等于给定对象。如果它们具有相同的规范名称,则认为它们相等。
代码示例来源:origin: AsyncHttpClient/async-http-client
private static boolean isUtf8OrUsAscii(Charset charset) {
return charset.equals(UTF_8) || charset.equals(US_ASCII);
}
代码示例来源:origin: google/guava
@Override
public boolean equals(@Nullable Object o) {
if (o instanceof StringCharsetFunnel) {
StringCharsetFunnel funnel = (StringCharsetFunnel) o;
return this.charset.equals(funnel.charset);
}
return false;
}
代码示例来源:origin: google/guava
@Override
public ByteSource asByteSource(Charset charset) {
if (charset.equals(this.charset)) {
return ByteSource.this;
}
return super.asByteSource(charset);
}
代码示例来源:origin: google/guava
@Override
public CharSource asCharSource(Charset charset) {
if (charset.equals(this.charset)) {
return CharSource.this;
}
return super.asCharSource(charset);
}
代码示例来源:origin: prestodb/presto
@Override
public CharSource asCharSource(Charset charset) {
if (charset.equals(this.charset)) {
return CharSource.this;
}
return super.asCharSource(charset);
}
代码示例来源:origin: prestodb/presto
@Override
public boolean equals(@NullableDecl Object o) {
if (o instanceof StringCharsetFunnel) {
StringCharsetFunnel funnel = (StringCharsetFunnel) o;
return this.charset.equals(funnel.charset);
}
return false;
}
代码示例来源:origin: prestodb/presto
@Override
public ByteSource asByteSource(Charset charset) {
if (charset.equals(this.charset)) {
return ByteSource.this;
}
return super.asByteSource(charset);
}
代码示例来源:origin: prestodb/presto
@Override public boolean equals(@Nullable Object other) {
return other instanceof Challenge
&& ((Challenge) other).scheme.equals(scheme)
&& ((Challenge) other).realm.equals(realm)
&& ((Challenge) other).charset.equals(charset);
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public DataBuffer write(CharSequence charSequence, Charset charset) {
Assert.notNull(charSequence, "CharSequence must not be null");
Assert.notNull(charset, "Charset must not be null");
if (StandardCharsets.UTF_8.equals(charset)) {
ByteBufUtil.writeUtf8(this.byteBuf, charSequence);
}
else if (StandardCharsets.US_ASCII.equals(charset)) {
ByteBufUtil.writeAscii(this.byteBuf, charSequence);
}
else {
return PooledDataBuffer.super.write(charSequence, charset);
}
return this;
}
代码示例来源:origin: spring-projects/spring-framework
Assert.notNull(input, "Input String should not be null");
Assert.notNull(charset, "Charset should not be null");
if (StandardCharsets.US_ASCII.equals(charset)) {
return input;
Assert.isTrue(UTF_8.equals(charset) || ISO_8859_1.equals(charset),
"Charset should be UTF-8 or ISO-8859-1");
byte[] source = input.getBytes(charset);
代码示例来源:origin: netty/netty
@Override
public CharSequence getCharSequence(int index, int length, Charset charset) {
if (CharsetUtil.US_ASCII.equals(charset) || CharsetUtil.ISO_8859_1.equals(charset)) {
// ByteBufUtil.getBytes(...) will return a new copy which the AsciiString uses directly
return new AsciiString(ByteBufUtil.getBytes(this, index, length, true), false);
}
return toString(index, length, charset);
}
代码示例来源:origin: google/j2objc
@Override
public CharSource asCharSource(Charset charset) {
if (charset.equals(this.charset)) {
return CharSource.this;
}
return super.asCharSource(charset);
}
代码示例来源:origin: AsyncHttpClient/async-http-client
private static void encodeAndAppendFormField(StringBuilder sb, String field, Charset charset) {
if (charset.equals(UTF_8)) {
Utf8UrlEncoder.encodeAndAppendFormElement(sb, field);
} else {
try {
// TODO there's probably room for perf improvements
sb.append(URLEncoder.encode(field, charset.name()));
} catch (UnsupportedEncodingException e) {
// can't happen, as Charset was already resolved
}
}
}
代码示例来源:origin: google/j2objc
@Override
public ByteSource asByteSource(Charset charset) {
if (charset.equals(this.charset)) {
return ByteSource.this;
}
return super.asByteSource(charset);
}
代码示例来源:origin: google/j2objc
@Override
public boolean equals(@NullableDecl Object o) {
if (o instanceof StringCharsetFunnel) {
StringCharsetFunnel funnel = (StringCharsetFunnel) o;
return this.charset.equals(funnel.charset);
}
return false;
}
代码示例来源:origin: spring-projects/spring-framework
Assert.isTrue(UTF_8.equals(charset) || ISO_8859_1.equals(charset),
"Charset should be UTF-8 or ISO-8859-1");
byte[] value = input.substring(secondQuoteIndex + 1, input.length()).getBytes(charset);
代码示例来源:origin: prestodb/presto
@Override
public Buffer writeString(String string, int beginIndex, int endIndex, Charset charset) {
if (string == null) throw new IllegalArgumentException("string == null");
if (beginIndex < 0) throw new IllegalAccessError("beginIndex < 0: " + beginIndex);
if (endIndex < beginIndex) {
throw new IllegalArgumentException("endIndex < beginIndex: " + endIndex + " < " + beginIndex);
}
if (endIndex > string.length()) {
throw new IllegalArgumentException(
"endIndex > string.length: " + endIndex + " > " + string.length());
}
if (charset == null) throw new IllegalArgumentException("charset == null");
if (charset.equals(Util.UTF_8)) return writeUtf8(string, beginIndex, endIndex);
byte[] data = string.substring(beginIndex, endIndex).getBytes(charset);
return write(data, 0, data.length);
}
代码示例来源:origin: redisson/redisson
@Override
public CharSequence getCharSequence(int index, int length, Charset charset) {
if (CharsetUtil.US_ASCII.equals(charset) || CharsetUtil.ISO_8859_1.equals(charset)) {
// ByteBufUtil.getBytes(...) will return a new copy which the AsciiString uses directly
return new AsciiString(ByteBufUtil.getBytes(this, index, length, true), false);
}
return toString(index, length, charset);
}
代码示例来源:origin: netty/netty
@SuppressWarnings("deprecation")
static String decodeString(ByteBuf src, int readerIndex, int len, Charset charset) {
if (len == 0) {
return StringUtil.EMPTY_STRING;
}
final byte[] array;
final int offset;
if (src.hasArray()) {
array = src.array();
offset = src.arrayOffset() + readerIndex;
} else {
array = threadLocalTempArray(len);
offset = 0;
src.getBytes(readerIndex, array, 0, len);
}
if (CharsetUtil.US_ASCII.equals(charset)) {
// Fast-path for US-ASCII which is used frequently.
return new String(array, 0, offset, len);
}
return new String(array, offset, len, charset);
}
代码示例来源:origin: square/okhttp
if (charset == null || charset.equals(UTF_8)) {
encodedCharBuffer.writeUtf8CodePoint(codePoint);
} else {
内容来源于网络,如有侵权,请联系作者删除!