KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > filesys > smb > dcerpc > server > DCEPipeFile


1 /*
2  * Copyright (C) 2005 Alfresco, Inc.
3  *
4  * Licensed under the Mozilla Public License version 1.1
5  * with a permitted attribution clause. You may obtain a
6  * copy of the License at
7  *
8  * http://www.alfresco.org/legal/license.txt
9  *
10  * Unless required by applicable law or agreed to in writing,
11  * software distributed under the License is distributed on an
12  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13  * either express or implied. See the License for the specific
14  * language governing permissions and limitations under the
15  * License.
16  */

17 package org.alfresco.filesys.smb.dcerpc.server;
18
19 import java.io.IOException JavaDoc;
20
21 import org.alfresco.filesys.server.filesys.NetworkFile;
22 import org.alfresco.filesys.smb.dcerpc.DCEBuffer;
23 import org.alfresco.filesys.smb.dcerpc.DCEPipeType;
24
25 /**
26  * DCE/RPC Pipe File Class
27  * <p>
28  * Contains the details and state of a DCE/RPC special named pipe.
29  */

30 public class DCEPipeFile extends NetworkFile
31 {
32
33     // Maximum receive/transmit DCE fragment size
34

35     private int m_maxRxFragSize;
36     private int m_maxTxFragSize;
37
38     // Named pipe state flags
39

40     private int m_state;
41
42     // DCE/RPC handler for this named pipe
43

44     private DCEHandler m_handler;
45
46     // Current DCE buffered data
47

48     private DCEBuffer m_dceData;
49
50     /**
51      * Class constructor
52      *
53      * @param id int
54      */

55     public DCEPipeFile(int id)
56     {
57         super(id);
58         setName(DCEPipeType.getTypeAsString(id));
59
60         // Set the DCE/RPC request handler for the pipe
61

62         setRequestHandler(DCEPipeHandler.getHandlerForType(id));
63     }
64
65     /**
66      * Return the maximum receive fragment size
67      *
68      * @return int
69      */

70     public final int getMaxReceiveFragmentSize()
71     {
72         return m_maxRxFragSize;
73     }
74
75     /**
76      * Return the maximum transmit fragment size
77      *
78      * @return int
79      */

80     public final int getMaxTransmitFragmentSize()
81     {
82         return m_maxTxFragSize;
83     }
84
85     /**
86      * Return the named pipe state
87      *
88      * @return int
89      */

90     public final int getPipeState()
91     {
92         return m_state;
93     }
94
95     /**
96      * Return the pipe type id
97      *
98      * @return int
99      */

100     public final int getPipeId()
101     {
102         return getFileId();
103     }
104
105     /**
106      * Determine if the pipe has a request handler
107      *
108      * @return boolean
109      */

110     public final boolean hasRequestHandler()
111     {
112         return m_handler != null ? true : false;
113     }
114
115     /**
116      * Return the pipes DCE/RPC handler
117      *
118      * @return DCEHandler
119      */

120     public final DCEHandler getRequestHandler()
121     {
122         return m_handler;
123     }
124
125     /**
126      * Determine if the pipe has any buffered data
127      *
128      * @return boolean
129      */

130     public final boolean hasBufferedData()
131     {
132         return m_dceData != null ? true : false;
133     }
134
135     /**
136      * Get the buffered data for the pipe
137      *
138      * @return DCEBuffer
139      */

140     public final DCEBuffer getBufferedData()
141     {
142         return m_dceData;
143     }
144
145     /**
146      * Set buffered data for the pipe
147      *
148      * @param buf DCEBuffer
149      */

150     public final void setBufferedData(DCEBuffer buf)
151     {
152         m_dceData = buf;
153     }
154
155     /**
156      * Set the maximum receive fragment size
157      *
158      * @param siz int
159      */

160     public final void setMaxReceiveFragmentSize(int siz)
161     {
162         m_maxRxFragSize = siz;
163     }
164
165     /**
166      * Set the maximum transmit fragment size
167      *
168      * @param siz int
169      */

170     public final void setMaxTransmitFragmentSize(int siz)
171     {
172         m_maxTxFragSize = siz;
173     }
174
175     /**
176      * Set the named pipe state flags
177      *
178      * @param state int
179      */

180     public final void setPipeState(int state)
181     {
182         m_state = state;
183     }
184
185     /**
186      * Set the pipes DCE/RPC handler
187      *
188      * @param handler DCEHandler
189      */

190     public final void setRequestHandler(DCEHandler handler)
191     {
192         m_handler = handler;
193     }
194
195     /**
196      * Dump the file details
197      */

198     public final void DumpFile()
199     {
200         System.out.println("** DCE/RPC Named Pipe: " + getName());
201         System.out.println(" File ID : " + getFileId());
202         System.out.println(" State : 0x" + Integer.toHexString(getPipeState()));
203         System.out.println(" Max Rx : " + getMaxReceiveFragmentSize());
204         System.out.println(" Max Tx : " + getMaxTransmitFragmentSize());
205         System.out.println(" Handler : " + getRequestHandler());
206     }
207
208     /**
209      * @see NetworkFile#closeFile()
210      */

211     public void closeFile() throws IOException JavaDoc
212     {
213     }
214
215     /**
216      * @see NetworkFile#openFile(boolean)
217      */

218     public void openFile(boolean createFlag) throws IOException JavaDoc
219     {
220     }
221
222     /**
223      * @see NetworkFile#readFile(byte[], int, int, long)
224      */

225     public int readFile(byte[] buf, int len, int pos, long fileOff) throws IOException JavaDoc
226     {
227         return 0;
228     }
229
230     /**
231      * Flush any buffered output to the file
232      *
233      * @throws IOException
234      */

235     public void flushFile() throws IOException JavaDoc
236     {
237     }
238
239     /**
240      * @see NetworkFile#seekFile(long, int)
241      */

242     public long seekFile(long pos, int typ) throws IOException JavaDoc
243     {
244         return 0;
245     }
246
247     /**
248      * @see NetworkFile#truncateFile(long)
249      */

250     public void truncateFile(long siz) throws IOException JavaDoc
251     {
252     }
253
254     /**
255      * @see NetworkFile#writeFile(byte[], int, int, long)
256      */

257     public void writeFile(byte[] buf, int len, int pos, long fileOff) throws IOException JavaDoc
258     {
259     }
260 }
Popular Tags