2 * jSite2 - SimpleProgress.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;
23 * A “SimpleProgress” message tells the client about the progress of a
24 * {@link ClientGet} or {@link ClientPut} operation.
26 * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
28 public class SimpleProgress extends BaseMessage {
31 * Creates a new “SimpleProgress” message that wraps the received message.
33 * @param receivedMessage
34 * The received message
36 SimpleProgress(FcpMessage receivedMessage) {
37 super(receivedMessage);
41 * Returns the total number of blocks. This number may increase as long as
42 * {@link #isFinalizedTotal()} returns <code>false</code>.
44 * @return The total number of blocks
46 public int getTotal() {
47 return FcpUtils.safeParseInt(getField("Total"));
51 * Returns the number of blocks that are required to completet the request.
52 * This number might actually be lower than {@link #getTotal} because of
53 * redundancy information. This number may also increase as long as
54 * {@link #isFinalizedTotal()} returns <code>false</code>.
56 * @return The number of required blocks
58 public int getRequired() {
59 return FcpUtils.safeParseInt(getField("Required"));
63 * Returns the number of blocks that have failed and run out of retries.
65 * @return The number of failed blocks
67 public int getFailed() {
68 return FcpUtils.safeParseInt(getField("Failed"));
72 * Returns the number of fatally failed blocks. A block that failed fatally
73 * can never be completed, even with infinite retries.
75 * @return The number of fatally failed blocks
77 public int getFatallyFailed() {
78 return FcpUtils.safeParseInt(getField("FatallyFailed"));
82 * Returns the number of blocks that have been successfully processed.
84 * @return The number of succeeded blocks
86 public int getSucceeded() {
87 return FcpUtils.safeParseInt(getField("Succeeded"));
91 * Returns whether the total number of blocks (see {@link #getTotal()} has
92 * been finalized. Once the total number of blocks has been finalized for a
93 * request it will not change any more, and this method of every further
94 * SimpleProgress message will always return <code>true</code>.
96 * @return <code>true</code> if the number of total blocks has been
97 * finalized, <code>false</code> otherwise
99 public boolean isFinalizedTotal() {
100 return Boolean.valueOf(getField("FinalizedTotal"));
104 * Returns the identifier of the request.
106 * @return The identifier of the request
108 public String getIdentifier() {
109 return getField("Identifier");