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

File AbstractInputStreamInputSource.java

 

Coverage histogram

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

Code metrics

6
8
4
1
65
34
7
0.88
2
4
1.75

Classes

Class Line # Actions
AbstractInputStreamInputSource 29 8 0% 7 7
0.611111161.1%
 

Contributing tests

This file is covered by 20 tests. .

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.input;
21   
22    import java.io.IOException;
23    import java.io.InputStream;
24   
25    /**
26    * @version $Id: 1e3aacf884a49592ae5ace56bf17f079e2760296 $
27    * @since 6.2M1
28    */
 
29    public abstract class AbstractInputStreamInputSource implements InputStreamInputSource
30    {
31    protected InputStream inputStream;
32   
 
33  0 toggle @Override
34    public boolean restartSupported()
35    {
36  0 return true;
37    }
38   
 
39  25 toggle @Override
40    public InputStream getInputStream() throws IOException
41    {
42  25 if (this.inputStream == null) {
43  25 this.inputStream = openStream();
44    }
45   
46  25 return this.inputStream;
47    }
48   
49    protected abstract InputStream openStream() throws IOException;
50   
 
51  29 toggle @Override
52    public void close() throws IOException
53    {
54  29 if (this.inputStream != null) {
55  25 this.inputStream.close();
56    }
57  29 this.inputStream = null;
58    }
59   
 
60  0 toggle @Override
61    public String toString()
62    {
63  0 return this.inputStream != null ? this.inputStream.toString() : super.toString();
64    }
65    }