Package java.nio

Examples of java.nio.ByteBuffer.mark()


        buf.position(offset);
        buf.mark();
        buf.limit(size + offset);
      } else {
        buf = ByteBuffer.allocateDirect(size);
        buf.mark();
        buf.limit(size);
      }

      buf.put(EMPTY_BYTES);
      buf.reset();
View Full Code Here


            }

            byteBuffer.put(buffer, 0, read);
            // sets the limit to the current position and then the position to zero
            byteBuffer.flip();
            byteBuffer.mark();

            for(Message msg = decoder.decode(byteBuffer); msg != null; msg = decoder.decode(byteBuffer)) {
              if (msg.isResponse()) {
                responder.responseReceived(StreamedDuplexChannel.this, msg);
              } else {
View Full Code Here

              if (msg.isResponse()) {
                responder.responseReceived(StreamedDuplexChannel.this, msg);
              } else {
                messageListener.get().onMessage(msg);
              }
              byteBuffer.mark();
            }
            // reset to the position of the last mark (end of last message)
            byteBuffer.reset();
            if (byteBuffer.position() != 0) {
              byteBuffer.compact();
View Full Code Here

    src.position(start);

    while (src.hasRemaining()) {
      if (b == src.get()) { // matching first byte
        src.mark(); // save position in loop
        tgt.mark(); // save position in target
        boolean found = true;
        int pos = src.position() - 1;
        while (tgt.hasRemaining()) {
          if (!src.hasRemaining()) { // src expired first
            tgt.reset();
View Full Code Here

    fields = null;
   
    if (buffer.position() < lb.bytesUsed)
    {
      // save current record position so we can reset on errors
      buffer.mark();
      long logKey = ((long) lb.bsn << 24) | (buffer.position() & 0xffffff ) ;

      try {
        type = buffer.getShort();
        length  = buffer.getShort();
View Full Code Here

    private void realloc(int size) {
        ByteBuffer buffer = ByteBuffer.allocate(size);
        this.buffer.flip();
        buffer.put(this.buffer);
        buffer.mark();
        this.buffer = buffer;
    }
}
View Full Code Here

      src.position(start);

      while (src.hasRemaining()) {
        if (b == src.get()) { // matching first byte
          src.mark(); // save position in loop
          tgt.mark(); // save position in target
          boolean found = true;
          int pos = src.position() - 1;
          while (tgt.hasRemaining()) {
            if (!src.hasRemaining()) { // src expired first
              tgt.reset();
View Full Code Here

                logger.log(
        Level.FINEST,
        "processQueue protocol:{0} size:{1,number,#} head={2}",
        SimpleSgsProtocolImpl.this, pendingWrites.size(),
        HexDumper.format(message, 0x50));
    message.mark();
            }
            try {
                asyncMsgChannel.write(message, this);
            } catch (RuntimeException e) {
                logger.logThrow(Level.SEVERE, e,
View Full Code Here

   */
  public static String decodeNoFallback(final Charset cs,
      final byte[] buffer, final int start, final int end)
      throws CharacterCodingException {
    final ByteBuffer b = ByteBuffer.wrap(buffer, start, end - start);
    b.mark();

    // Try our built-in favorite. The assumption here is that
    // decoding will fail if the data is not actually encoded
    // using that encoder.
    //
View Full Code Here

      return;
    }
    internalBuffer.put(b, off, len);
    ByteBuffer dup = internalBuffer.duplicate();
    dup.position(ipos);
    dup.mark();
    dup.limit(ipos + len);
    vec.add(dup);
    lastInternalBuffer = internalBuffer;
  }
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.