Refine search
/** Returns the character located at the specified index in the buffer. The index value is referenced from the current buffer * position. * * @param index the index referenced from the current buffer position. It must not be less than zero but less than the value * obtained from a call to {@code remaining()}. * @return the character located at the specified index (referenced from the current position) in the buffer. * @exception IndexOutOfBoundsException if the index is invalid. * @since Android 1.0 */ public final char charAt (int index) { if (index < 0 || index >= remaining()) { throw new IndexOutOfBoundsException(); } return get(position + index); }
while (cb.hasRemaining()) { final char c = cb.get(); if (c == '%' && cb.remaining() >= 2) { final char uc = cb.get(); final char lc = cb.get(); final int u = Character.digit(uc, 16); final int l = Character.digit(lc, 16);
final CoderResult coderResult = decoder.decode(src, oneChar, false); if (coderResult.isUnderflow()) { if (oneChar.hasRemaining()) { return false; } else if (oneChar.hasRemaining()) { throw new IllegalStateException(); final char ch = oneChar.get(0); builder.append(ch); if (ch == delimiter) {
/** Returns the character located at the specified index in the buffer. The index value is referenced from the current buffer * position. * * @param index the index referenced from the current buffer position. It must not be less than zero but less than the value * obtained from a call to {@code remaining()}. * @return the character located at the specified index (referenced from the current position) in the buffer. * @exception IndexOutOfBoundsException if the index is invalid. * @since Android 1.0 */ public final char charAt (int index) { if (index < 0 || index >= remaining()) { throw new IndexOutOfBoundsException(); } return get(position + index); }
private void _encodeLeftoverChar( CharBuffer inputCharBuffer, boolean endOfInput) throws IOException { if (_inputCharBuffer.position() == 0) { return; } if ((_inputCharBuffer.position() == 1) && inputCharBuffer.hasRemaining()) { _inputCharBuffer.put(inputCharBuffer.get()); } _inputCharBuffer.flip(); _encodeLoop(_inputCharBuffer, endOfInput); _inputCharBuffer.compact(); }
if (charBuf.hasRemaining()) { char c = charBuf.get(); incrPosition(delta, true); return c; if (charBuf.remaining() == 2) { char highSurrogate = charBuf.get(); lowSurrogate = charBuf.get();
private void _encodeLoop(CharBuffer inputCharBuffer, boolean endOfInput) throws IOException { while (inputCharBuffer.hasRemaining()) { CoderResult coderResult = _charsetEncoder.encode( inputCharBuffer, _outputByteBuffer, endOfInput); if (coderResult.isError()) { coderResult.throwException(); } if (coderResult.isUnderflow()) { if (_autoFlush) { _flushBuffer(); } if ((_inputCharBuffer != inputCharBuffer) && inputCharBuffer.hasRemaining()) { _inputCharBuffer.put(inputCharBuffer.get()); } break; } // Must be overflow, no need to check _flushBuffer(); } }
private void charToIntBuffer(int toAppend) { charBuffer.flip(); // IntBuffers hold two times as much per unit as ByteBuffers, so start with one half the capacity. IntBuffer newBuffer = IntBuffer.allocate(Math.max(charBuffer.remaining() + toAppend, charBuffer.capacity() / 2)); while (charBuffer.hasRemaining()) { newBuffer.put(charBuffer.get() & 0xFFFF); } type = Type.INT; charBuffer = null; intBuffer = newBuffer; } }
if (result.isError() || !_cb.hasRemaining()) return REPLACEMENT; return _cb.get() & 0xffff;
private void charToIntBuffer(int toAppend) { charBuffer.flip(); // IntBuffers hold two times as much per unit as ByteBuffers, so start with one half the capacity. IntBuffer newBuffer = IntBuffer.allocate(Math.max(charBuffer.remaining() + toAppend, charBuffer.capacity() / 2)); while (charBuffer.hasRemaining()) { newBuffer.put(charBuffer.get() & 0xFFFF); } type = Type.INT; charBuffer = null; intBuffer = newBuffer; } }
/** Checks whether this char buffer is equal to another object. * <p> * If {@code other} is not a char buffer then {@code false} is returned. Two char buffers are equal if and only if their * remaining chars are exactly the same. Position, limit, capacity and mark are not considered. * </p> * * @param other the object to compare with this char buffer. * @return {@code true} if this char buffer is equal to {@code other}, {@code false} otherwise. * @since Android 1.0 */ public boolean equals (Object other) { if (!(other instanceof CharBuffer)) { return false; } CharBuffer otherBuffer = (CharBuffer)other; if (remaining() != otherBuffer.remaining()) { return false; } int myPosition = position; int otherPosition = otherBuffer.position; boolean equalSoFar = true; while (equalSoFar && (myPosition < limit)) { equalSoFar = get(myPosition++) == otherBuffer.get(otherPosition++); } return equalSoFar; }
@Override public int read() { if (!cb.hasRemaining()) { return -1; } return cb.get(); }
private void charToIntBuffer(int toAppend) { charBuffer.flip(); // IntBuffers hold two times as much per unit as ByteBuffers, so start with one half the capacity. IntBuffer newBuffer = IntBuffer.allocate(Math.max(charBuffer.remaining() + toAppend, charBuffer.capacity() / 2)); while (charBuffer.hasRemaining()) { newBuffer.put(charBuffer.get() & 0xFFFF); } type = Type.INT; charBuffer = null; intBuffer = newBuffer; } }
/** Checks whether this char buffer is equal to another object. * <p> * If {@code other} is not a char buffer then {@code false} is returned. Two char buffers are equal if and only if their * remaining chars are exactly the same. Position, limit, capacity and mark are not considered. * </p> * * @param other the object to compare with this char buffer. * @return {@code true} if this char buffer is equal to {@code other}, {@code false} otherwise. * @since Android 1.0 */ public boolean equals (Object other) { if (!(other instanceof CharBuffer)) { return false; } CharBuffer otherBuffer = (CharBuffer)other; if (remaining() != otherBuffer.remaining()) { return false; } int myPosition = position; int otherPosition = otherBuffer.position; boolean equalSoFar = true; while (equalSoFar && (myPosition < limit)) { equalSoFar = get(myPosition++) == otherBuffer.get(otherPosition++); } return equalSoFar; }
@Override public long skip(long n) throws IOException { int skipped = 0; while (n > 0 && this.cbuf.hasRemaining()) { this.cbuf.get(); n--; skipped++; } return skipped; }
@Override public long skip(long n) throws IOException { int skipped = 0; while (n > 0 && this.cbuf.hasRemaining()) { this.cbuf.get(); n--; skipped++; } return skipped; }