2 * jFCPlib - SimpleProgress.java - Copyright © 2008 David Roden
4 * This program 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.
9 * This program 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.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 package net.pterodactylus.fcp;
22 * A “SimpleProgress” message tells the client about the progress of a
23 * {@link ClientGet} or {@link ClientPut} operation.
25 * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
27 public class SimpleProgress extends BaseMessage implements Identifiable {
30 * Creates a new “SimpleProgress” message that wraps the received message.
32 * @param receivedMessage
33 * The received message
35 public SimpleProgress(FcpMessage receivedMessage) {
36 super(receivedMessage);
40 * Returns the total number of blocks. This number may increase as long as
41 * {@link #isFinalizedTotal()} returns <code>false</code>.
43 * @return The total number of blocks
45 public int getTotal() {
46 return FcpUtils.safeParseInt(getField("Total"));
50 * Returns the number of blocks that are required to completet the request.
51 * This number might actually be lower than {@link #getTotal} because of
52 * redundancy information. This number may also increase as long as
53 * {@link #isFinalizedTotal()} returns <code>false</code>.
55 * @return The number of required blocks
57 public int getRequired() {
58 return FcpUtils.safeParseInt(getField("Required"));
62 * Returns the number of blocks that have failed and run out of retries.
64 * @return The number of failed blocks
66 public int getFailed() {
67 return FcpUtils.safeParseInt(getField("Failed"));
71 * Returns the number of fatally failed blocks. A block that failed fatally
72 * can never be completed, even with infinite retries.
74 * @return The number of fatally failed blocks
76 public int getFatallyFailed() {
77 return FcpUtils.safeParseInt(getField("FatallyFailed"));
81 * Returns the number of blocks that have been successfully processed.
83 * @return The number of succeeded blocks
85 public int getSucceeded() {
86 return FcpUtils.safeParseInt(getField("Succeeded"));
90 * Returns whether the total number of blocks (see {@link #getTotal()} has
91 * been finalized. Once the total number of blocks has been finalized for a
92 * request it will not change any more, and this method of every further
93 * SimpleProgress message will always return <code>true</code>.
95 * @return <code>true</code> if the number of total blocks has been
96 * finalized, <code>false</code> otherwise
98 public boolean isFinalizedTotal() {
99 return Boolean.valueOf(getField("FinalizedTotal"));
103 * Returns the identifier of the request.
105 * @return The identifier of the request
108 public String getIdentifier() {
109 return getField("Identifier");