Package java.nio

Examples of java.nio.ByteBuffer.capacity()


            serializationPack(message, clientID, out);

            ByteBuffer buf = ByteBuffer.wrap(baos.toByteArray());
            if (messageMonitor != null) {
                messageMonitor.sending(message, buf.capacity());
            }
           
            // TODO Remove - this is should be in messageMonitor
            if (logger.isLoggable(Level.FINEST)) {
                logger.finest("Packed " + message.getClass().getName() + "   size " + buf.capacity());
View Full Code Here


                messageMonitor.sending(message, buf.capacity());
            }
           
            // TODO Remove - this is should be in messageMonitor
            if (logger.isLoggable(Level.FINEST)) {
                logger.finest("Packed " + message.getClass().getName() + "   size " + buf.capacity());
            }
            return buf;
        } catch (IOException ex) {
            Logger.getLogger(MessagePacker.class.getName()).log(Level.SEVERE, null, ex);
        } finally {
View Full Code Here

            if(!buffer.hasRemaining()) {
                b.remove();
            } else if(buffer.position() > 0) {
                int bytesLeftToRead = buffer.remaining();
                buffer.limit(buffer.capacity());
                ByteBuffer noneRead = buffer.slice();
                noneRead.position(bytesLeftToRead);
                noneRead.limit(bytesLeftToRead);
                b.set(noneRead);
            } else {
View Full Code Here

            ByteBuffer current = (ByteBuffer)b.next();
           
            if(bytesLeft <= 0) {
                b.remove();
           
            } else if(current.capacity() >= bytesLeft) {
                current.position(bytesLeft);
                current.limit(bytesLeft);
            }

            bytesLeft -= current.capacity();
View Full Code Here

            } else if(current.capacity() >= bytesLeft) {
                current.position(bytesLeft);
                current.limit(bytesLeft);
            }

            bytesLeft -= current.capacity();
        }
    }
   
    /**
     * Skips the specified number of bytes.
View Full Code Here

            buffers.removeFirst();

        // we still have more to read from this buffer
        } else {
            int bytesLeftToRead = readFrom.remaining();
            readFrom.limit(readFrom.capacity());
            ByteBuffer noneRead = readFrom.slice();
            noneRead.position(bytesLeftToRead);
            noneRead.limit(bytesLeftToRead);
            buffers.set(0, noneRead);
        }
View Full Code Here

     */
    private ByteBuffer getWriteIntoBuffer() {
        // we have a buffer with space remaining
        if(!buffers.isEmpty()) {
            ByteBuffer last = (ByteBuffer)buffers.getLast();
            if(last.position() < last.capacity()) {
                last.limit(last.capacity());
                return last;
            }
        }

View Full Code Here

    private ByteBuffer getWriteIntoBuffer() {
        // we have a buffer with space remaining
        if(!buffers.isEmpty()) {
            ByteBuffer last = (ByteBuffer)buffers.getLast();
            if(last.position() < last.capacity()) {
                last.limit(last.capacity());
                return last;
            }
        }

        // we need to create a new buffer
View Full Code Here

  private int createBlurTexture(GL gl)
  {
    ByteBuffer data = BufferUtil.newByteBuffer(m_Texture_Width * m_Texture_Height * 4); // Create Storage Space For
    // Texture
    // Data (128x128x4)
    data.limit(data.capacity());

    int[] txtnumber = new int[1];

    gl.glGenTextures(1, txtnumber, 0); // Create 1 Texture
    gl.glBindTexture(GL.GL_TEXTURE_RECTANGLE_ARB, txtnumber[0]); // Bind The Texture
View Full Code Here

        // Compute the position in the current page
        int pagePos = ( int ) ( position + ( pageNb + 1 ) * LONG_SIZE + INT_SIZE ) - pageNb * pageSize;

        ByteBuffer pageData = pageIos[pageNb].getData();
        int remaining = pageData.capacity() - pagePos;

        if ( length == 0 )
        {
            // No bytes to read : return null;
            return null;
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.