KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > vfs > provider > FileContentThreadData


1 /*
2  * Copyright 2002-2005 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.commons.vfs.provider;
17
18 import org.apache.commons.vfs.FileSystemException;
19 import org.apache.commons.vfs.RandomAccessContent;
20
21 import java.io.IOException JavaDoc;
22 import java.io.InputStream JavaDoc;
23 import java.util.ArrayList JavaDoc;
24
25 /**
26  * Holds the data which needs to be local to the current thread
27  */

28 class FileContentThreadData
29 {
30     // private int state = DefaultFileContent.STATE_CLOSED;
31

32     private final ArrayList JavaDoc instrs = new ArrayList JavaDoc();
33     private DefaultFileContent.FileContentOutputStream outstr;
34     private RandomAccessContent rastr;
35
36     FileContentThreadData()
37     {
38     }
39
40     /*
41     int getState()
42     {
43         return state;
44     }
45
46     void setState(int state)
47     {
48         this.state = state;
49     }
50     */

51
52     void addInstr(InputStream JavaDoc is)
53     {
54         this.instrs.add(is);
55     }
56
57     void setOutstr(DefaultFileContent.FileContentOutputStream os)
58     {
59         this.outstr = os;
60     }
61
62     DefaultFileContent.FileContentOutputStream getOutstr()
63     {
64         return this.outstr;
65     }
66
67     void setRastr(RandomAccessContent ras)
68     {
69         this.rastr = ras;
70     }
71
72     int getInstrsSize()
73     {
74         return this.instrs.size();
75     }
76
77     public Object JavaDoc removeInstr(int pos)
78     {
79         return this.instrs.remove(pos);
80     }
81
82     public void removeInstr(InputStream JavaDoc instr)
83     {
84         this.instrs.remove(instr);
85     }
86
87     public RandomAccessContent getRastr()
88     {
89         return this.rastr;
90     }
91
92     public boolean hasStreams()
93     {
94         return instrs.size() > 0 || outstr != null || rastr != null;
95     }
96
97     public void closeOutstr() throws FileSystemException
98     {
99         outstr.close();
100         outstr = null;
101     }
102
103     public void closeRastr() throws IOException JavaDoc
104     {
105         rastr.close();
106         rastr = null;
107     }
108 }
109
Popular Tags