1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.vfs2.provider;
18
19 import java.io.InputStream;
20 import java.util.ArrayList;
21
22 import org.apache.commons.vfs2.FileSystemException;
23 import org.apache.commons.vfs2.RandomAccessContent;
24
25
26
27
28 final class FileContentThreadData {
29
30 private ArrayList<InputStream> inputStreamList;
31 private ArrayList<RandomAccessContent> randomAccessContentList;
32 private DefaultFileContent.FileContentOutputStream outputStream;
33
34 FileContentThreadData() {
35 }
36
37 void add(final InputStream inputStream) {
38 if (inputStreamList == null) {
39 inputStreamList = new ArrayList<>();
40 }
41 inputStreamList.add(inputStream);
42 }
43
44 void add(final RandomAccessContent randomAccessContent) {
45 if (randomAccessContentList == null) {
46 randomAccessContentList = new ArrayList<>();
47 }
48 randomAccessContentList.add(randomAccessContent);
49 }
50
51
52
53
54
55
56 void closeOutputStream() throws FileSystemException {
57 outputStream.close();
58 outputStream = null;
59 }
60
61 DefaultFileContent.FileContentOutputStream getOutputStream() {
62 return outputStream;
63 }
64
65 boolean hasInputStream() {
66 return inputStreamList != null && !inputStreamList.isEmpty();
67 }
68
69 boolean hasRandomAccessContent() {
70 return randomAccessContentList != null && !randomAccessContentList.isEmpty();
71 }
72
73 boolean hasStreams() {
74 return hasInputStream() || outputStream != null || hasRandomAccessContent();
75 }
76
77 void remove(final InputStream inputStream) {
78
79
80
81
82
83
84
85
86
87
88 if (inputStreamList != null) {
89 inputStreamList.remove(inputStream);
90 }
91 }
92
93 void remove(final RandomAccessContent randomAccessContent) {
94 if (randomAccessContentList != null) {
95 randomAccessContentList.remove(randomAccessContent);
96 }
97 }
98
99 InputStream removeInputStream(final int pos) {
100 return inputStreamList.remove(pos);
101 }
102
103 Object removeRandomAccessContent(final int pos) {
104 return randomAccessContentList.remove(pos);
105 }
106
107 void setOutputStream(final DefaultFileContent.FileContentOutputStream outputStream) {
108 this.outputStream = outputStream;
109 }
110 }