View Javadoc

1   /***
2    * 
3    */
4   package twcsckernel.projectbase.io;
5   
6   import java.io.Serializable;
7   import java.rmi.RemoteException;
8   
9   import twcsckernel.projectbase.common.FileFactory;
10  
11  /***
12   * @author VMD Group
13   * 
14   */
15  public class RemoteFile implements Serializable {
16  
17      private static final long serialVersionUID = 1L;
18  
19      private final int fileID;
20  
21      private final FileFactory rff;
22  
23      RemoteFile(int fileID, FileFactory rff)
24              throws NullPointerException {
25          if (rff == null)
26              throw new NullPointerException("RemoteFileFactory is null");
27          this.fileID = fileID;
28          this.rff = rff;
29      }
30  
31      public boolean disposeFileHandle() {
32          try {
33              return rff.disposeFileHandle(fileID);
34          } catch (RemoteException e) {
35              return false;
36          } catch (ItemNotFoundException e) {
37              return false;
38          }
39      }
40  
41      public Character getSeparatorChar() {
42          try {
43              return rff.getSeparatorChar();
44          } catch (RemoteException e) {
45              return null;
46          }
47      }
48  
49      public String getSeparator() {
50          try {
51              return rff.getSeparator();
52          } catch (RemoteException e) {
53              return null;
54          }
55  
56      }
57  
58      public Character getPathSeparatorChar() {
59          try {
60              return rff.getPathSeparatorChar();
61          } catch (RemoteException e) {
62              return null;
63          }
64      }
65  
66      public String getPathSeparator() throws SecurityException {
67          try {
68              return rff.getPathSeparator();
69          } catch (RemoteException e) {
70              return null;
71          }
72      }
73  
74      public String getName() throws SecurityException {
75          try {
76              return rff.getName(fileID);
77          } catch (RemoteException e) {
78              return null;
79          } catch (ItemNotFoundException infe) {
80              return null;
81          }
82      }
83  
84      public String getParent() throws SecurityException {
85          try {
86              return rff.getParent(fileID);
87          } catch (RemoteException e) {
88              return null;
89          } catch (ItemNotFoundException infe) {
90              return null;
91          }
92      }
93  
94      public String getPath() throws SecurityException {
95          try {
96              return rff.getPath(fileID);
97          } catch (RemoteException e) {
98              return null;
99          } catch (ItemNotFoundException infe) {
100             return null;
101         }
102     }
103 
104     public Boolean canRead() throws SecurityException {
105         try {
106             return rff.canRead(fileID);
107         } catch (RemoteException e) {
108             return null;
109         } catch (ItemNotFoundException infe) {
110             return null;
111         }
112     }
113 
114     public Boolean canWrite() throws SecurityException {
115         try {
116             return rff.canWrite(fileID);
117         } catch (RemoteException e) {
118             return null;
119         } catch (ItemNotFoundException infe) {
120             return null;
121         }
122     }
123 
124     public Boolean exists() throws SecurityException {
125         try {
126             return rff.exists(fileID);
127         } catch (RemoteException e) {
128             return null;
129         } catch (ItemNotFoundException infe) {
130             return null;
131         }
132     }
133 
134     public Boolean isDirectory() throws SecurityException {
135         try {
136             return rff.isDirectory(fileID);
137         } catch (RemoteException e) {
138             return null;
139         } catch (ItemNotFoundException infe) {
140             return null;
141         }
142     }
143 
144     public Boolean isFile() throws SecurityException {
145         try {
146             return rff.isFile(fileID);
147         } catch (RemoteException e) {
148             return null;
149         } catch (ItemNotFoundException infe) {
150             return null;
151         }
152     }
153 
154     public Boolean isHidden() throws SecurityException {
155         try {
156             return rff.isHidden(fileID);
157         } catch (RemoteException e) {
158             return null;
159         } catch (ItemNotFoundException infe) {
160             return null;
161         }
162     }
163 
164     public Long lastModified() throws SecurityException {
165         try {
166             return rff.lastModified(fileID);
167         } catch (RemoteException e) {
168             return null;
169         } catch (ItemNotFoundException infe) {
170             return null;
171         }
172     }
173 
174     public Long length() throws SecurityException {
175         try {
176             return rff.length(fileID);
177         } catch (RemoteException e) {
178             return null;
179         } catch (ItemNotFoundException infe) {
180             return null;
181         }
182     }
183 
184     public Boolean createNewFile() throws SecurityException {
185         try {
186             return rff.createNewFile(fileID);
187         } catch (RemoteException e) {
188             return null;
189         } catch (Exception infe) {
190             return null;
191         } 
192     }
193 
194     public Boolean delete() throws SecurityException {
195         try {
196             return rff.delete(fileID);
197         } catch (RemoteException e) {
198             return null;
199         } catch (ItemNotFoundException infe) {
200             return null;
201         }
202     }
203 
204     public FileDescriptor[] list() throws SecurityException {
205         try {
206             return rff.list(fileID);
207         } catch (RemoteException e) {
208             return null;
209         } catch (ItemNotFoundException infe) {
210             return null;
211         }
212     }
213 
214     public Boolean mkdir() throws SecurityException {
215         try {
216             return rff.mkdir(fileID);
217         } catch (RemoteException e) {
218             return null;
219         } catch (ItemNotFoundException infe) {
220             return null;
221         }
222     }
223 
224     public Boolean mkdirs() throws SecurityException {
225         try {
226             return rff.mkdirs(fileID);
227         } catch (RemoteException e) {
228             return null;
229         } catch (ItemNotFoundException infe) {
230             return null;
231         }
232     }
233 
234     public Boolean renameTo(String dest) throws SecurityException {
235         try {
236             return rff.renameTo(fileID,dest);
237         } catch (RemoteException e) {
238             return null;
239         } catch (ItemNotFoundException infe) {
240             return null;
241         }
242     }
243 
244     public Boolean setLastModified(long time) throws SecurityException {
245         try {
246             return rff.setLastModified(fileID,time);
247         } catch (RemoteException e) {
248             return null;
249         } catch (ItemNotFoundException infe) {
250             return null;
251         }
252     }
253 
254     public Boolean setReadOnly() throws SecurityException {
255         try {
256             return rff.setReadOnly(fileID);
257         } catch (RemoteException e) {
258             return null;
259         } catch (ItemNotFoundException infe) {
260             return null;
261         }
262     }
263     
264     public FileDescriptor getDescriptor() {
265     	try {
266 			return rff.getDescriptor(fileID);
267 		} catch (Exception e) {
268 			return null;
269 		}
270     }
271 
272 }