@Override public boolean equals(@Nullable Object o) { if (o instanceof StringCharsetFunnel) { StringCharsetFunnel funnel = (StringCharsetFunnel) o; return this.charset.equals(funnel.charset); } return false; }
@Override public ByteSource asByteSource(Charset charset) { if (charset.equals(this.charset)) { return ByteSource.this; } return super.asByteSource(charset); }
@Override public CharSource asCharSource(Charset charset) { if (charset.equals(this.charset)) { return CharSource.this; } return super.asCharSource(charset); }
@Override public CharSource asCharSource(Charset charset) { if (charset.equals(this.charset)) { return CharSource.this; } return super.asCharSource(charset); }
@Override public boolean equals(@NullableDecl Object o) { if (o instanceof StringCharsetFunnel) { StringCharsetFunnel funnel = (StringCharsetFunnel) o; return this.charset.equals(funnel.charset); } return false; }
@Override public ByteSource asByteSource(Charset charset) { if (charset.equals(this.charset)) { return ByteSource.this; } return super.asByteSource(charset); }
@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); }
@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; }
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);
@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); }
@Override public CharSource asCharSource(Charset charset) { if (charset.equals(this.charset)) { return CharSource.this; } return super.asCharSource(charset); }
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 } } }
@Override public ByteSource asByteSource(Charset charset) { if (charset.equals(this.charset)) { return ByteSource.this; } return super.asByteSource(charset); }
@Override public boolean equals(@NullableDecl Object o) { if (o instanceof StringCharsetFunnel) { StringCharsetFunnel funnel = (StringCharsetFunnel) o; return this.charset.equals(funnel.charset); } return false; }
@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); }
@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); }
@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); }
if (charset == null || charset.equals(UTF_8)) { encodedCharBuffer.writeUtf8CodePoint(codePoint); } else {