* Documents less than the maxMemorySize will be held directly in memory
*/
public static SQLXMLImpl saveToBufferManager(BufferManager bufferMgr, XMLTranslator translator)
throws TeiidComponentException, TeiidProcessingException {
boolean success = false;
final FileStore lobBuffer = bufferMgr.createFileStore("xml"); //$NON-NLS-1$
FileStoreInputStreamFactory fsisf = new FileStoreInputStreamFactory(lobBuffer, Streamable.ENCODING);
try{
Writer writer = fsisf.getWriter();
translator.translate(writer);
writer.close();
success = true;
return new SQLXMLImpl(fsisf);
} catch(IOException e) {
throw new TeiidComponentException(e);
} catch(TransformerException e) {
throw new TeiidProcessingException(e);
} finally {
if (!success && lobBuffer != null) {
lobBuffer.remove();
}
}
}