voldemort.common.nio
Class ByteBufferBackedInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by voldemort.common.nio.ByteBufferBackedInputStream
All Implemented Interfaces:
java.io.Closeable

public class ByteBufferBackedInputStream
extends java.io.InputStream

ByteBufferBackedInputStream allows a ByteBuffer to be the source of data for InputStream-based callers.

This class is used to interface with callers using "classic" java.io.* APIs. For code that manages the ByteBufferBackedInputStream, there are accessor methods for the underlying buffer should it need to expand and contract on reuse.


Constructor Summary
ByteBufferBackedInputStream(java.nio.ByteBuffer buffer)
           
ByteBufferBackedInputStream(java.nio.ByteBuffer buffer, org.apache.commons.lang.mutable.MutableLong sizeTracker)
           
 
Method Summary
 void close()
           
 java.nio.ByteBuffer getBuffer()
           
 int read()
           
 int read(byte[] bytes, int off, int len)
           
 void setBuffer(java.nio.ByteBuffer newBuffer)
           
 
Methods inherited from class java.io.InputStream
available, mark, markSupported, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ByteBufferBackedInputStream

public ByteBufferBackedInputStream(java.nio.ByteBuffer buffer)

ByteBufferBackedInputStream

public ByteBufferBackedInputStream(java.nio.ByteBuffer buffer,
                                   org.apache.commons.lang.mutable.MutableLong sizeTracker)
Method Detail

getBuffer

public java.nio.ByteBuffer getBuffer()

setBuffer

public void setBuffer(java.nio.ByteBuffer newBuffer)

read

public int read()
         throws java.io.IOException
Specified by:
read in class java.io.InputStream
Throws:
java.io.IOException

read

public int read(byte[] bytes,
                int off,
                int len)
         throws java.io.IOException
Overrides:
read in class java.io.InputStream
Throws:
java.io.IOException

close

public void close()
Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.InputStream


Jay Kreps, Roshan Sumbaly, Alex Feinberg, Bhupesh Bansal, Lei Gao, Chinmay Soman, Vinoth Chandar, Zhongjie Wu