Package java.nio

Examples of java.nio.CharBuffer.capacity()


            dest.flip();

            if (result.isUnderflow()) { // done reading
                // make sure there is at least one extra character
                if (dest.limit() == dest.capacity()) {
                    dest = CharBuffer.allocate(dest.capacity()+1).put(dest);
                    dest.flip();
                }
                return dest;
            } else if (result.isOverflow()) { // buffer too small; expand
                int newCapacity =
View Full Code Here


                    dest.flip();
                }
                return dest;
            } else if (result.isOverflow()) { // buffer too small; expand
                int newCapacity =
                    10 + dest.capacity() +
                    (int)(inbuf.remaining()*decoder.maxCharsPerByte());
                dest = CharBuffer.allocate(newCapacity).put(dest);
            } else if (result.isMalformed() || result.isUnmappable()) {
                // bad character in input

View Full Code Here

                inbuf.position(inbuf.position() + result.length());

                // undo the flip() to prepare the output buffer
                // for more translation
                dest.position(dest.limit());
                dest.limit(dest.capacity());
                dest.put((char)0xfffd); // backward compatible
            } else {
                throw new AssertionError(result);
            }
        }
View Full Code Here

        out.clear();
        assertSame(CoderResult.UNDERFLOW, decoder.decode(in, out, false));
        assertEquals(out.limit(), 100);
        assertEquals(out.position(), getString().length());
        assertEquals(out.remaining(), 100 - getString().length());
        assertEquals(out.capacity(), 100);
        assertCharBufferValue(getString(), out);

        decoder.reset();
        in.rewind();
        out.clear();
View Full Code Here

        assertSame(CoderResult.UNDERFLOW, decoder.decode(in, out, false));
        in.rewind();
        assertSame(CoderResult.UNDERFLOW, decoder.decode(in, out, true));
        assertEquals(out.limit(), 100);
        assertTrue(out.position() > 0);
        assertEquals(out.remaining(), out.capacity() - out.position());
        assertEquals(out.capacity(), 100);
        assertCharBufferValue(getString() + getString() + getString(), out);

        // overflow
        out = CharBuffer.allocate(4);
View Full Code Here

        in.rewind();
        assertSame(CoderResult.UNDERFLOW, decoder.decode(in, out, true));
        assertEquals(out.limit(), 100);
        assertTrue(out.position() > 0);
        assertEquals(out.remaining(), out.capacity() - out.position());
        assertEquals(out.capacity(), 100);
        assertCharBufferValue(getString() + getString() + getString(), out);

        // overflow
        out = CharBuffer.allocate(4);
        decoder.reset();
View Full Code Here

        out.rewind();
        assertSame(CoderResult.UNDERFLOW, decoder.decode(in, out, true));
        assertEquals(out.limit(), 100);
        assertEquals(out.position(), getString().length());
        assertEquals(out.remaining(), 100 - getString().length());
        assertEquals(out.capacity(), 100);
        assertCharBufferValue(getString(), out);
        decoder.flush(out);

        // normal case, one complete operation, but call twice, first time set
        // endOfInput to false
View Full Code Here

    assertEquals(buf.isReadOnly(), slice.isReadOnly());
    assertEquals(buf.isDirect(), slice.isDirect());
    assertEquals(buf.order(), slice.order());
    assertEquals(slice.position(), 0);
    assertEquals(slice.limit(), buf.remaining());
    assertEquals(slice.capacity(), buf.remaining());
    try {
      slice.reset();
      fail("Should throw Exception"); //$NON-NLS-1$
    } catch (InvalidMarkException e) {
      // expected
View Full Code Here

    }

    // slice share the same content with buf
    if (!slice.isReadOnly()) {
      loadTestData1(slice);
      assertContentLikeTestData1(buf, 1, (char) 0, slice.capacity());
      buf.put(2, (char) 500);
      assertEquals(slice.get(1), 500);
    }
  }
View Full Code Here

    assertTrue(readonly.isReadOnly());
    assertEquals(buf.position(), readonly.position());
    assertEquals(buf.limit(), readonly.limit());
    assertEquals(buf.isDirect(), readonly.isDirect());
    assertEquals(buf.order(), readonly.order());
    assertEquals(buf.capacity(), readonly.capacity());
    assertContentEquals(buf, readonly);

    // readonly's position, mark, and limit should be independent to buf
    readonly.reset();
    assertEquals(readonly.position(), 0);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.