Package java.nio

Examples of java.nio.CharBuffer.position()


        ByteBuffer byteBuf = ByteBuffer.wrap(input, off, len);
        CharBuffer charBuf = CharBuffer.wrap(chars);
        IOUtils.decode(charsetDecoder, byteBuf, charBuf);

        int position = charBuf.position();

        DefaultJSONParser parser = new DefaultJSONParser(chars, position, ParserConfig.getGlobalInstance(), features);
        Object value = parser.parse();

        handleResovleTask(parser, value);
View Full Code Here


        ByteBuffer byteBuf = ByteBuffer.wrap(input, off, len);
        CharBuffer charByte = CharBuffer.wrap(chars);
        IOUtils.decode(charsetDecoder, byteBuf, charByte);

        int position = charByte.position();

        return (T) parseObject(chars, position, clazz, features);
    }

    @SuppressWarnings("unchecked")
View Full Code Here

          logger.debug("read {} characters", buffer.remaining());

          counterGroup.addAndGet("characters.received",
              Long.valueOf(buffer.limit()));

          builder.append(buffer.array(), buffer.position(), buffer.length());
        }

        if (builder.charAt(builder.length() - 1) == '\n') {
          builder.deleteCharAt(builder.length() - 1);
        }
View Full Code Here

    h.check(cb.hasRemaining(), true);
    h.check(cb.isDirect(), false);
    h.check(cb.isReadOnly(), true);
    h.check(cb.length(), 3);
    h.check(cb.limit(), 7);
    h.check(cb.position(), 4);
    h.check(cb.remaining(), 3);
    try
      {
        cb.compact();
        h.fail("testBasic");
View Full Code Here

   */
  private void testSlice(TestHarness h)
  {
    StringBuilder b = new StringBuilder("Hello World");
    CharBuffer cb = CharBuffer.wrap(b);
    cb.position(4);
    cb.limit(7);
    CharBuffer slice = cb.slice();

    h.check(slice.capacity(), 3);
    try
View Full Code Here

      }
    h.check(slice.isDirect(), false);
    h.check(slice.isReadOnly(), true);
    h.check(slice.length(), 3);
    h.check(slice.limit(), 3);
    h.check(slice.position(), 0);

    // This shows a JDK bug..
    h.check(slice.get(), 'o');
    h.check(slice.get(), ' ');
    h.check(slice.get(), 'W');
View Full Code Here

   */
  private void testDuplicate(TestHarness h)
  {
    StringBuilder b = new StringBuilder("Hello World");
    CharBuffer cb = CharBuffer.wrap(b);
    cb.position(4);
    cb.limit(7);
    CharBuffer dup = cb.duplicate();

    h.check(dup.capacity(), 11);
    try
View Full Code Here

      }
    h.check(dup.isDirect(), false);
    h.check(dup.isReadOnly(), true);
    h.check(dup.length(), 3);
    h.check(dup.limit(), 7);
    h.check(dup.position(), 4);

    h.check(dup.get(), 'o');
    h.check(dup.get(), ' ');
    h.check(dup.get(), 'W');
View Full Code Here

                // Since ASCII is single-byte, retrict encoder character consumption
                // to at most 'len' characters' to produce at most len ASCII
                // characters
                int cbLimit     = cb.limit();
                int cbPosistion = cb.position();

                cb.limit(cbPosistion + len);
                bb.clear();

                int         bbPosition = bb.position();
View Full Code Here

                        length, charset);
            }

            buf = buf.slice();
            buf.limit(length);
            buf.position(offset);
            return copiedBuffer(endianness, buf, charset);
        }

        return copiedBuffer(
                endianness, CharBuffer.wrap(string, offset, offset + length),
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.