Examples of compact()


Examples of java.nio.ByteBuffer.compact()

            logFacility.dump(getClass(), Warn, "Bad data sink when reading revision %d. Reported %d bytes consumed, byt actually read %d", revisionNumber, consumed, buf.position());
          }
          if (buf.position() == 0) {
            throw new HgInvalidStateException("Bad sink implementation (consumes no bytes) results in endless loop");
          }
          buf.compact(); // ensure (a) there's space for new (b) data starts at 0
          progressSupport.worked(consumed);
        }
        progressSupport.done(); // XXX shall specify whether #done() is invoked always or only if completed successfully.
      } catch (IOException ex) {
        recordFailure(ex);
View Full Code Here

Examples of java.nio.ByteBuffer.compact()

        while (fc.read(buf) != -1) {
          cs.checkCancelled();
          buf.flip();
          int consumed = sink.write(buf);
          progress.worked(flength > Integer.MAX_VALUE ? 1 : consumed);
          buf.compact();
        }
      } catch (IOException ex) {
        throw new HgInvalidFileException("Working copy read failed", ex, f);
      } finally {
        progress.done();
View Full Code Here

Examples of java.nio.ByteBuffer.compact()

            if (i > 0) {
                bytesRead += i;
            }
            tmp.flip();
            dst.put(tmp);
            tmp.compact();
        }
       
        assertEquals(16, bytesRead);
        assertEquals("0123456789abcdef", convert(dst));
        assertTrue(decoder.isCompleted());
View Full Code Here

Examples of java.nio.ByteBuffer.compact()

                    src.flip();
                    if (src.hasRemaining()) {
                        int bytesWritten = encoder.write(src);
                        System.out.println(conn + ": " + bytesWritten + " bytes written");
                    }
                    src.compact();
                   
                    if (src.position() == 0) {
                        if (proxyTask.getClientState() == ProxyTask.REQUEST_BODY_DONE) {
                            encoder.complete();
                        } else {
View Full Code Here

Examples of java.nio.ByteBuffer.compact()

                    src.flip();
                    if (src.hasRemaining()) {
                        int bytesWritten = encoder.write(src);
                        System.out.println(conn + ": " + bytesWritten + " bytes written");
                    }
                    src.compact();

                    if (src.position() == 0) {
                        if (proxyTask.getOriginState() == ProxyTask.RESPONSE_BODY_DONE) {
                            encoder.complete();
                        } else {
View Full Code Here

Examples of java.nio.ByteBuffer.compact()

                } else {
                    ByteBuffer buf = connState.getInbuf();
                    decoder.read(buf);
                    buf.flip();
                    transferred = channel.write(buf);
                    buf.compact();
                }
                connState.incrementInputCount(transferred);
               
                if (decoder.isCompleted()) {
                    // Request entity has been fully received
View Full Code Here

Examples of java.nio.ByteBuffer.compact()

                    ByteBuffer outbuf = connState.getOutbuf();
                    transferred = channel.read(outbuf);
                    if (transferred != -1) {
                        outbuf.flip();
                        encoder.write(outbuf);
                        outbuf.compact();
                    }
                }
                if (transferred == -1) {
                    encoder.complete();
                }
View Full Code Here

Examples of java.nio.ByteBuffer.compact()

            ByteBuffer buf = eb.getResource();
            final ByteBuffer ugBuffer = unget.getResource();

            if (ugBuffer.limit() - ugBuffer.remaining() > buf.remaining()) {
                //stuff the existing data after the data we are ungetting
                ugBuffer.compact();
                ugBuffer.put(buf);
                ugBuffer.flip();
                eb.free();
                connection.setExtraBytes(unget);
            } else {
View Full Code Here

Examples of java.nio.ByteBuffer.compact()

              throw new SSLException("unexpected status after wrap: "
                                     + result.getStatus());
            srv = result.getHandshakeStatus();
            snetBuffer.flip();
            result = clientEngine.unwrap(snetBuffer, empty);
            snetBuffer.compact();
            if (result.getStatus() != Status.OK)
              throw new SSLException("unexpected status after unwrap: "
                                     + result.getStatus());
            cli = result.getHandshakeStatus();
View Full Code Here

Examples of java.nio.ByteBuffer.compact()

            ByteBuffer buf = eb.getResource();
            final ByteBuffer ugBuffer = unget.getResource();

            if (ugBuffer.limit() - ugBuffer.remaining() > buf.remaining()) {
                //stuff the existing data after the data we are ungetting
                ugBuffer.compact();
                ugBuffer.put(buf);
                ugBuffer.flip();
                eb.free();
                connection.setExtraBytes(unget);
            } else {
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.