A temporary file which can store arbitrary data for the duration of a process.
If we are dealing with a 4GB XML file, we don't want lots of seldom accessed strings hanging around the heap.
Currently strings and XML documents may be stored.
Usage:
For each object to be stored, firstly a "container" is created and then data is appended/written to the container.
In this way, it's possible for an XML SAX parser, finding an XML [myObject type="x"] tag, to create the container and place
it in the appropriate place in the destination data structure (e.g. if its place dependent on the element's attribute),
but for the container to be actually filled with data
while processing further tags, e.g. child elements of the original tag.
OutOfHeapTemporaryFileStorage file = new OutOfHeapTemporaryFileStorage(); // file created in /tmp
// Persisting and loading a string
OutOfHeapString str = file.newStringContainer();
str.append("xyz");
System.out.println("str is: " + str.toString()); // fetches string from file
// Persisting and loading chunks of XML
org.w3c.dom.Element anElement = ....;
OutOfHeapXml xml = file.newXmlContainer();
xml.setXml(anElement); // call only once
org.w3c.dom.Element afterLoading = x.toXmlDomElement();