Clover Coverage Report - Atlassian Core
Coverage timestamp: Sun Nov 30 2008 18:33:35 CST
5   40   3   1.67
0   24   0.6   3
3     1  
1    
 
 
  ByteArraySpool       Line # 14 5 3 50% 0.5
 
  (1)
 
1    package com.atlassian.core.spool;
2   
3    import java.io.ByteArrayInputStream;
4    import java.io.IOException;
5    import java.io.InputStream;
6   
7    import org.apache.commons.io.IOUtils;
8    import org.apache.commons.io.output.ByteArrayOutputStream;
9   
10    /**
11    * A very simple spool that uses a ByteArray buffer. Default buffer size is 10KiB
12    */
13   
 
14    public class ByteArraySpool implements Spool
15    {
16    private int initialBufferSize = 10 * 1024;
17   
 
18  0 toggle public int getInitialBufferSize()
19    {
20  0 return initialBufferSize;
21    }
22   
23    /**
24    * Configure the initial size of the byte array buffer.
25    *
26    * @param initialBufferSize The initial size of the buffer in bytes
27    */
 
28  0 toggle public void setInitialBufferSize(int initialBufferSize)
29    {
30  0 this.initialBufferSize = initialBufferSize;
31    }
32   
 
33  1 toggle public InputStream spool(InputStream is) throws IOException
34    {
35  1 ByteArrayOutputStream buf = new ByteArrayOutputStream(initialBufferSize);
36  1 IOUtils.copy(is, buf);
37  1 return new ByteArrayInputStream(buf.toByteArray());
38    }
39   
40    }