KickJava   Java API By Example, From Geeks To Geeks.

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


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 net.nutch.io.*;
6 import net.nutch.util.*;
7
8 import java.io.*;
9 import java.util.*;
10
11 /******************************************************
12  * NDFSFileInfo tracks info about remote files, including
13  * name, size, etc.
14  *
15  * @author Mike Cafarella
16  ******************************************************/

17 public class NDFSFileInfo implements Writable {
18     UTF8 path;
19     long len;
20     long contentsLen;
21     boolean isDir;
22
23     /**
24      */

25     public NDFSFileInfo() {
26     }
27
28     /**
29      */

30     public NDFSFileInfo(UTF8 path, long len, long contentsLen, boolean isDir) {
31         this.path = path;
32         this.len = len;
33         this.contentsLen = contentsLen;
34         this.isDir = isDir;
35     }
36
37     /**
38      */

39     public String JavaDoc getPath() {
40         return new File(path.toString()).getPath();
41     }
42
43     /**
44      */

45     public String JavaDoc getName() {
46         return new File(path.toString()).getName();
47     }
48
49     /**
50      */

51     public String JavaDoc getParent() {
52         return new File(path.toString()).getParent();
53     }
54
55     /**
56      */

57     public long getLen() {
58         return len;
59     }
60
61     /**
62      */

63     public long getContentsLen() {
64         return contentsLen;
65     }
66
67     /**
68      */

69     public boolean isDir() {
70         return isDir;
71     }
72
73     //////////////////////////////////////////////////
74
// Writable
75
//////////////////////////////////////////////////
76
public void write(DataOutput out) throws IOException {
77         path.write(out);
78         out.writeLong(len);
79         out.writeLong(contentsLen);
80         out.writeBoolean(isDir);
81     }
82
83     public void readFields(DataInput in) throws IOException {
84         this.path = new UTF8();
85         this.path.readFields(in);
86         this.len = in.readLong();
87         this.contentsLen = in.readLong();
88         this.isDir = in.readBoolean();
89     }
90 }
91
92
Popular Tags