01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.commons.vfs.provider;
18:
19: import org.apache.commons.vfs.FileSystemException;
20: import org.apache.commons.vfs.RandomAccessContent;
21:
22: import java.io.InputStream;
23: import java.util.ArrayList;
24:
25: /**
26: * Holds the data which needs to be local to the current thread
27: */
28: class FileContentThreadData {
29: // private int state = DefaultFileContent.STATE_CLOSED;
30:
31: private final ArrayList instrs = new ArrayList();
32: private final ArrayList rastrs = new ArrayList();
33: private DefaultFileContent.FileContentOutputStream outstr;
34:
35: FileContentThreadData() {
36: }
37:
38: /*
39: int getState()
40: {
41: return state;
42: }
43:
44: void setState(int state)
45: {
46: this.state = state;
47: }
48: */
49:
50: void addInstr(InputStream is) {
51: this .instrs.add(is);
52: }
53:
54: void setOutstr(DefaultFileContent.FileContentOutputStream os) {
55: this .outstr = os;
56: }
57:
58: DefaultFileContent.FileContentOutputStream getOutstr() {
59: return this .outstr;
60: }
61:
62: void addRastr(RandomAccessContent ras) {
63: this .rastrs.add(ras);
64: }
65:
66: int getInstrsSize() {
67: return this .instrs.size();
68: }
69:
70: public Object removeInstr(int pos) {
71: return this .instrs.remove(pos);
72: }
73:
74: public void removeInstr(InputStream instr) {
75: this .rastrs.remove(instr);
76: }
77:
78: public Object removeRastr(int pos) {
79: return this .rastrs.remove(pos);
80: }
81:
82: public void removeRastr(RandomAccessContent ras) {
83: this .instrs.remove(ras);
84: }
85:
86: public boolean hasStreams() {
87: return instrs.size() > 0 || outstr != null || rastrs.size() > 0;
88: }
89:
90: public void closeOutstr() throws FileSystemException {
91: outstr.close();
92: outstr = null;
93: }
94:
95: int getRastrsSize() {
96: return rastrs.size();
97: }
98: }
|