1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.filter.output

File DefaultOutputStreamOutputTarget.java

 

Coverage histogram

../../../../img/srcFileCovDistChart7.png
64% of files have more coverage

Code metrics

2
8
6
1
85
39
7
0.88
1.33
6
1.17

Classes

Class Line # Actions
DefaultOutputStreamOutputTarget 29 8 0% 7 6
0.62562.5%
 

Contributing tests

This file is covered by 1 test. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.filter.output;
21   
22    import java.io.IOException;
23    import java.io.OutputStream;
24   
25    /**
26    * @version $Id: 649422255fad3bb48a72599affa2743aacb43671 $
27    * @since 6.2M1
28    */
 
29    public class DefaultOutputStreamOutputTarget implements OutputStreamOutputTarget
30    {
31    private final boolean close;
32   
33    private final OutputStream outputStream;
34   
35    /**
36    * Create an instance of {@link OutputStreamOutputTarget} returning the passed {@link OutputStream}.
37    * <p>
38    * The passed {@link OutputStream} is not closed when the {@link OutputTarget} is closed.
39    *
40    * @param outputStream the {@link OutputStream}
41    */
 
42  26 toggle public DefaultOutputStreamOutputTarget(OutputStream outputStream)
43    {
44  26 this(outputStream, false);
45    }
46   
47    /**
48    * Create an instance of {@link OutputStreamOutputTarget} returning the passed {@link OutputStream}.
49    *
50    * @param outputStream the {@link OutputStream}
51    * @param close indicate of the passer {@link OutputStream} should be closed when the {@link OutputTarget} is closed
52    * @since 6.2M1
53    */
 
54  26 toggle public DefaultOutputStreamOutputTarget(OutputStream outputStream, boolean close)
55    {
56  26 this.outputStream = outputStream;
57  26 this.close = close;
58    }
59   
 
60  0 toggle @Override
61    public boolean restartSupported()
62    {
63  0 return false;
64    }
65   
 
66  25 toggle @Override
67    public OutputStream getOutputStream()
68    {
69  25 return this.outputStream;
70    }
71   
 
72  25 toggle @Override
73    public void close() throws IOException
74    {
75  25 if (this.close) {
76  0 this.outputStream.close();
77    }
78    }
79   
 
80  0 toggle @Override
81    public String toString()
82    {
83  0 return this.outputStream.toString();
84    }
85    }