long bufferSize = bufferContainer.getSize(); // size in bytes (!= length)
/** * Returns the number of buffers that currently are in the pool and whose Class are the same as the specified * factory's. This method is provided for debugging purposes only. * * @param factory the BufferFactory * @return the number of buffers currently in the pool */ public static int getBufferCount(BufferFactory factory) { int count = 0; int nbBuffers = bufferContainers.size(); for(int i=0; i<nbBuffers; i++) { if(factory.matchesBufferClass(bufferContainers.elementAt(i).getBuffer().getClass())) { count ++; } } return count; }
/** * Returns the size in bytes of the given buffer, as defined by {@link com.mucommander.commons.io.BufferPool.BufferContainer#getSize()}. * * @param buffer the buffer for which to return the size * @param factory the factory that was used to create the buffer * @return the size in bytes of the given buffer */ private int getBufferSize(Object buffer, BufferPool.BufferFactory factory) { return factory.newBufferContainer(buffer).getSize(); }
/** * Returns the length of the given buffer, as defined by {@link com.mucommander.commons.io.BufferPool.BufferContainer#getLength()}. * * @param buffer the buffer for which to return the length * @param factory the factory that was used to create the buffer * @return the length of the given buffer */ private int getBufferLength(Object buffer, BufferPool.BufferFactory factory) { return factory.newBufferContainer(buffer).getLength(); }