KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > nutch > ndfs > NDFSFile


1 /* Copyright (c) 2004 The Nutch Organization. All rights reserved. */
2 /* Use subject to the conditions in http://www.nutch.org/LICENSE.txt. */
3 package net.nutch.ndfs;
4
5 import java.io.*;
6 import java.net.*;
7 import java.util.*;
8
9
10 /*****************************************************************
11  * NDFSFile is a traditional java File that's been annotated with
12  * some extra information.
13  *
14  * @author Mike Cafarella
15  *****************************************************************/

16 public class NDFSFile extends File {
17     NDFSFileInfo info;
18
19     /**
20      */

21     public NDFSFile(NDFSFileInfo info) {
22         super(info.getPath());
23         this.info = info;
24     }
25
26     /**
27      * A number of File methods are unsupported in this subclass
28      */

29     public boolean canRead() {
30         return false;
31     }
32     public boolean canWrite() {
33         return false;
34     }
35     public boolean createNewFile() {
36         return false;
37     }
38     public boolean delete() {
39         return false;
40     }
41     public void deleteOnExit() {
42     }
43     public boolean isHidden() {
44         return false;
45     }
46
47     /**
48      * We need to reimplement some of them
49      */

50     public boolean isDirectory() {
51         return info.isDir();
52     }
53     public boolean isFile() {
54         return ! isDirectory();
55     }
56     public long length() {
57         return info.getLen();
58     }
59
60     /**
61      * And add a few extras
62      */

63     public long getContentsLength() {
64         return info.getContentsLen();
65     }
66 }
67
Popular Tags