Clover Coverage Report - Atlassian Core
Coverage timestamp: Sun Nov 30 2008 18:33:35 CST
9   53   6   1.5
0   37   0.67   6
6     1  
1    
 
 
  DeferredSpool       Line # 13 9 6 0% 0.0
 
No Tests
 
1    package com.atlassian.core.spool;
2   
3    import java.io.IOException;
4    import java.io.InputStream;
5    import java.io.BufferedInputStream;
6   
7    import org.apache.commons.io.IOUtils;
8   
9    /**
10    * Thresholding spool that uses a DeferredSpoolFileOutputStream for spooling, allowing for a balance between memory
11    * usage and speed.
12    */
 
13    public class DeferredSpool implements FileSpool, ThresholdingSpool
14    {
15    private int maxMemorySpool;
16    private FileFactory fileFactory = DefaultSpoolFileFactory.getInstance();
17   
 
18  0 toggle public FileFactory getFileFactory()
19    {
20  0 return fileFactory;
21    }
22   
 
23  0 toggle public void setFileFactory(FileFactory fileFactory)
24    {
25  0 this.fileFactory = fileFactory;
26    }
27   
 
28  0 toggle public void setThresholdBytes(int bytes)
29    {
30  0 this.maxMemorySpool = bytes;
31    }
32   
 
33  0 toggle public int getThresholdBytes()
34    {
35  0 return maxMemorySpool;
36    }
37   
 
38  0 toggle public InputStream spool(InputStream is) throws IOException
39    {
40  0 DeferredSpoolFileOutputStream deferredStream = getNewDeferredSpoolFileOutputStream();
41  0 IOUtils.copy(is, deferredStream);
42  0 deferredStream.close();
43  0 return new BufferedInputStream(deferredStream.getInputStream());
44    }
45   
46    /**
47    * @return a new DeferredSpoolFileOutputStream
48    */
 
49  0 toggle protected DeferredSpoolFileOutputStream getNewDeferredSpoolFileOutputStream()
50    {
51  0 return new DeferredSpoolFileOutputStream(maxMemorySpool, getFileFactory());
52    }
53    }