01: /*
02: * This file is part of DrFTPD, Distributed FTP Daemon.
03: *
04: * DrFTPD is free software; you can redistribute it and/or modify
05: * it under the terms of the GNU General Public License as published by
06: * the Free Software Foundation; either version 2 of the License, or
07: * (at your option) any later version.
08: *
09: * 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 org.drftpd.slave;
19:
20: import java.io.Serializable;
21:
22: /**
23: * @author mog
24: * @version $Id: TransferStatus.java 1290 2005-10-04 00:37:27Z zubov $
25: */
26: public class TransferStatus implements Serializable {
27: private long _checksum;
28: private long _elapsed;
29: private boolean _isFinished;
30: private Throwable _throwable;
31: private long _transfered;
32: private TransferIndex _transferIndex;
33:
34: public TransferStatus(long elapsed, long transfered, long checksum,
35: boolean isFinished, TransferIndex transferIndex) {
36: _transferIndex = transferIndex;
37: _elapsed = elapsed;
38: _transfered = transfered;
39: _checksum = checksum;
40: _isFinished = isFinished;
41: _throwable = null;
42: }
43:
44: public TransferStatus(TransferIndex transferIndex, Throwable t) {
45: this (0, 0, 0, true, transferIndex);
46: _throwable = t;
47: }
48:
49: public long getChecksum() {
50: return _checksum;
51: }
52:
53: public long getElapsed() {
54: return _elapsed;
55: }
56:
57: public Throwable getThrowable() {
58: return _throwable;
59: }
60:
61: public long getTransfered() {
62: return _transfered;
63: }
64:
65: public TransferIndex getTransferIndex() {
66: return _transferIndex;
67: }
68:
69: public long getXferSpeed() {
70: if (_transfered == 0) {
71: return 0;
72: }
73:
74: if (_elapsed == 0) {
75: return 0;
76: }
77:
78: return (long) (_transfered / ((float) _elapsed / (float) 1000));
79: }
80:
81: public boolean isFinished() {
82: return _isFinished;
83: }
84:
85: public boolean threwException() {
86: return (_throwable != null);
87: }
88:
89: public String toString() {
90: return "TransferStatus=[xferspeed=" + getXferSpeed()
91: + "][transfered=" + getTransfered() + "][elapsed="
92: + getElapsed() + "]";
93: }
94:
95: }
|