/** * 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()); }
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; } }
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; } }
/** * 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()); }
/** * 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()); }
/** * 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()); }
/** * 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()); }
/** * 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()); }
/** * 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()); }
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(); } } }
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(); } } }
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(); } } }
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(); } } }
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); }
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); }
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); }
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); }
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); } }
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); }
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(); } }