Package java.nio

Examples of java.nio.CharBuffer.capacity()


    CharBuffer cb = CharBuffer.wrap(b);
    cb.position(4);
    cb.limit(7);
    CharBuffer dup = cb.duplicate();

    h.check(dup.capacity(), 11);
    try
      {
        dup.arrayOffset();
        h.fail("testDuplicate");
      }
View Full Code Here


                //             CharBuffer returned by btc.decode(byteBuf)
                //             is longer in length than the number of characters
                //             decoded. Hence, the check below to ensure the
                //             char[] returned contains all the chars that have
                //             been decoded and no more.
                if (charBuf.limit() == charBuf.capacity()) {
                    buffer = charBuf.array();
                } else {
                    buffer = new char[charBuf.limit()];
                    charBuf.get(buffer, 0, charBuf.limit()).position(0);
                }
View Full Code Here

                //             CharBuffer returned by btc.decode(byteBuf)
                //             is longer in length than the number of characters
                //             decoded. Hence, the check below to ensure the
                //             char[] returned contains all the chars that have
                //             been decoded and no more.
                if (charBuf.limit() == charBuf.capacity()) {
                    buffer = charBuf.array();
                } else {
                    buffer = new char[charBuf.limit()];
                    charBuf.get(buffer, 0, charBuf.limit()).position(0);
                }
View Full Code Here

          if (charsRead == -1) {
            // if we received EOF before last event processing attempt, then we
            // have done everything we can
            break;
          } else if (charsRead == 0 && eventsProcessed == 0) {
            if (buffer.remaining() == buffer.capacity()) {
              // If we get here it means:
              // 1. Last time we called fill(), no new chars were buffered
              // 2. After that, we failed to process any events => no newlines
              // 3. The unread data in the buffer == the size of the buffer
              // Therefore, we are stuck because the client sent a line longer
View Full Code Here

              // Therefore, we are stuck because the client sent a line longer
              // than the size of the buffer. Response: Drop the connection.
              logger.warn("Client sent event exceeding the maximum length");
              counterGroup.incrementAndGet("events.failed");
              writer.write("FAILED: Event exceeds the maximum length (" +
                  buffer.capacity() + " chars, including newline)\n");
              writer.flush();
              break;
            }
          }
        }
View Full Code Here

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

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

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

    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(out, unistr + unistr + unistr);

    // 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(out, unistr + unistr + unistr);

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

                    if (res.isMalformed() || res.isUnmappable()) {
                        return true;
                    } else if (res.isOverflow()) {
                        chars.limit(chars.position());
                        chars.rewind();
                        int c = chars.capacity() * 2;
                        CharBuffer on = CharBuffer.allocate(c);
                        on.put(chars);
                        chars = on;
                    }
                }
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.