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 abstract 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 * Returns the number of total blocks.
61 * @return The number of total blocks
63 public int getTotalBlocks() {
68 * Sets the number of total blocks.
71 * The number of total blocks
73 void setTotalBlocks(int totalBlocks) {
74 this.totalBlocks = totalBlocks;
78 * Returns the number of required blocks. For downloads, this number is
79 * smaller than {@link #getTotalBlocks()}.
81 * @return The number of required blocks
83 public int getRequiredBlocks() {
84 return requiredBlocks;
88 * Sets the number of required blocks.
90 * @param requiredBlocks
91 * The number of required blocks
93 void setRequiredBlocks(int requiredBlocks) {
94 this.requiredBlocks = requiredBlocks;
98 * Returns the number of successfully transferred blocks.
100 * @return The number of successfully transferred blocks
102 public int getSuccessfulBlocks() {
103 return successfulBlocks;
107 * Sets the number of successfully transferred blocks.
109 * @param successfulBlocks
110 * The number of successfully transferred blocks
112 void setSuccessfulBlocks(int successfulBlocks) {
113 this.successfulBlocks = successfulBlocks;
117 * Returns the number of failed blocks. Blocks that have failed can be
120 * @return The number of failed blocks
122 public int getFailedBlocks() {
127 * Sets the number of failed blocks.
129 * @param failedBlocks
130 * The number of failed blocks
132 void setFailedBlocks(int failedBlocks) {
133 this.failedBlocks = failedBlocks;
137 * Returns the number of fatally failed blocks. Fatally failed blocks will
138 * never complete, even with endless retries.
140 * @return The number of fatally failed blocks
142 public int getFatallyFailedBlocks() {
143 return fatallyFailedBlocks;
147 * Sets the number of fatally failed blocks.
149 * @param fatallyFailedBlocks
150 * The number fatally failed blocks
152 void setFatallyFailedBlocks(int fatallyFailedBlocks) {
153 this.fatallyFailedBlocks = fatallyFailedBlocks;
157 * Returns whether the result of {@link #getTotalBlocks()} is final, i.e. it
158 * won’t change anymore.
160 * @return <code>true</code> if the result of {@link #getTotalBlocks()} is
161 * final, <code>false</code> otherwise
163 public boolean isTotalFinalized() {
164 return totalFinalized;
168 * Sets whether the result of {@link #getTotalBlocks()} is final, i.e. it
169 * won’t change anymore.
171 * @param totalFinalized
172 * <code>true</code> if the result of {@link #getTotalBlocks()}
173 * is final, <code>false</code> otherwise
175 void setTotalFinalized(boolean totalFinalized) {
176 this.totalFinalized = totalFinalized;