KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > drftpd > remotefile > StaticRemoteFile


1 /*
2  * This file is part of DrFTPD, Distributed FTP Daemon.
3  *
4  * DrFTPD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * DrFTPD is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with DrFTPD; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  */

18 package net.sf.drftpd.remotefile;
19
20 import java.util.Collection JavaDoc;
21 import java.util.Collections JavaDoc;
22 import java.util.List JavaDoc;
23
24 /**
25  * Creates a single RemoteFile object that is not linked to any other objects.
26  *
27  * @author mog
28  * @version $Id: StaticRemoteFile.java,v 1.28.2.1 2004/06/11 00:59:58 mog Exp $
29  */

30 public class StaticRemoteFile extends AbstractRemoteFile {
31     private long _checkSum;
32     private String JavaDoc _groupname;
33     private boolean _isDeleted;
34     private long _lastModified;
35     private long _length;
36     private String JavaDoc _link = null;
37     private String JavaDoc _name;
38     private List JavaDoc _rslaves;
39     private String JavaDoc _username;
40     private long _xfertime;
41
42     /**
43      * @param rslaves null indicates that this is a directory.
44      */

45     public StaticRemoteFile(
46         List JavaDoc rslaves,
47         String JavaDoc name,
48         String JavaDoc owner,
49         String JavaDoc group,
50         long size,
51         long lastModified) {
52         _rslaves = rslaves;
53         _name = name;
54         // if(name.indexOf("/") != -1) {
55
// throw new IllegalArgumentException("constructor only does files and not paths");
56
// }
57
_username = owner;
58         _groupname = group;
59         _length = size;
60         _lastModified = lastModified;
61     }
62
63     public StaticRemoteFile(
64         List JavaDoc rslaves,
65         String JavaDoc name,
66         String JavaDoc owner,
67         String JavaDoc group,
68         long size,
69         long lastModified,
70         long checkSum) {
71         this(rslaves, name, owner, group, size, lastModified);
72         _checkSum = checkSum;
73     }
74
75     public StaticRemoteFile(List JavaDoc rslaves, String JavaDoc name, long size) {
76         this(rslaves, name, null, null, size, System.currentTimeMillis());
77     }
78     public StaticRemoteFile(String JavaDoc name) {
79         _name = name;
80     }
81
82     public StaticRemoteFile(String JavaDoc name, List JavaDoc rslaves) {
83         this(name);
84         _rslaves = rslaves;
85     }
86
87     public long getCheckSumCached() {
88         return _checkSum;
89     }
90     
91     /**
92      * StaticRemoteFile cannot be linked
93      * @return java.util.Collections.EMPTY_LIST
94      */

95     public Collection JavaDoc getFiles() {
96         return Collections.EMPTY_LIST;
97     }
98
99     public String JavaDoc getGroupname() {
100         return _groupname;
101     }
102
103     public String JavaDoc getLinkPath() {
104         return _link;
105     }
106
107     public String JavaDoc getName() {
108         return _name;
109     }
110
111     public String JavaDoc getParent() {
112         throw new UnsupportedOperationException JavaDoc("getParent() does not exist in StaticRemoteFile");
113     }
114
115     public String JavaDoc getPath() {
116         throw new UnsupportedOperationException JavaDoc();
117     }
118
119     public Collection JavaDoc getSlaves() {
120         return _rslaves;
121     }
122
123     public String JavaDoc getUsername() {
124         return _username;
125     }
126
127     public long getXfertime() {
128         return _xfertime;
129     }
130
131     public boolean isDeleted() {
132         return _isDeleted;
133     }
134
135     public boolean isDirectory() {
136         return _rslaves == null;
137     }
138
139     public boolean isFile() {
140         return _rslaves != null;
141     }
142
143     public boolean isLink() {
144         return _link != null;
145     }
146
147     public long lastModified() {
148         return _lastModified;
149     }
150
151     public long length() {
152         return _length;
153     }
154
155     /**
156      * Sets the checkSum.
157      * @param checkSum The checkSum to set
158      */

159     public void setCheckSum(long checkSum) {
160         _checkSum = checkSum;
161     }
162
163     public void setDeleted(boolean isDeleted) {
164         _isDeleted = isDeleted;
165     }
166
167     public void setGroupname(String JavaDoc groupname) {
168         _groupname = groupname;
169     }
170
171     public void setLastModified(long lastmodified) {
172         _lastModified = lastmodified;
173     }
174
175     public void setLength(long length) {
176         _length = length;
177     }
178
179     public void setLink(String JavaDoc link) {
180         _link = link;
181     }
182
183     public void setRSlaves(List JavaDoc rslaves) {
184         _rslaves = rslaves;
185     }
186
187     public void setUsername(String JavaDoc username) {
188         _username = username;
189     }
190
191     public void setXfertime(long xfertime) {
192         _xfertime = xfertime;
193     }
194
195     public String JavaDoc toString() {
196
197         StringBuffer JavaDoc ret = new StringBuffer JavaDoc();
198         ret.append(getClass().getName() + "[");
199         if (isDirectory())
200             ret.append("[isDirectory(): true]");
201         if (isFile())
202             ret.append("[isFile(): true]");
203         ret.append("[length(): " + length() + "]");
204         ret.append(getName());
205         ret.append("]");
206         ret.append("[rslaves:" + _rslaves + "]");
207         return ret.toString();
208     }
209
210 }
211
Popular Tags