org.apache.camel.converter.stream
Class InputStreamCache

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.ByteArrayInputStream
          extended by org.apache.camel.converter.stream.InputStreamCache
All Implemented Interfaces:
Closeable, StreamCache

public final class InputStreamCache
extends ByteArrayInputStream
implements StreamCache

A StreamCache for caching using an in-memory byte array.


Field Summary
 
Fields inherited from class java.io.ByteArrayInputStream
buf, count, mark, pos
 
Fields inherited from interface org.apache.camel.StreamCache
DEFAULT_SPOOL_THRESHOLD
 
Constructor Summary
InputStreamCache(byte[] data)
           
InputStreamCache(byte[] data, int count)
           
 
Method Summary
 boolean inMemory()
          Whether this StreamCache is in memory only or spooled to persistent storage such as files.
 long length()
          Gets the length of the cached stream.
 void writeTo(OutputStream os)
          Writes the stream to the given output
 
Methods inherited from class java.io.ByteArrayInputStream
available, close, mark, markSupported, read, read, reset, skip
 
Methods inherited from class java.io.InputStream
read
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.camel.StreamCache
reset
 

Constructor Detail

InputStreamCache

public InputStreamCache(byte[] data)

InputStreamCache

public InputStreamCache(byte[] data,
                        int count)
Method Detail

writeTo

public void writeTo(OutputStream os)
             throws IOException
Description copied from interface: StreamCache
Writes the stream to the given output

Specified by:
writeTo in interface StreamCache
Parameters:
os - the destination to write to
Throws:
IOException - is thrown if write fails

inMemory

public boolean inMemory()
Description copied from interface: StreamCache
Whether this StreamCache is in memory only or spooled to persistent storage such as files.

Specified by:
inMemory in interface StreamCache

length

public long length()
Description copied from interface: StreamCache
Gets the length of the cached stream.

The implementation may return 0 in cases where the length cannot be computed, or if the implementation does not support this.

Specified by:
length in interface StreamCache
Returns:
number of bytes in the cache.


Apache Camel