ccs.utils
Class SwappingBuffer

java.lang.Object
  extended by java.io.OutputStream
      extended by ccs.utils.SwappingBuffer
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable
Direct Known Subclasses:
RepeatingSwappingBuffer

public class SwappingBuffer
extends java.io.OutputStream

A dual-mode buffer that efficiently stores an arbitrary amount of transient data. For small amounts, it uses memory. However, once the buffer size passes a threshold, it automatically copies this to a disk file and uses that from then on. The disk file is encrypted with a throw-away key; in this way if the app crashes before it has wiped any disk file, there is no security breach.

A SwappingBuffer is strictly a "single-shot" object. It has 4 lifecycle stages: writable, unwritable, read-committed and dead. It proceeds through each of these stages, in the above order: