java.nio.charset.CoderResult.toString()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(8.5k)|赞(0)|评价(0)|浏览(114)

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

CoderResult.toString介绍

[英]Returns a text description of this result.
[中]返回此结果的文本说明。

代码示例

代码示例来源:origin: robovm/robovm

/**
 * Returns the length of the erroneous input. The length is only meaningful for
 * a malformed-input error or an unmappable character error.
 *
 * @throws UnsupportedOperationException
 *             if this result is an overflow or underflow.
 */
public int length() throws UnsupportedOperationException {
  if (this.type == TYPE_MALFORMED_INPUT || this.type == TYPE_UNMAPPABLE_CHAR) {
    return this.length;
  }
  throw new UnsupportedOperationException("length meaningless for " + toString());
}

代码示例来源:origin: android-hacker/VirtualXposed

public void flush() throws IOException {
  //Log.i("PackageManager", "flush mPos=" + mPos);
  if (mPos > 0) {
    if (mOutputStream != null) {
      CharBuffer charBuffer = CharBuffer.wrap(mText, 0, mPos);
      CoderResult result = mCharset.encode(charBuffer, mBytes, true);
      while (true) {
        if (result.isError()) {
          throw new IOException(result.toString());
        } else if (result.isOverflow()) {
          flushBytes();
          result = mCharset.encode(charBuffer, mBytes, true);
          continue;
        }
        break;
      }
      flushBytes();
      mOutputStream.flush();
    } else {
      mWriter.write(mText, 0, mPos);
      mWriter.flush();
    }
    mPos = 0;
  }
}

代码示例来源:origin: evernote/android-job

public void flush() throws IOException {
  //Log.i("PackageManager", "flush mPos=" + mPos);
  if (mPos > 0) {
    if (mOutputStream != null) {
      CharBuffer charBuffer = CharBuffer.wrap(mText, 0, mPos);
      CoderResult result = mCharset.encode(charBuffer, mBytes, true);
      while (true) {
        if (result.isError()) {
          throw new IOException(result.toString());
        } else if (result.isOverflow()) {
          flushBytes();
          result = mCharset.encode(charBuffer, mBytes, true);
          continue;
        }
        break;
      }
      flushBytes();
      mOutputStream.flush();
    } else {
      mWriter.write(mText, 0, mPos);
      mWriter.flush();
    }
    mPos = 0;
  }
}

代码示例来源:origin: MobiVM/robovm

/**
 * Returns the length of the erroneous input. The length is only meaningful for
 * a malformed-input error or an unmappable character error.
 *
 * @throws UnsupportedOperationException
 *             if this result is an overflow or underflow.
 */
public int length() throws UnsupportedOperationException {
  if (this.type == TYPE_MALFORMED_INPUT || this.type == TYPE_UNMAPPABLE_CHAR) {
    return this.length;
  }
  throw new UnsupportedOperationException("length meaningless for " + toString());
}

代码示例来源:origin: ibinti/bugvm

/**
 * Returns the length of the erroneous input. The length is only meaningful for
 * a malformed-input error or an unmappable character error.
 *
 * @throws UnsupportedOperationException
 *             if this result is an overflow or underflow.
 */
public int length() throws UnsupportedOperationException {
  if (this.type == TYPE_MALFORMED_INPUT || this.type == TYPE_UNMAPPABLE_CHAR) {
    return this.length;
  }
  throw new UnsupportedOperationException("length meaningless for " + toString());
}

代码示例来源:origin: com.mobidevelop.robovm/robovm-rt

/**
 * Returns the length of the erroneous input. The length is only meaningful for
 * a malformed-input error or an unmappable character error.
 *
 * @throws UnsupportedOperationException
 *             if this result is an overflow or underflow.
 */
public int length() throws UnsupportedOperationException {
  if (this.type == TYPE_MALFORMED_INPUT || this.type == TYPE_UNMAPPABLE_CHAR) {
    return this.length;
  }
  throw new UnsupportedOperationException("length meaningless for " + toString());
}

代码示例来源:origin: com.bugvm/bugvm-rt

/**
 * Returns the length of the erroneous input. The length is only meaningful for
 * a malformed-input error or an unmappable character error.
 *
 * @throws UnsupportedOperationException
 *             if this result is an overflow or underflow.
 */
public int length() throws UnsupportedOperationException {
  if (this.type == TYPE_MALFORMED_INPUT || this.type == TYPE_UNMAPPABLE_CHAR) {
    return this.length;
  }
  throw new UnsupportedOperationException("length meaningless for " + toString());
}

代码示例来源:origin: com.gluonhq/robovm-rt

/**
 * Returns the length of the erroneous input. The length is only meaningful for
 * a malformed-input error or an unmappable character error.
 *
 * @throws UnsupportedOperationException
 *             if this result is an overflow or underflow.
 */
public int length() throws UnsupportedOperationException {
  if (this.type == TYPE_MALFORMED_INPUT || this.type == TYPE_UNMAPPABLE_CHAR) {
    return this.length;
  }
  throw new UnsupportedOperationException("length meaningless for " + toString());
}

代码示例来源:origin: FlexoVM/flexovm

/**
 * Returns the length of the erroneous input. The length is only meaningful for
 * a malformed-input error or an unmappable character error.
 *
 * @throws UnsupportedOperationException
 *             if this result is an overflow or underflow.
 */
public int length() throws UnsupportedOperationException {
  if (this.type == TYPE_MALFORMED_INPUT || this.type == TYPE_UNMAPPABLE_CHAR) {
    return this.length;
  }
  throw new UnsupportedOperationException("length meaningless for " + toString());
}

代码示例来源:origin: org.jruby/jruby-complete

private void byte2char(ByteBuffer bytes, CharBuffer chars) throws IOException {
    decoder.reset();
    chars.clear();
    CoderResult result = decoder.decode(bytes, chars, true);
    if (result.isError() || result.isOverflow()) {
      throw new IOException(result.toString());
    } else if (result.isUnderflow()) {
      chars.flip();
    }
  }
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

private void byte2char(ByteBuffer bytes, CharBuffer chars) throws IOException {
    decoder.reset();
    chars.clear();
    CoderResult result = decoder.decode(bytes, chars, true);
    if (result.isError() || result.isOverflow()) {
      throw new IOException(result.toString());
    } else if (result.isUnderflow()) {
      chars.flip();
    }
  }
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

private void byte2char(ByteBuffer bytes, CharBuffer chars) throws IOException {
    decoder.reset();
    chars.clear();
    CoderResult result = decoder.decode(bytes, chars, true);
    if (result.isError() || result.isOverflow()) {
      throw new IOException(result.toString());
    } else if (result.isUnderflow()) {
      chars.flip();
    }
  }
}

代码示例来源:origin: org.jruby/jruby-core

private void byte2char(ByteBuffer bytes, CharBuffer chars) throws IOException {
    decoder.reset();
    chars.clear();
    CoderResult result = decoder.decode(bytes, chars, true);
    if (result.isError() || result.isOverflow()) {
      throw new IOException(result.toString());
    } else if (result.isUnderflow()) {
      chars.flip();
    }
  }
}

代码示例来源:origin: codefollower/Tomcat-Research

public void write() {
  buffer.clear();
  CoderResult cr = encoder.encode(message, buffer, true);
  if (cr.isError()) {
    throw new IllegalArgumentException(cr.toString());
  }
  isDone = !cr.isOverflow();
  buffer.flip();
  endpoint.startMessage(Constants.OPCODE_TEXT, buffer,
      isDone && isLast, this);
}

代码示例来源:origin: org.apache.tomcat.embed/tomcat-embed-websocket

public void write() {
  buffer.clear();
  CoderResult cr = encoder.encode(message, buffer, true);
  if (cr.isError()) {
    throw new IllegalArgumentException(cr.toString());
  }
  isDone = !cr.isOverflow();
  buffer.flip();
  endpoint.startMessage(Constants.OPCODE_TEXT, buffer,
      isDone && isLast, this);
}

代码示例来源:origin: org.apache.tomcat/tomcat7-websocket

public void write() {
  buffer.clear();
  CoderResult cr = encoder.encode(message, buffer, true);
  if (cr.isError()) {
    throw new IllegalArgumentException(cr.toString());
  }
  isDone = !cr.isOverflow();
  buffer.flip();
  endpoint.startMessage(Constants.OPCODE_TEXT, buffer,
      isDone && isLast, this);
}

代码示例来源:origin: org.apache.tomcat/tomcat-websocket

public void write() {
  buffer.clear();
  CoderResult cr = encoder.encode(message, buffer, true);
  if (cr.isError()) {
    throw new IllegalArgumentException(cr.toString());
  }
  isDone = !cr.isOverflow();
  buffer.flip();
  endpoint.startMessage(Constants.OPCODE_TEXT, buffer,
      isDone && isLast, this);
}

代码示例来源:origin: org.jboss.web/jbossweb

public void write() {
  // FIXME: maybe not needed
  synchronized (buffer) {
    buffer.clear();
    CoderResult cr = encoder.encode(message, buffer, true);
    if (cr.isError()) {
      throw new IllegalArgumentException(cr.toString());
    }
    isDone = !cr.isOverflow();
    buffer.flip();
    endpoint.startMessage(Constants.OPCODE_TEXT, buffer,
        isDone && isLast, this);
  }
}

代码示例来源:origin: org.apache.tomcat/tomcat-websocket

void sendMessageBlock(CharBuffer part, boolean last) throws IOException {
  long timeoutExpiry = getTimeoutExpiry();
  boolean isDone = false;
  while (!isDone) {
    encoderBuffer.clear();
    CoderResult cr = encoder.encode(part, encoderBuffer, true);
    if (cr.isError()) {
      throw new IllegalArgumentException(cr.toString());
    }
    isDone = !cr.isOverflow();
    encoderBuffer.flip();
    sendMessageBlock(Constants.OPCODE_TEXT, encoderBuffer, last && isDone, timeoutExpiry);
  }
  stateMachine.complete(last);
}

代码示例来源:origin: apache/asterixdb

private static void set(final byte[] content, final CharsetDecoder decoder, final CharBuffer chars,
      final CharArrayRecord record) throws IOException {
    chars.clear();
    ByteBuffer bytes = ByteBuffer.wrap(content);
    CoderResult result = decoder.decode(bytes, chars, true);
    if (result.isError() || (result.isUnderflow() && bytes.remaining() > 0)) {
      throw new IOException(result.toString());
    }
    chars.flip();
    record.append(chars);
    record.endRecord();
  }
}

相关文章