add continuous callback
[jFCPlib.git] / src / net / pterodactylus / fcp / highlevel / HighLevelContinuousResult.java
1 /*
2  * jFCPlib-high-level-client - HighLevelContinuosResult.java -
3  * Copyright © 2008 David Roden
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  */
19
20 package net.pterodactylus.fcp.highlevel;
21
22 /**
23  * Result for operations that send progress messages until they have completed.
24  * 
25  * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
26  * @version $Id$
27  */
28 public abstract class HighLevelContinuousResult extends HighLevelResult {
29
30         /** The number of total blocks. */
31         private int totalBlocks;
32
33         /** The number of required blocks. */
34         private int requiredBlocks;
35
36         /** The number of successfully transferred blocks. */
37         private int successfulBlocks;
38
39         /** The number of failed blocks. */
40         private int failedBlocks;
41
42         /** The number of fatally failed blocks. */
43         private int fatallyFailedBlocks;
44
45         /** Whether the total number is finalized. */
46         private boolean totalFinalized;
47
48         /**
49          * Returns the number of total blocks.
50          * 
51          * @return The number of total blocks
52          */
53         public int getTotalBlocks() {
54                 return totalBlocks;
55         }
56
57         /**
58          * Sets the number of total blocks.
59          * 
60          * @param totalBlocks
61          *            The number of total blocks
62          */
63         void setTotalBlocks(int totalBlocks) {
64                 this.totalBlocks = totalBlocks;
65         }
66
67         /**
68          * Returns the number of required blocks. For downloads, this number is
69          * smaller than {@link #getTotalBlocks()}.
70          * 
71          * @return The number of required blocks
72          */
73         public int getRequiredBlocks() {
74                 return requiredBlocks;
75         }
76
77         /**
78          * Sets the number of required blocks.
79          * 
80          * @param requiredBlocks
81          *            The number of required blocks
82          */
83         void setRequiredBlocks(int requiredBlocks) {
84                 this.requiredBlocks = requiredBlocks;
85         }
86
87         /**
88          * Returns the number of successfully transferred blocks.
89          * 
90          * @return The number of successfully transferred blocks
91          */
92         public int getSuccessfulBlocks() {
93                 return successfulBlocks;
94         }
95
96         /**
97          * Sets the number of successfully transferred blocks.
98          * 
99          * @param successfulBlocks
100          *            The number of successfully transferred blocks
101          */
102         void setSuccessfulBlocks(int successfulBlocks) {
103                 this.successfulBlocks = successfulBlocks;
104         }
105
106         /**
107          * Returns the number of failed blocks. Blocks that have failed can be
108          * retried.
109          * 
110          * @return The number of failed blocks
111          */
112         public int getFailedBlocks() {
113                 return failedBlocks;
114         }
115
116         /**
117          * Sets the number of failed blocks.
118          * 
119          * @param failedBlocks
120          *            The number of failed blocks
121          */
122         void setFailedBlocks(int failedBlocks) {
123                 this.failedBlocks = failedBlocks;
124         }
125
126         /**
127          * Returns the number of fatally failed blocks. Fatally failed blocks will
128          * never complete, even with endless retries.
129          * 
130          * @return The number of fatally failed blocks
131          */
132         public int getFatallyFailedBlocks() {
133                 return fatallyFailedBlocks;
134         }
135
136         /**
137          * Sets the number of fatally failed blocks.
138          * 
139          * @param fatallyFailedBlocks
140          *            The number fatally failed blocks
141          */
142         void setFatallyFailedBlocks(int fatallyFailedBlocks) {
143                 this.fatallyFailedBlocks = fatallyFailedBlocks;
144         }
145
146         /**
147          * Returns whether the result of {@link #getTotalBlocks()} is final, i.e. it
148          * won’t change anymore.
149          * 
150          * @return <code>true</code> if the result of {@link #getTotalBlocks()} is
151          *         final, <code>false</code> otherwise
152          */
153         public boolean isTotalFinalized() {
154                 return totalFinalized;
155         }
156
157         /**
158          * Sets whether the result of {@link #getTotalBlocks()} is final, i.e. it
159          * won’t change anymore.
160          * 
161          * @param totalFinalized
162          *            <code>true</code> if the result of {@link #getTotalBlocks()}
163          *            is final, <code>false</code> otherwise
164          */
165         void setTotalFinalized(boolean totalFinalized) {
166                 this.totalFinalized = totalFinalized;
167         }
168
169 }