Class | Line # | Actions | |||||
---|---|---|---|---|---|---|---|
AbstractOutputStreamOutputTarget | 29 | 7 | 0% | 5 | 4 |
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: c45d9b75df7ec6db68a54080148930562bf2a8db $ | |
27 | * @since 6.2M1 | |
28 | */ | |
29 | public abstract class AbstractOutputStreamOutputTarget implements OutputStreamOutputTarget | |
30 | { | |
31 | protected OutputStream outputStream; | |
32 | ||
33 | protected abstract OutputStream openStream() throws IOException; | |
34 | ||
35 | 0 | @Override |
36 | public boolean restartSupported() | |
37 | { | |
38 | 0 | return true; |
39 | } | |
40 | ||
41 | 1 | @Override |
42 | public OutputStream getOutputStream() throws IOException | |
43 | { | |
44 | 1 | if (this.outputStream == null) { |
45 | 1 | this.outputStream = openStream(); |
46 | } | |
47 | ||
48 | 1 | return this.outputStream; |
49 | } | |
50 | ||
51 | 1 | @Override |
52 | public void close() throws IOException | |
53 | { | |
54 | 1 | if (this.outputStream != null) { |
55 | 1 | this.outputStream.close(); |
56 | } | |
57 | 1 | this.outputStream = null; |
58 | } | |
59 | } |