com.couchbase.client.deps.io.netty.buffer.ByteBuf.toString()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(6.0k)|赞(0)|评价(0)|浏览(210)

本文整理了Java中com.couchbase.client.deps.io.netty.buffer.ByteBuf.toString()方法的一些代码示例,展示了ByteBuf.toString()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ByteBuf.toString()方法的具体详情如下:
包路径:com.couchbase.client.deps.io.netty.buffer.ByteBuf
类名称:ByteBuf
方法名:toString

ByteBuf.toString介绍

[英]Returns the string representation of this buffer. This method does not necessarily return the whole content of the buffer but returns the values of the key properties such as #readerIndex(), #writerIndex() and #capacity().
[中]返回此缓冲区的字符串表示形式。此方法不一定返回缓冲区的全部内容,但返回关键属性的值,如#readerIndex()、#writeridex()和#capacity()。

代码示例

代码示例来源:origin: com.couchbase.client/core-io

  1. @Override
  2. public String toString() {
  3. return content.toString(CharsetUtil.UTF_8);
  4. }
  5. }

代码示例来源:origin: com.couchbase.client/core-io

  1. @Override
  2. public String getString(Charset encoding) {
  3. if (byteBuf == null) {
  4. return "";
  5. }
  6. if (encoding == null) {
  7. encoding = HttpConstants.DEFAULT_CHARSET;
  8. }
  9. return byteBuf.toString(encoding);
  10. }

代码示例来源:origin: com.couchbase.client/core-io

  1. /**
  2. * Return {@link ByteBuf#toString()} without checking the reference count first. This is useful to implement
  3. * {@link #toString()}.
  4. */
  5. protected final String contentToString() {
  6. return data.toString();
  7. }

代码示例来源:origin: com.couchbase.client/core-io

  1. @Override
  2. protected void decode(ChannelHandlerContext ctx, ByteBuf msg, List<Object> out) throws Exception {
  3. out.add(msg.toString(charset));
  4. }
  5. }

代码示例来源:origin: com.couchbase.client/core-io

  1. @Override
  2. public boolean equals(Object o) {
  3. if (this == o) return true;
  4. if (o == null || getClass() != o.getClass()) return false;
  5. MultiResult that = (MultiResult) o;
  6. if (statusCode != that.statusCode) return false;
  7. if (status != that.status) return false;
  8. if (path != null ? !path.equals(that.path) : that.path != null) return false;
  9. if (operation != that.operation) return false;
  10. if (value == null) return that.value == null;
  11. return value.toString(CharsetUtil.UTF_8).equals(that.value.toString(CharsetUtil.UTF_8));
  12. }

代码示例来源:origin: com.couchbase.client/core-io

  1. @Override
  2. public String toString() {
  3. StringBuilder result = new StringBuilder();
  4. for (ByteBuf elt : value) {
  5. result.append(elt.toString(charset));
  6. }
  7. return result.toString();
  8. }

代码示例来源:origin: com.couchbase.client/core-io

  1. public void call(ByteBuf buf) {
  2. clientContextID = buf.toString(CHARSET);
  3. clientContextID = clientContextID.substring(1, clientContextID.length() - 1);
  4. buf.release();
  5. }
  6. }),

代码示例来源:origin: com.couchbase.client/core-io

  1. @Override
  2. public int hashCode() {
  3. int result = (int) statusCode;
  4. result = 31 * result + (status != null ? status.hashCode() : 0);
  5. result = 31 * result + (path != null ? path.hashCode() : 0);
  6. result = 31 * result + (operation != null ? operation.hashCode() : 0);
  7. if (value != null) {
  8. result = 31 * result + value.toString(CharsetUtil.UTF_8).hashCode();
  9. }
  10. return result;
  11. }

代码示例来源:origin: com.couchbase.client/core-io

  1. public void call(ByteBuf buf) {
  2. clientContextID = buf.toString(CHARSET);
  3. clientContextID = clientContextID.substring(1, clientContextID.length() - 1);
  4. buf.release();
  5. }
  6. }),

代码示例来源:origin: com.couchbase.client/core-io

  1. /**
  2. * Returns the text data in this frame
  3. */
  4. public String text() {
  5. return content().toString(CharsetUtil.UTF_8);
  6. }

代码示例来源:origin: com.couchbase.client/core-io

  1. @Override
  2. public String toString(int index, int length, Charset charset) {
  3. checkIndex(index, length);
  4. return buffer.toString(index, length, charset);
  5. }

代码示例来源:origin: com.couchbase.client/core-io

  1. /**
  2. * Returns the text data in this frame
  3. */
  4. public String text() {
  5. return content().toString(CharsetUtil.UTF_8);
  6. }

代码示例来源:origin: com.couchbase.client/core-io

  1. public void call(ByteBuf buf) {
  2. handle = buf.toString(CHARSET).replaceAll("^\"|\"$", "");
  3. buf.release();
  4. if (!sentResponse) {
  5. createResponse();
  6. LOGGER.trace("Received handle for requestId {}", requestID);
  7. }
  8. }
  9. }),

代码示例来源:origin: com.couchbase.client/core-io

  1. @Override
  2. public String toString() {
  3. StringBuilder builder = new StringBuilder();
  4. builder.append(operation())
  5. .append('(').append(path()).append("): ")
  6. .append(status());
  7. if (value.readableBytes() > 0) {
  8. builder.append(" = ").append(value().toString(CharsetUtil.UTF_8));
  9. }
  10. return builder.toString();
  11. }
  12. }

代码示例来源:origin: com.couchbase.client/core-io

  1. static String readUsAscii(ByteBuf buffer, int length) {
  2. String s = buffer.toString(buffer.readerIndex(), length, CharsetUtil.US_ASCII);
  3. buffer.skipBytes(length);
  4. return s;
  5. }
  6. }

代码示例来源:origin: com.couchbase.client/java-client

  1. @Override
  2. protected RawJsonDocument doDecode(String id, ByteBuf content, long cas, int expiry, int flags,
  3. ResponseStatus status) throws Exception {
  4. if (!TranscoderUtils.hasJsonFlags(flags)) {
  5. throw new TranscodingException("Flags (0x" + Integer.toHexString(flags) + ") indicate non-JSON document for "
  6. + "id " + id + ", could not decode.");
  7. }
  8. String converted = content.toString(CharsetUtil.UTF_8);
  9. return newDocument(id, expiry, converted, cas);
  10. }

代码示例来源:origin: com.couchbase.client/java-client

  1. @Override
  2. protected StringDocument doDecode(String id, ByteBuf content, long cas, int expiry, int flags,
  3. ResponseStatus status) throws Exception {
  4. if (!TranscoderUtils.hasStringFlags(flags)) {
  5. throw new TranscodingException("Flags (0x" + Integer.toHexString(flags) + ") indicate non-String document for "
  6. + "id " + id + ", could not decode.");
  7. }
  8. return newDocument(id, expiry, content.toString(CharsetUtil.UTF_8), cas);
  9. }

代码示例来源:origin: com.couchbase.client/core-io

  1. void setCurrentValue(ByteBuf value, int length) {
  2. this.currentValue = value;
  3. if (peekMode() == Mode.JSON_STRING_HASH_KEY) {
  4. //strip the quotes
  5. this.jsonPointer.addToken(this.currentValue.toString(
  6. this.currentValue.readerIndex() + 1, length - 1, Charset.defaultCharset()));
  7. }
  8. }

代码示例来源:origin: com.couchbase.client/core-io

  1. private void setFinalBuffer(ByteBuf buffer) throws IOException {
  2. currentAttribute.addContent(buffer, true);
  3. String value = decodeAttribute(currentAttribute.getByteBuf().toString(charset), charset);
  4. currentAttribute.setValue(value);
  5. addHttpData(currentAttribute);
  6. currentAttribute = null;
  7. }

代码示例来源:origin: com.couchbase.client/core-io

  1. @Override
  2. public String call(GetBucketConfigResponse response) {
  3. if (!response.status().isSuccess()) {
  4. response.content().release();
  5. throw new IllegalStateException("Bucket config response did not return with success.");
  6. }
  7. LOGGER.debug("Successfully loaded config through carrier.");
  8. String content = response.content().toString(CharsetUtil.UTF_8);
  9. response.content().release();
  10. return replaceHostWildcard(content, hostname);
  11. }
  12. });

相关文章