Package java.nio

Examples of java.nio.CharBuffer.position()


            while (out.hasRemaining()) {
                // fill the buffer if needed
                if (needInput) {
                    try {
                        if ((in.available() == 0)
                            && (out.position() > offset)) {
                            // we could return the result without blocking read
                            break;
                        }
                    } catch (IOException e) {
                        // available didn't work so just try the read
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

      tmpcb.rewind();

      baseEncoder.reset();

      for (int pos = tmpcb.position(); pos < tmpcb.limit(); pos++) {
        char c = tmpcb.get (pos);
        if ( c >= 128 ){
          if (toCp347.containsKey(new Integer(c)))
            tmpcb.put (pos,(char)(((Integer)toCp347.get(new Integer((int)c))).intValue()));
          else
View Full Code Here

            // escape characters interpreted as backslash by mysql
            if(charsetEncoder != null) {
              CharBuffer cbuf = CharBuffer.allocate(1);
              ByteBuffer bbuf = ByteBuffer.allocate(1);
              cbuf.put(c);
              cbuf.position(0);
              charsetEncoder.encode(cbuf, bbuf, true);
              if(bbuf.get(0) == '\\') {
                buf.append('\\');
              }
            }
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

    assertCharBufferValue(out, "");

    // normal case
    ByteBuffer in = ByteBuffer.wrap(getUnibytes());
    out = decoder.decode(in);
    assertEquals(out.position(), 0);
    assertEquals(out.limit(), unistr.length());
    assertEquals(out.remaining(), unistr.length());
    assertEquals(new String(out.array(), 0, out.limit()), unistr);
  }
View Full Code Here

    decoder.reset();
    in.rewind();
    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);
View Full Code Here

    decoder.reset();
    in.rewind();
    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();
View Full Code Here

    in = ByteBuffer.wrap(unibytes);
    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
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

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.