org.apache.camel.converter.stream
Class ReaderCache

java.lang.Object
  extended by java.io.Reader
      extended by java.io.StringReader
          extended by org.apache.camel.converter.stream.ReaderCache
All Implemented Interfaces:
Closeable, Readable, StreamCache

public class ReaderCache
extends StringReader
implements StreamCache

A StreamCache for String Readers


Field Summary
 
Fields inherited from class java.io.Reader
lock
 
Fields inherited from interface org.apache.camel.StreamCache
DEFAULT_SPOOL_THRESHOLD
 
Constructor Summary
ReaderCache(String data)
           
 
Method Summary
 void close()
           
 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 reset()
          Resets the StreamCache for a new stream consumption.
 void writeTo(OutputStream os)
          Writes the stream to the given output
 
Methods inherited from class java.io.StringReader
mark, markSupported, read, read, ready, skip
 
Methods inherited from class java.io.Reader
read, read
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReaderCache

public ReaderCache(String data)
Method Detail

close

public void close()
Specified by:
close in interface Closeable
Overrides:
close in class StringReader

reset

public void reset()
Description copied from interface: StreamCache
Resets the StreamCache for a new stream consumption.

Specified by:
reset in interface StreamCache
Overrides:
reset in class StringReader

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