2 * jFCPlib-high-level-client - HighLevelContinuosResult.java -
3 * Copyright © 2008 David Roden
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.
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.
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.
20 package net.pterodactylus.fcp.highlevel;
23 * Result for operations that send progress messages until they have completed.
25 * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
28 public class HighLevelProgress extends HighLevelResult {
30 /** The number of total blocks. */
31 private int totalBlocks;
33 /** The number of required blocks. */
34 private int requiredBlocks;
36 /** The number of successfully transferred blocks. */
37 private int successfulBlocks;
39 /** The number of failed blocks. */
40 private int failedBlocks;
42 /** The number of fatally failed blocks. */
43 private int fatallyFailedBlocks;
45 /** Whether the total number is finalized. */
46 private boolean totalFinalized;
49 * Package-private constructor.
52 * The identifier of the request
54 public HighLevelProgress(String identifier) {
59 * Creates a new high-level progress with the given values.
62 * The identifier of the request
64 * The total number of blocks
65 * @param requiredBlocks
66 * The number of required blocks
67 * @param successfulBlocks
68 * The number of successful blocks
70 * The number of failed blocks
71 * @param fatallyFailedBlocks
72 * The number of fatally failed blocks
73 * @param totalFinalized
74 * <code>true</code> if the total number of blocks is
75 * finalized, <code>false</code> otherwise
77 public HighLevelProgress(String identifier, int totalBlocks, int requiredBlocks, int successfulBlocks, int failedBlocks, int fatallyFailedBlocks, boolean totalFinalized) {
79 this.totalBlocks = totalBlocks;
80 this.requiredBlocks = requiredBlocks;
81 this.successfulBlocks = successfulBlocks;
82 this.failedBlocks = failedBlocks;
83 this.fatallyFailedBlocks = fatallyFailedBlocks;
84 this.totalFinalized = totalFinalized;
88 * Returns the number of total blocks.
90 * @return The number of total blocks
92 public int getTotalBlocks() {
97 * Sets the number of total blocks.
100 * The number of total blocks
102 void setTotalBlocks(int totalBlocks) {
103 this.totalBlocks = totalBlocks;
107 * Returns the number of required blocks. For downloads, this number is
108 * smaller than {@link #getTotalBlocks()}.
110 * @return The number of required blocks
112 public int getRequiredBlocks() {
113 return requiredBlocks;
117 * Sets the number of required blocks.
119 * @param requiredBlocks
120 * The number of required blocks
122 void setRequiredBlocks(int requiredBlocks) {
123 this.requiredBlocks = requiredBlocks;
127 * Returns the number of successfully transferred blocks.
129 * @return The number of successfully transferred blocks
131 public int getSuccessfulBlocks() {
132 return successfulBlocks;
136 * Sets the number of successfully transferred blocks.
138 * @param successfulBlocks
139 * The number of successfully transferred blocks
141 void setSuccessfulBlocks(int successfulBlocks) {
142 this.successfulBlocks = successfulBlocks;
146 * Returns the number of failed blocks. Blocks that have failed can be
149 * @return The number of failed blocks
151 public int getFailedBlocks() {
156 * Sets the number of failed blocks.
158 * @param failedBlocks
159 * The number of failed blocks
161 void setFailedBlocks(int failedBlocks) {
162 this.failedBlocks = failedBlocks;
166 * Returns the number of fatally failed blocks. Fatally failed blocks will
167 * never complete, even with endless retries.
169 * @return The number of fatally failed blocks
171 public int getFatallyFailedBlocks() {
172 return fatallyFailedBlocks;
176 * Sets the number of fatally failed blocks.
178 * @param fatallyFailedBlocks
179 * The number fatally failed blocks
181 void setFatallyFailedBlocks(int fatallyFailedBlocks) {
182 this.fatallyFailedBlocks = fatallyFailedBlocks;
186 * Returns whether the result of {@link #getTotalBlocks()} is final, i.e. it
187 * won’t change anymore.
189 * @return <code>true</code> if the result of {@link #getTotalBlocks()} is
190 * final, <code>false</code> otherwise
192 public boolean isTotalFinalized() {
193 return totalFinalized;
197 * Sets whether the result of {@link #getTotalBlocks()} is final, i.e. it
198 * won’t change anymore.
200 * @param totalFinalized
201 * <code>true</code> if the result of {@link #getTotalBlocks()}
202 * is final, <code>false</code> otherwise
204 void setTotalFinalized(boolean totalFinalized) {
205 this.totalFinalized = totalFinalized;