Package org.miv.mbox.net

Examples of org.miv.mbox.net.PositionableByteArrayInputStream


          // incomplete or there are no more messages or a header is
          // incomplete.

          ByteBuffer unpackedBuffer = unpacker.unpackMessage(buf, beg, end);
          if (unpackedBuffer == buf) {
            in = new PositionableByteArrayInputStream(buf.array(), beg, end - beg);
          } else {
            in = new PositionableByteArrayInputStream(
                unpackedBuffer.array(), 0, unpackedBuffer.capacity());
          }
         
          decoder.decodeMessage(in);
          buf.position(end);

          if (end + sizeOfInt <= limit) {
            // There is a following message.

            beg = end + sizeOfInt;
            end = end + unpacker.unpackMessageSize(buf) + sizeOfInt;
          } else {
            // There is the beginning of a following message
            // but the header is incomplete. Compact the buffer
            // and stop here.
            assert (beg >= sizeOfInt);

            beg = end;
            int p = sizeOfInt - ((end + sizeOfInt) - limit);
            compactBuffer();
            pos = p;
            beg = 0;
            end = -1;
            break;
          }
        }

        if (end == limit) {
          // If the end of the message coincides with the limit of
          // what
          // was read we have one last complete message. We decode it
          // and
          // clear the buffer for the next call.

          ByteBuffer unpackedBuffer = unpacker.unpackMessage(buf, beg, end);
          if (unpackedBuffer == buf) {
            in = new PositionableByteArrayInputStream(buf.array(), beg, end - beg);
          } else {
            in = new PositionableByteArrayInputStream(
                unpackedBuffer.array(), 0, unpackedBuffer.capacity());
          }
         
          decoder.decodeMessage(in);
         
View Full Code Here

TOP

Related Classes of org.miv.mbox.net.PositionableByteArrayInputStream

Copyright © 2018 www.massapicom. 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.