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 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 (this.inputStreamList == null) {
39 this.inputStreamList = new ArrayList<>();
40 }
41 this.inputStreamList.add(inputStream);
42 }
43
44 void add(final RandomAccessContent randomAccessContent) {
45 if (this.randomAccessContentList == null) {
46 this.randomAccessContentList = new ArrayList<>();
47 }
48 this.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 this.outputStream;
63 }
64
65 boolean hasInputStream() {
66 return this.inputStreamList != null && !this.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 InputStream removeInputStream(final int pos) {
78 return this.inputStreamList.remove(pos);
79 }
80
81 void remove(final InputStream inputStream) {
82
83
84
85
86
87
88
89
90
91
92 if (this.inputStreamList != null) {
93 this.inputStreamList.remove(inputStream);
94 }
95 }
96
97 Object removeRandomAccessContent(final int pos) {
98 return this.randomAccessContentList.remove(pos);
99 }
100
101 void remove(final RandomAccessContent randomAccessContent) {
102 if (this.randomAccessContentList != null) {
103 this.randomAccessContentList.remove(randomAccessContent);
104 }
105 }
106
107 void setOutputStream(final DefaultFileContent.FileContentOutputStream outputStream) {
108 this.outputStream = outputStream;
109 }
110 }