KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > drftpd > slave > TransferStatus


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.slave;
19
20 import java.io.Serializable JavaDoc;
21 import java.net.InetAddress JavaDoc;
22
23 /**
24  * @author mog
25  * @version $Id: TransferStatus.java,v 1.5 2004/04/22 02:10:12 mog Exp $
26  */

27 public class TransferStatus implements Serializable JavaDoc {
28     private long _checksum;
29     private long _elapsed, _transfered;
30     private InetAddress JavaDoc _peer;
31
32     public TransferStatus(long elapsed, long transfered, long checksum, InetAddress JavaDoc peer) {
33         _elapsed = elapsed;
34         _transfered = transfered;
35         _checksum = checksum;
36         if(peer == null) throw new NullPointerException JavaDoc();
37         _peer = peer;
38     }
39
40     public long getChecksum() {
41         return _checksum;
42     }
43
44     /**
45      * @see TransferImpl#getElapsed()
46      */

47     public long getElapsed() {
48         return _elapsed;
49     }
50
51     /**
52      * @see TransferImpl#getTransfered()
53      */

54     public long getTransfered() {
55         return _transfered;
56     }
57
58     /**
59      * @see TransferImpl#getXferSpeed()
60      */

61     public int getXferSpeed() {
62         if (_transfered == 0)
63             return 0;
64         if (_elapsed == 0)
65             return 0;
66         return (int) (_transfered / ((float) _elapsed / (float) 1000));
67     }
68
69     public InetAddress JavaDoc getPeer() {
70         return _peer;
71     }
72
73 }
74
Popular Tags